Is now a good time to start a discussion on lexical scopes? Is anyone
currently working on an implementation of scratchpads? I have sketched
out a simple implementation, based on the struct at the end of this
email, but there are somethings that I do not understand, so I am hoping
someone can set me straight. Here are my two main questions:

1) How should a scratchpad be created. The only documentation I found
was in docs/parrot_assembly.pod:

"Pad descriptors are templates for a particular pad. They are specified
in the constant area of a bytecode file, and contain the names, types,
and attributes for the variables referenced in the scope the pad is for.
[...]
newpad pad_descriptor
   Create a new scratchpad using pad_descriptor as a template."

Has anyone worked out how pad descriptors will look and be handled by
the assembler, passed to constructor, etc?

2) How are values stored in scratchpads? Will scratchpads only contain
pointers?

/* Scratchpad, for implementing lexically scoped variables. */
typedef struct Scratchpad {
    /* sub class of buffer (?) */
    Buffer buffer;

    /* pad for enclosing lexical scope */
    struct Scratchpad *parent;

    /* for (slow) by name access, this could be a string
       to int hash instead */
    struct parrot_string_t * names;

    /* for (faster) by index access */
    PMC * data;

    /* subtracted from indexes before accessing data,
       calculated from the parent's offset and size
       (an index less than this offset, should refer to
       a variable in an enclosing scope) */
    INTVAL offset;

    /* number of pointers in data */              
    INTVAL size;
} * scratchpad_t;


Thanks, for any help/feedback!
--
Jonathan Sillito

Reply via email to