diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-12-18 11:06:57 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-12-18 11:06:57 -0800 |
commit | e0cd2bef0fd5d7f378d8ab9caa547d50c48808d4 (patch) | |
tree | 122b6b5c8967e98297f9bcee59da09f05bb87a1d /txr.spec | |
parent | 9ae286b5a405f52cd83a0d2f6f8ee348e86b824e (diff) | |
download | txr-e0cd2bef0fd5d7f378d8ab9caa547d50c48808d4.tar.gz txr-e0cd2bef0fd5d7f378d8ab9caa547d50c48808d4.tar.bz2 txr-e0cd2bef0fd5d7f378d8ab9caa547d50c48808d4.zip |
Refactoring internals of for/each operators.
NOTE: The socket test cases do not pass under this commit:
this is expected.
The for and each family of operators will now be macros which
expand to let/let* binding construct wrapping a lower level
special operator.
This is in preparation for a change to how special variable
binding is implemented.
This change reduces the number of special forms which bind
variables.
There is a single low-level operator for for loops called
sys:for-op. Its syntax is a lot like the C89 for loop:
(sys:for-op init-forms test step-forms body). The init-forms
do not bind anything; it is just forms.
There is a sys:each operator for implementing each,
each*, append-each and all those operators. Its syntax is
(sys:each-op type-sym optional-vars . body).
The type-sym is one of each, append-each or collect-each.
If optional-vars is nil, then the operator looks at the
immediate lexical environment, and assumes all the bindings
there are the each iteration variables and it works with
those bindings, like its predecessor did. Otherwise
optional-vars is a list of symbols: the operator walks the
list and resolves each element to a binding. This is
used in two situations: when some of the variables are
special (dynamically scoped) or when the variables are
bound sequentially with let* and are thus scattered in
multiple levels of environment.
* eval.c (for_op_s, each_op_s): New symbol variables.
(get_bindings): New static function.
(op_each): Now implements sys:each-op.
(op_for): Now implements sys:for-op.
(get_var_syms): New static function.
(me_each, me_for): New static functions.
(do_expand): Do not expand the each operator family under the
same rule. New case handling sys:each-op is introduced
due to the different syntax.
The for case restructured to handle for_op_s.
(eval_init): Intern sys:each-op and sys:for-op symbols.
Register the corresponding operators. Move registrations of
the public symbols each, each*, for, for* and all the other
each variants to be macros.
* tests/011/macros-2.expected: Updated with different
macro expansion which is now produced for a while
loop.
Diffstat (limited to 'txr.spec')
0 files changed, 0 insertions, 0 deletions