2012-03-31

component selector syntax

adda/syntax/component selector:

3.2: colon:
. the colon is part of the internet syntax;
if it were used for components,
then dots would mean only typedef syntax,
there's already a precedent for being picky about spaces .
x: y is the label,
x:y is the component selector .
. the way internet uses dot notation is the selection of names not components .
. people who know mac paths will be familiar with x:y .

3.3: colon and comma are out:
. the most popular english meaning of (:)
is for labelling {is a, is naming};
so, if using it like mac did, for component selection,
then it has 2 fundamentally different meanings,
which would be confusing .
. also, so what it's like the internet use?
no popular urls use the colon specifier .
. what about the comma?
there's already a precident of the comma in numbers separation;
yes, but it's insignificant being optional,
it's like the apostrophe,
to be left as an english style of variant spelling .

3.3: backslash:
. another symbol with a meaning similar to (/) is (\);
because, that is microsoft's folder divider,
so it is being seen popularly as either nothing
or as a component selector .
. here's a memory aid:
(a\c) : look down for built-in components,
(a/c) : look up and outward by pointer for modular component .
. but consider how often components are used,
and how much easier (.) is to find on the keyboard than (\).

3.3: apostrophe is out:
. the apostrophe might be easily remembered as
doubling as english's possessive mark;
ie, components belong to the aggregate,
hence, (aggregate'component) would read as
aggregate's component .
. but the overriding reason for that understanding
is that apostrophe means a placeholder,
indicating that part of the name's spelling is missing
(ie, aggregate's = aggregate has).
. that's why (`), rather than the apostrophe,
is used for oop's possessive mark:
the apostrophe is part of many english spelling,
so we should use something other than the apostrophe
to represent our possessive operator;
the backquote (`) was chosen because
it looks like apostrophe ('),
which is  often representing possession .

3.3: backquote is out:
. the reason for not using (`) for components
is that oop's possessive has different semantics:
. say (.) is the component selector,
then x.f() means x is a record containing a function;
whereas, x`f() means that if x is a variable of type T,
then T has a function f that has an implicit inout parameter;
so, x`f() is similar to f(inout x) .

3.3: applies to activation records:
. how is the nested subroutine like a component?
save the (\)-syntax for that if they differ .
. the function body is like a record
because its local var's are its components .
records are like Ada packages,
in that their components can be functions,
and within the record's body
we put the bodies of its function,
along with any local var's that will be global to them,
but inaccessable by the user of the record .
. a function's signature and body defines an
activation record (after elaborating params and locals).
. an assignment can replace
the initial value of a function's component,
so there are reasons to have this syntax .
. so we have: f.component,
vs a call to f (f arg)
vs (f), the unbound or unactivated function .
. the syntax ( x. ) should be reserved for
defining the any-type local, often used in generators,
and duck typing .