On 14/08/2012, at 4:45 PM, Dobes Vandermeer wrote: > > Excellent idea. Type safe macros for table generation over heterogenous > > types! > > > You can try this. You will have a lot of pain! > It has to be done in the parser (don't use "for", use "tuplefor" to avoid > hassles parsing). > > Hmm yeah maybe I haven't dug into the compiler architecture much yet. > > I don't think it would work at the parser level since the type of the tuple > has to be known.
Yes yes, that's not the point. The parser isn't doing the unrolling, its generating classes with a virtual procedure and instances that will do the unrolling. You can do what you want now, but you have to write class myfor[T] { virtual proc P: T; } instance[T,U] myfor[T ** U] { ... } instance[T,U] myfor [T * U} { ... } for every such loop. The parser would just do all that housekeeping for you. The body of the loop is the procedure P (with a tail call to P[U] to make the polyjmorphic recursion happen). > So it would have to be done at a later stage. I don't know how yet, maybe > I'll give up before I get there. As above. Look at lib/std/tuple.flx This deals with a function like "str" on a tuple. Just replace "str" with "P" where P is the body of the loop. -- john skaller skal...@users.sourceforge.net http://felix-lang.org ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language