2009-12-28

data.struct's

10.9: adda/type"variant.record:
. variant.record is a set description:
{.(tag)
empty: null
, leaf: (...)
, branch: (tree, tree)
} .
. this set indicates set builder notation:
the tag has no range,
so this is your que that values of the range
are expected to be described in the map that follows .
. when considering lists and sets,
you may want to have rec's be using
the <...> syntax ?
. to guide the use of that syntax,
notice how a function point (,,,)
differs from vector <,,,> .

10.10: adda/type"dict:

. a Python-style dict (dictionary) is a
variable function:
you can build it incrementally by
{adding, removing} points .
. f(x) first looks for (x,y) in f`points;
if no results then it tries eval'ing f`process(x) .
if there is no process, then it returns null .
. what is the type decl of dict?
in the usual function type
you can expect every value in arg`type
to return some value in return`type .

. dict's can be viewed in 2 ways:
either
the return type is {intended type, null},
or [mis?:]
the arg`type's domain is varying
so you have to say return`type.subset .
[10.11:
. there's only one way to view this:
you can define an acceptable type,
or simply accept anything that's type-tagged;
but unlike functions,
they're not designed to guarantee a return . ]

--. diff'ing sub.type vs type.subset ?
a subtype is assignment compatable or
like how int is related to num .
a type.subset means a restriction of the
type's value.set .
todo:
. how did math use terms image, codomain, range? .

10.19: adda/type"array/sortable traversal:
. the array is like a directory listing
-- it is sortable .
how can the syntax show the domain is sorted by
some other way ?

10.22: adda/type"string/literals:
"(..) or for multi line
"(
...
)
. what if the terminator is in the string?
and since your not sure when copying
then need a tool to check for this .
or put string in its own resource file and refer to it by name .
. when labels define members on array
but are passed to generic fun
then need syntax for knowing list is a
literal list vs a label decl'
. decl's ...
[.?] labels decl'd must be typed;
and, untyped [labels] are assumed to be labels known by
[the] var it's being passed to .

10.28: adda/type"string/vs array:
. how string differs from array:
it gets a lot of inserts;
string may be a tree`struct vs contiguous .


10.8: adda/syntax/compound typing:
. order of types on name .ch.st or .st.ch?
it should be like order of function or record:
the obj is 1st a string,
or some compound type (aka container type);
and then a component, eg ch;
but, those are name-related syntax issues;
see it like this:
. if it's first a string,
that should be the outer-most type: x.ch.st .


10.17: adda/syntax/review of datastructure access operators:
. a review of data.structure access operators:
p/.fs -- folder sys
p`= . -- p points to curr'folder
p/`= ./ -- p copies curr'folder
p/f -- returns a file or /.file depending on receiver` type .


10.18: adda/syntax/records:
. syntax for record literal as return type
should work while recursing types;
eg `(a,b,c).(t1, t2) is confused with
() being the start of function.types .
...
. f().() -- ().() is a function type.literal;
r.() -- () is a record type.literal;
`().() -- this also is a record type.literal
for when you want to arrange the description
like an array does:
eg, `(trafficlight).(int,real,string)
is the same as
(red.int, yellow.real, green.string)
. if you said instead
#(trafficlight).(int,real,string)
that would mean
( red.(0.int, 1.real, 2.string)
, yellow.(0.int, 1.real, 2.string)
, green.(0.int, 1.real, 2.string)
) because,
each array domain value is mapped to the entire return
and then, since the components of the return were not named,
the default is like c's -- offsets are used as the name .
... actually,
you would likely never want to say that,
rather, an array returning record
would want to name the record`components:
#(trafficlight).(a.int, b.real, c.string) .


10.20: adda/syntax/structures summarized:
.
a#{enum}.{enum} = ( s:s, ... )
,
f( {enum}).{enum} = { s:s, ... }
,
f().(rec) = { x:(rec), ...}
,
r.(rec) = ( s:y, ... )
.

10.24: adda/syntax/type"string:
. can syntax show insert vs overwrite?
overwrite addressing a range:
a#{i...}`= b -- overwrite range having size same as source
a#{i...}`= b#{j...} -- overwrite with b#{j...last}
a#{i}`= b -- insert source so it starts at destination index .
a`= b -- overwrite all .
. the symbols {first, last} are reserved for ranges .
. the slice having no specific last item,
depends on where it is:
in the array being read, it means last;
in the array being written to, it means
whatever length is needed to accommodate
what's being assigned .
. can syntax show index vs offset?
the array`domain can be any scalar or symbol set,
so letting it start at zero
gives it the same affect as an offset .

10.27: adda/syntax/slices:
. array slice is confusable with array declaration ?
any slice could be a subset of the declared domain-space .
. if worried that a name mis.spelling could cause a double decl',
then check for similar names in the generated act'rec decl'summary .

12.19: adda/syntax/unifying record and package:

. to merge the idea of record and package,
every record has an implicit field "(body),
which represents an init process .
. it may also contain hidden var's,
so that it works like a package or type'mgt does .
. without the body,
records have {ini,fini} handlers that are simply
the sum of those of their component fields .

. if a record needs dyna'mem,
it gets it from the nearest subheap;
eg, act'rec's have the usual subheap,
and array's of records can have their own subheaps .

. in use:
r.( a.N, x.N)`= (0,0); r`body`= (...);
or equivently:
r.( a.N`= 0, x.N`= 0, body`= (...) );

. notice this makes the assumption that
body is semi-reserved,
in that having a field named "(body)
precludes being able to define a body as defined by the system .

12.20:
. a record impl'd to include private var's
will need just one link to the subheap or dope.space .
. think of body.field as a module plug .

12.19: adda/syntax/confusion:

. review 12.19/adda/syntax/unifying record and package:
. in use:
r.( a.N, x.N)`= (0,0); r`body`= (...);
or equivently:
r.( a.N`= 0, x.N`= 0, body`= (...) );

. that example shows a possible confusion about
colon as a map.operator:
if param' record instantiation uses the colon,
why can't a rec'declaration do the same?
by the rules of locals, it could,
but by using the colon, it's declaring a constant;
. another confusion is forgetting that the dot is the decl'mark;
is the body pre-declared in this case?
if it's really acting as a sub.record,
it should be dotted:
r.( a.N`= 0, b.N`= 0, body.(...) );
. if the body gets to keep its locals private,
shouldn't it be able to have its definition delayed?
yes, but in other cases,
how do I declare a sub.rec' as defined separately?
. the way ada does this (using adda's syntax) is:
rec.type;
r.( ..., sub.rec);
sub`= (,,,);
. notice how it matters whether using the {colon, dot} on sub.rec's:
( sub: (,,,) ) -- constant record;
but, does it still have a meaning if the record is not init'd?
. I now vaguely recall a similar discussion
resulting in the rule that label's must be typed,
but would that make a diff' here ?

No comments:

Post a Comment