Perl 6
SMOP Lexical Scope Implementation: Revision 7

One first hard step in implementing lexical scopes is to put together a lot of details that are spread over the specs. In this page we're going to sketch a model for the lexical scopes that support all the documented Perl 6 features.

Variable Lookup

The local variable lookup happens in the following order:

  1. MY
  2. OUTER recursive

Special cases

$_

$_ is always locally defined in any block. Routines start with an empty $_, other Code objects have a signature of:

 -> $_ is rw = OUTER::<$_>

$! and $/

These variables are compile-time aliases to $+! and $+/

Modelling

Data Structure

class LexicalScope {
  has %!entries handles postcircumfix:<{}>;
  has LexicalScope $.outer is rw;
}

Accessing the Lexical Scope

The lexical scope is an attribute of the continuation, meaning that the "current continuation" points to the "current lexical scope". The Perl 6 specs doesn't specify a macro that return the current continuation, so we have one of the SMOP Specific Macros ___CURRENT_CONTINUATION___. This should provide access to the following API:

class Continuation {
  has LexicalScope $.lexpad is rw;
  has Continuation $.caller is rw;
}

Upload Files

Click "Browse" to find the file you want to upload. When you click "Upload file" your file will be uploaded and added to the list of attachments for this page.

Maximum file size: 50MB

 
 
 
File Name Author Date Uploaded Size

Save Page As

Enter a meaningful and distinctive title for your page.

Page Title:

Tip: You'll be able to find this page later by using the title you choose.

Page Already Exists

There is already a page named XXX. Would you like to:

Save with a different name:

Save the page with the name "XXX"

Append your text to the bottom of the existing page named: "XXX"

Upload Files

Click "Browse" to find the file you want to upload. When you click "Add file" this file will be added to the list of attachments for this page, and uploaded when you save the page.

 
 
 
Add Tags

Enter a tag and click "Add tag". The tag will be saved when you save the page.

Tag: 

Suggestions: