Hi everyone, I'm not sure this is the right place but I don't remember a parrot-users mailing list (and at least it's not listed on the parrot website).
Anyway, I'm writing a small article about parrot and I was implementing a tiny language with lexical scope and first class functions. Although I know how to create closures in my language and I can call them ok, I still have a problem: if I use variable lookup to access my functions, it doesn't find the pir-defined routines, while if I use the normal function lookup it does not consider the lexical functions defined as variables. I did solve this once managing scopes explicitly in the grammar (following the Squaak example) and having something like for (scopes() ) if $_.symbol($<name>) call closure found = true if not found call fun $<name> but I don't like this and it still does not allow passing the builtins around (moreover I was happily avoiding the whole manual scope management :). It seems to me there are a few options, * install the symbols explicitly in the top level namespace (should work, but requires duplicated effort when defining a new builtin) * have some trap function in the variable lookup mechanic that fetches the function if all else fails (nice, seems to be python's behaviour, but is it possible?) * register the namespace where functions are defined (package?) as the parent namespace for the top level scope (a PAST::Block/immediate defined in TOP) All of these, though, I have no clue on how to implement :) As this seems a problem common to many lisp-1-ish languages (python, ecmascript, scheme) I guess there is a proper way of doing it but I don't know how to approach it, is there a documented way or an obvious way I'm overlooking? Is this something worth documenting for future implementors? Thanks in advance, and sorry if I ask dumb questions. _______________________________________________ http://lists.parrot.org/mailman/listinfo/parrot-dev
