dynclasses/dynlexpad.pmc provides (or should eventually provide) a more dynamic lexpad (similar to the deprecated scratchpad.pmc). It's not finished yet, it doesn't consult LexInfo for static lexicals yet.

Before working more on it, I'd like to know from HLL authors, what they need.

Currently it looks like this

SYNOPSIS

  .sub _load :immediate                    # (1)
      $P0 = loadlib 'dynlexpad'
  .end

  .HLL "foo", ""      # or "foo_group" - load dynamic PMCs too
  .HLL_map .LexPad -> .DynLexPad           # (2)

  .sub main :main :lex                     # (3)
       $P0 = new .Integer
       store_lex 0, 'a', $P0               # (4)
       ...
       $P1 = find_lex 'a'                  # no pad_depth (yet)
  .end

DESCRIPTION

(1) The :immediate sub is run before the parsing proceeds, the DynLexPad is already avialable at (2) so that .constant syntax works. (2) installs for the given HLL named "foo" the DynLexPad as the one to be used.
(3) denotes the main sub as needing a lexpad (see also pdd20)
(4) stores the lexical into the DynLexPad hash as a new entry. The 'pad_depth' integer is needed for an initial store_lex, but otherwise ignored, specifically it doesn not allow (yet) a store into an outer lexpad.

See also t/dynclass/dynlexpad.t and dynclasses/dynlexpad.pmc

Comments welcome
leo

Reply via email to