Ok, so now stream macros support arguments:
/////////////////////////////
_tokdef px x y = print x; print " "; print y; endl _edef
px _tok ("Yuk!" + " yyy") _etok " gak";
/////////////////////////////
Here are the semantics. First, in a completely separate
phase, _tok ... _etok sequences are compressed into
a single token (recursively).
Now, a _tokdef can specify parameters:
_tokdef px x y = print x; print " "; print y; endl _edef
here there are two, x and y. A call to this macro:
px _tok ("Yuk!" + " yyy") _etok " gak";
maps each parameter to a SINGLE token argument.
Note that _tok ("Yuk!" + " yyy") _etok is a single token!
Next, the parameters in the body are replaced by the
argument tokens. Then the body is pushed into the input
queue for rescanning.
When a _tok .. _etok token is found in the input queue,
it is unpacked, and replaced in the input queue with
the tokens it wrapped, those tokens are then scanned.
I am considering adding some special features to manage
mapping of keywords. For example Felix will change so
"_goto", "_let", "_fun" etc are keywords.
Then, the programmer will map identifiers to those keywords:
_tokdef goto = _goto _edef
This allows a German to write:
gehen start; // goto start
and it allows you to say:
_undef goto
to get rid of gotos :)
Another potential use is internationalisation of messages:
_tokdef err42 = "Earth bulldozed to make way for skyway" _edef
in one file, can be replaced in another by messages in another
language.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language