Many of the languages (if not most) that are planned to be implemented
above Parrot are lexically-scoped. The methodology to implement such
behaviour on top of an otherwise non-LS VM was described by Abelson and
Sussman in the book "Structure and Interpretation of Computer Programs":

http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-21.html#%25_sec_3.2

and

http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-26.html#%25_sec_4.1

If I find some time, I'd like to implement a PMC for such Variable Frames
for Parrot, so lexical scoping will be more optimized and easier to
implement. The way I see it frames should support the following
primitives:

1. Frame_New (parent) - creates a new empty frame whose parent frame is
parent.

3. Frame_Ref - References a frame again.

2. Frame_DeRef - dereferences a frame (possibly recursively)

3. Frame_Define - Defines a new variable in the frame (akin to (define ...
) in Scheme or "my $var = " in Perl)

4. Frame_Set - Sets an already defined variable. (akin to (set! ) in
Scheme or a simple "=" in Perl)

5. Frame_Undef - Perl's undef() operation.

6. Frame_Get - Gets the value of a variable.

This gets a bit messier when we assume that variables can be referenced by
either their names or IDs and that they can store either INTs, strings or
other PMCs. Nevertheless, I'd like to try and write an ad-hoc
implementation for Parrot.

Does this correspond with the general Parrot philosophy? Any
other objections?

Regards,

        Shlomi Fish



-- 


----------------------------------------------------------------------
Shlomi Fish        [EMAIL PROTECTED]
Home Page:         http://t2.technion.ac.il/~shlomif/
Home E-mail:       [EMAIL PROTECTED]

He who re-invents the wheel, understands much better how a wheel works.


Reply via email to