Following discussions and some rants on polyadic arrays and compact linear types, and of course the "dynamic" issue, I have decided to do some experiments in Felix.
Rants deleted .. just run the code! [You WILL need the latest Felix, because I have changed lists so that a list is now also an array] // Type descriptors. // First cut, doesn't handle recursion! class Desc { union typecode = | Primitive of string // for now, just the name of a primitive type eg "int" etc | Tuple of list[typecode] // a tuple of various types | Array of int * typecode // an array ; instance Str[typecode] { fun str : typecode -> string = | Primitive ?s => s | Tuple Empty => "()" | Tuple (Cons (?h, ?t)) => "(" + fold_left (fun (acc:string) (x:typecode) => acc + "," + x.str) (h.str) t + ")" | Array (?n, ?t) => str t + "^" + Str::str n ; } // example: var ex1 = Array (3, Tuple ( Primitive "int", Primitive "string").list ); println$ ex1; union selector = | Choice of int // pick one of the tree nodes ; typedef path = list[selector]; fun component (t: typecode) (i: path) => match t,i with | _, Empty => t // | Primitive _, _ => fail "ERROR" // fail doesn't unify properly at the moment | Tuple ?ts, Cons (Choice ?i, ?tail) => component ts.i tail | Array (_,?t), Cons (Choice _, ?tail) => component t tail endmatch ; // example: println$ component ex1 (Choice 1).list; } -- john skaller skal...@users.sourceforge.net http://felix-lang.org ------------------------------------------------------------------------------ Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery and much more. Keep your Java skills current with LearnJavaNow - 200+ hours of step-by-step video tutorials by Java experts. SALE $49.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122612 _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language