Hi Tomas,

> : (do2 (I . 5) (print I) "finished")

The current implementation of 'do' is not well suited to grant access to
the internal counter to the application level.

Because 32bit PicoLisp has no short numbers, incrementing a number
always results in the allocation of a new cell (turning the old cell
into garbage). To avoid this, 'do' creates a copy of its first argument
at the beginning, and destructively increments it at each pass through
the loop. If we make this value available to an application, strange
things would happen (modifying values as side effects).

As there is the 'for' function which handles similar cases, I never
really missed such a feature.

Should we think about it again for the 64bit version? Then we'll have
60bit short numbers which will probably not be exceeded for most loops.

> However, I am not sure what level it
> should be (not 123 really)...  How do you count how many frames need
> to be skipped in such cases to get to the scope out of the function?

To go one level up always '1' should be enough. You simply count the
levels of functional bindings, e.g.:

   (de foo (Lst . Prg)
         '((X) (eval X 2))
         Lst ) )

Here we must use '2', as we want to eval the expression 'X' in the scope
outside of 'foo', and between that is another function '((X) ..)'.

- Alex

Reply via email to