On Tue, 2007-07-24 at 06:58 +1000, skaller wrote:
> On Mon, 2007-07-23 at 22:27 +1000, skaller wrote:
[]
Simplified to this now:
////////////////////////////
#import <flx.flxh>
#symbol "^^"
syntax fthreads {
statement := ^^ statement =>#
"""(call "spawn_fthread" (lazy (list _2)))"""
;
statement := [ statement ] =>#
"""(call "spawn_fthread" (lazy (list _2)))"""
;
}
open syntax fthreads;
^^ println "Hello";
[ println "bye"; ]
////////////////////////////
The (Scheme) function lazy returns a lambda function expression
equivalent to { ss } where ss is a list of statements. Since
we only have a single statement here we need (list _2) to convert
the argument to a list. The term
(call "spawn_fthread" a)
generates (Felix) code that calls the function spawn_fthread
with argument a. This is inspired by the fact that:
`(ast_call ,_sr (ast_name "spawn_fthread" ())
(ast_lambda (,dfltvs ((() none)) none (,_2))))
is rather hard to read .. (it took me 8 goes to get it right,
and that's with a bracket matching editor).
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language