Ralf Hemmecke wrote:
>
> Hi Waldek,
>
> Thank you for
>
> > Experimental support for generators.
>
> Is the usage similar to Aldor or are there some differences. I'd like to
> test that as soon as possible.
>
See my other message.
> I'd also like to understand what is happening inside, maybe you can give
> a few lines of documentation?
>
compIterator is converts phrases like 'x in l' or 'while ..' to form
expected by other parts of the compiler. The new code compiles
'l' (from 'x in 'l') and checks if resulting type is 'Generator(y)'
for some 'y'. If yes it generates code which extracts 'emptyFun'
and 'stepFun' from 'l' and outputs form '["GSTEP", x, ef, sf, code]'
where 'code' is freshly generated code, ef and sf are new (generated)
variables and x came from 'x in 'l'.
In general Spad iteration has some code to initialize the loop,
code to test for end of iteration (more precisely, body is execuded
only if test gives false), body and possibly return value
(return value is only used for things like '[x for x in 1..5]',
that is for List/Vector constructors). That is Spad loop compiles
to code like:
Init code
label1:
test code
if test_result then goto label2
body
goto label1
label2:
-- possibly produce result value
Each phrase of loop (handled by compIterator) may add something to
init code, test code and to body (for interation over integer values
are incremented at end of body). 'compIterator' treats each
phrase separately. Later 'expandREPEAT' in g-boot.boot loops
over phrases, collects apropriate parts and (via 'expandDO')
finally generates Lisp code. More precisely, 'expandREPEAT'
produces list of variables, each with init code, list of tests
and augumented body. Then 'expandDO' declares variables and
puts variable initialization in init part, and build loop.
In case of "GSTEP" 'expandREPEAT' will add x to list of iteration
variables, add 'code' to code run before the loop (more precisely
as part of initialzation for 'x'), add '(SPADCALL ef)' to list of
tests (actually, the test will also do assignment of '(SPADCALL sf)'
to 'x').
--
Waldek Hebisch
[email protected]
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en.