I'm thinking of changing procedures so they can return values.
The only difference between procs and funs will be that procs
can have side effects, and applications are eagerly evaluated.

The implementation of a proc returning a value will be a proc
with an extra argument pointing to the place to assign the
result. Procs in expressions will be lifted out like generators.
This means for a proc with a return value the implementation:

        `BEXE_init ( v, `BEXE_apply(f,a))

will get changed to 

        `BEXE_call (f, (&v, a))

[actually, the &v argument will be prepended to the
argument tuple type, so if a above is the tuple (b,c,d)
we actually call with (&v,b,c,d)]

The effect is that 'proc' style functions can now call the
collector and do other naughty things on the side.

The idea is .. once this is working, just make ALL** functions
procs, and voila .. we have solved the gc problem.

In practice there are two exceptions: where there's no need,
and it gets in the way of optimisations, and, where it is
otherwise specified for some reason (eg a functional form
is required for a callback).

The disadvantage of procs here is that expressions are
forcibly unravelled to SSA form for eager evaluation,
possibly preventing inlining, possibly wasting space
with extra variables, and possibly stopping the C++
compiler doing optimisations it otherwise could.


-- 
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
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to