"Jonathan Sillito" <[EMAIL PROTECTED]> writes: > It would be nice if parrot provided the lexical scope semantics scheme (and > other languages) needs rather than have each language implement their own. I > guess this would be Dan's call, but just as another suggestion, could the > lexical ops be limited to something like the following, plus keyed access to > the pad? > > new Px, .ScratchPad > push_pad Px > peek_pad Px > pop_pad Px > > (The find_lex and store_lex ops would be unnecessary, but could be kept of > course)
Yes these would definitly be enough. In principle this is exactly what is my P31-hack does; the only difference is that the lexicals are saved on their own stack instead of the user stack. But this is definitly a good thing. Maybe one more: clone_pad Px The semantics would be: peek_pad Py clone Px, Py This is a quite common operation, and the intermediate Py-register would not be necessary. But I will not push this very strong. > > And there is a diffrence between define and set!, define creates a new > > binding in the top lexical scope, ignoring every previous definition, > > but set! changes the binding of a formerly defined variable. This 2 > > diffrent operations don't map very well on the store_lex_s_p > > operation. I used the diffrent keyed access methods of Seans > > Scratchpad.pmc for differentating this use cases: > > define : P31[-1;S0] > > set! : P31[S0] > > > > Assuming Sean's patch (not my above suggestioned ops), would this implement > the correct semantics for scheme's (define a ...): > > new_pad 1 > new P0, .SchemeUndef > store_lex 1, "a", P0 > # ... > pop_pad > > and could (set! a 12) inside of the above define be: > > new P0, .SchemeInteger > store_lex "a", P0 # looks back through nested pads Somehow it looks if these find_lex/store_lex operations are just a mapping of the Scratchpad vtable to bytecode with the implicit first argument current_pad. find_lex P0, S0 => set P0, P31[S0] store_lex I0, S0, P0 => set P31[I0;S0] new_pad => save P31 || new P31, .Scratchpad new P31, .Scratchpad push_pad P31 (Again this P31 crap, bad boemmels :-)) Some commonly used operations might be nice, but there needn't be the complete vtable. bye b. -- Juergen Boemmels [EMAIL PROTECTED] Fachbereich Physik Tel: ++49-(0)631-205-2817 Universitaet Kaiserslautern Fax: ++49-(0)631-205-3906 PGP Key fingerprint = 9F 56 54 3D 45 C1 32 6F 23 F6 C7 2F 85 93 DD 47