Showing posts with label etree. Show all posts
Showing posts with label etree. Show all posts

2011-07-30

symbol table linking

7.14: 7.15: adda/symbol table linking:

. etrees (expression trees)
are tree nodes with pointers into
global and local dictionaries of symbols
(symbol tables).
. every etree module
implies access to a global symbol table,
and must specify any needed local symbol tables .
. there can be more than one local symbol table;
because, a dictionary can include procedures;
and, procedure definitions can have
local dictionaries:
the parent procedure becomes the
scope of its local dictionary,
hence the term "(nested scopes),
involving stacks of local symbol tables .
. each module has a tree of symbol tables .
. a typical scope path is:
module/subprog/nested sub/nested block/nested block .

. the 3 main uses of "(library) include
system, standard, and custom .
. the system library of an addx installation
is a service for organizing and linking
the modules that are available for reuse .
. a standard library is a module that is
declared by the system's language .
. a custom library is one added by the user .
. each module has a list of imported modules,
and a tree of symbol tables
to match its tree of nested scopes .

. when designing the pointer that is
going from etree nodes into symbol tables,
there must be an efficient coding,
and it should support efficient copying
even when it involves context changes
(re: adde/object copy & paste).

etree node variants for library symbols:
. there is first a bit to distinguish
symbol location type in {library, local}:
# library location:
. there may be many libraries in use (15-bit),
and many symbols per library (16-bit) .
# local location:
. there's often no more than
4 nested levels of locals (2bit);
and often less than 256 symbols per local (8bit).
but if node`size is in increments of 16bit chunks
that division could be 4 bits for 16 nested scopes,
and an 11-bit space for locals,
or less if the descriminant is more than 1 bit .
[7.30:
... in any case, the more space you save,
the less efficient it is to remap etree nodes
to a new symbol table after a context change .]

details of library location:
. there could be an infinity of libraries over time,
so the library codes in an etree node
don't represent specific libraries,
rather they represent a slot in the module's
list of imported or required libraries;
however, standard libraries can be specified,
since there are a finite number of them;
ie, if the code is in the range that is
reserved for standard lib's,
then that is the same code used by
the system library;
otherwise, we need to use the module's import list
to convert the symbol table's code
into one that the system library recognizes .

. the system library creates a custom lib's code
by taking a Secure Hash of its interface
. as long as that didn't change,
it would be considered the same library . 

object copy & paste

7.14: adde/object copy & paste:

. the typical copy & paste
is a char-string operation;
whereas, an object selection
is operating over etrees (expression trees)
which are tree nodes with pointers into
dictionaries of symbols (symbol tables).
. there can be more than one symbol table;
because, a dictionary can include procedures,
and procedure definitions can have local dictionaries;
hence, a single etree can be within
the scope of multiple dictionaries
represented by stacks of local symbol tables .

. a copy becomes a module
meaning it needs its own copy of
any local symbol tables;
however, the cost of copying
depends on the destination:
if the paste location is within the source's scope
it shares all the same symbol tables .
. when some symbol tables are
not shared between source and destination
those tables must be copied;
and, affected etree nodes adjusted
to point into the new tables .

. when an arbitrary substring is selected
it can be representing fractions of etrees,
eg, given a+b+c, a selection can include
all of term-b and partials of terms {a,c} .

. there may be parts of the given language where
partial terms don't have the same meaning;
ie, there would be nothing but a
char-string translation of the object selection .
. in any case,
the quickest, most general way to define a selection
is to get links to the entire chain of symbol tables;
and, copy the entire subtree that contains
all the fragments of the selection;
then include a descriptor that shows
where the selection is beginning and ending .

. when would you want fragments and still want
the etree object rather than a char string?
for orthogonality,
we have to provide for the possibility
that one of adde's plug-in app's
can find some use for such a selection;
ie, in many cases of user interaction
the selection is for a function other than
cut or copy .

7.15:
. when designing the pointer that is
going from etree nodes into symbol tables,
there must be an efficient coding,
and it should support efficient copying
even when it involves context changes .

. both the source and destination of a copy
have scope paths:
if the scope paths aren't the same
we have to identify any scopes not shared
and copy their symbol tables
for merging with the destination .
if this is a cut instead of a copy,
there are fewer choices,
since the destination space is smaller .

. a complication of multiple nestings of scope
is the orphaned symbol from ancestor scopes:
these imply some sort of communication with
a context which no longer exists .
. we have to remind the user
that the orphan's place in the destination
may need special attention:
should it be added to the new parent scope,
or some higher scope ?
. the default location would be relative height,
ie, the same number of scopes up the path
as it was in the source location .
. in any case, we have to assist the user
in keeping track of these orphan relocations,
and make sure that all affected contexts
are adjusted to create a sensible communication
such that, the role of the source ancestor
is now provided by the new context's procedure .

2009-07-06

control string replacement

6.2:
. notice tcl/tk and c are often passing strings to indicate code;
eg, f'open(name, "(r+, access=lock))
. these control strings are really lists of symbols not characters
so, instead of passing a char.string,
it should be a symbol atom "(r+),
or symbol list "(, ,,,) .

6.4:

. control strings entail a sublanguage, whereby
the server is parsing the string according to rules
shared between client and server .
. control strings may be given either as literals at compile.time,
or as char.string operations stored in char.string variables .
. a literal has 2 levels: a char.string is parsed into an etree
eg,
""( a char.string ) -- here is a string of char's starting with a space;
"( an etree ) -- here is an etree with 2 symbols .

. the use of char.string to convey parameters is not consistent with
the goal of having one universal language .
. it does not reuse available language parsers and debuggers;
and is therefore not as modular as possible .

. a server's definition of a control string
is similar to declaring parameter names:
it's declaring symbols that have a meaning specific to
the parameter record being applied during a call to the server .

. just as there is a way to declare formal param's,
the language needs a way to declare the allowed sublanguage
that will be assigned to the control.string parameter .
. the control.string's type is like a union:
it describes the varieties of etree that it's permitted to have .
. when etree is assigned to it, the compiler is called to check compatability;
. when char.string is assigned, it's parsed into etree and checked .
. that means when a control.string is being constructed dynamically,
the system designer doesn't have to consider how one is
constructing etrees rather than strings;
parsing is done generically, encoded to the widest possible dictionary
until it's been assigned to an environ such as a namespace or a control.string .