On 14/08/2012, at 11:16 AM, john skaller wrote: >> >> for x in 3.14,'foo',1234 do >> // compiler unrolls this 3 times ... >> done > > 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). Felix used to be able to do this with macros, but macros suck and it doesn't work with variables of tuple type -- a proper version using polymorphic recursion would. To make it work you must first think what it means. In effect it means: the body of the for loop has to be a generic procedure. So you must make a class for it in the parser. The you instantiate the class with the usual patterns for zero, one, two and many tuple components (you might skip the zero and one cases to start, you need the "one" case to handle "sub tables" of tables, i.e. nested tuples). Doing this in the parser is NOT EASY because you have to write Scheme code that generates the appropriate S-expressions. maybe it can be done by generic_iter P tuple without resorting to the parser. I dunno. Might be a good idea to try some examples "by hand" first, to see what the patterns required are. -- 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