adda 2006.11.12



operator"(=): optional possession syntax for assignment


. adda`s use of operator"(=) resolves the issue of
being able to use (=) as both a boolean and also an assignment
-- just as lang"basic and math does --
while at the same time allowing (=) to mean assignment
-- just as langs"{c, fortran} have done --

the conventions relating to this are:
(1)
. control structures have parameters of only 2 types: { tall, bool }
(lang's that don't have a tall (to any) type will use { null, bool })
. the bool parameters must be passed a bool or truth-functional expression;
but the null param's can be passed anything, as an return values are ignored
while the tall param's can be passed only what is type-compatable with
what has
eg,
sequence = ( tall, tall, ... tall )
selection = ( bool ? tall )
iteration = ( bool ?? tall )
concurrency = ( !! tall  )

. if (=) is passed to a bool-type control param
then it's expected to be a bool
else if sent to a tall-type control param,
then it's interpreted as assignment;
. this convention can be generalized as
the type of an overloaded operator (a homonym) is determined by the destination`s type:
it's always considered an assignment unless the destination is a bool
(2)
. only related ideas should be homonyms,
and american english tends to use the apostrophe for 3 totally unrelated activities:
{ word contraction,  quotation, showing possessiveness }
hence, adda should use some other symbol for showing possessiveness
the spacing grave sign"(`) -- unicode.hex"0060 -- has chosen for this
since it has little use in american english,
and is similar in appearance to the apostrophe it is replacing .
 . in english the two marks, possessive and apostrophe,
are identical since the possessive"( foo`s bar )
was originally intended only as an abbreviation for
"( foo, his bar) -- the "(his) contracted to ( 's)

. what about "(her)? how did it contract to ('s)?
. that was back in the dark, romantic ages,
when she didn't possess anything
except his heart .

. however, generally if two operations are not related,
it's less confusing if their operators are not identical,
hence in artificial languages there would be no reason
to follow english convention in this case,
although generally, the aim is to make new syntax
so that it takes on the conventions of the home language
. furthermore, since a good syntax can be easily adapted
to take on the favorite conventions of any other language
the choice of it`s default lexicon is not so significant .
(3)
. a convention of math is that
nested subexpressions can return the return value of
the root, or final operation of the subexpression;
a generalization of this convention is that
a sequence should be considered subexpression,
and it`s last step should be considered it`s root operation,
hence the sequence should return the value returned by the last step;
thus,
if the sequence literal is passed to a boolean,
or if it's the last step in a boolean function
then an "(=) in the last step then it's a boolean,
. if the function didn't declare it`s type
(it's required only to declare the function`s syntax)
then a final step of "(=) is assumed to be an assignment


. to override the interpretation of bool,
the left operand would claim possession of the operator: (x`=y)
or a type would claim possession: (x tall`= y)
. in a control structure, the exit and return commands
are equivalent to a final step
regardless of where in the sequence they are located
since these commands have the same return-type as
 the structure they are exiting from

 if "(exit) is within a function, but outside a loop,
then it's equivalent to "(return);
conversely, "(return) is equivalent to "(<function>`exit)
--. there is also a co`exit which implements cooperative multitasking


. if there are 3 or more operands applied to an assignment
and also being passed to a boolean,
then all (=)'s must be possessed:
eg, a` = b` = c
. this way it's possible to say
((a  =  b` = c) ? s)
and have it mean:  ((a  bool`=  (b tall`= c)) ? s)


container generators


6.11.12:

. modeled after the understanding that <num><obj>
gives the number of objects,
adda could allow <num><enclosure> to be a generator

. the obvious contention is that it complicates the following
system:
{ <unary prefix operator><term> = f(x)
, <term> = (<term>)
};
 ie, now I can no longer say that it's generally true
that anywhere I had a parenthetical,
I could replace that with a symbol,
because with a symbol

. this is interesting in that it shows the similarities between
functions: <name><term>
and quantifications: <num><term>
because in the case of the function,
<name><term> is actually refering to <set><selector>
where there is a set of mappings from input to output,
that is made unique by selecting an input;

while quantification involves a set of ideas
that is made unique by selecting an object`type;
ie,
a number is shorthand for the set" { a number of <whatever> }
and then the term that follows is identifying <whatever>
as being a selected obj`type .

. there would now need to be
some other way to express a function call that returns
a function for yet another function call;
eg, f(x)(y)
had been thought of as saying f(x)(y) => ( f(x) )(y) => (g)(y) => g(y)

. this is a trivial problem however,
since that has never been a well-known syntax anyway;
I had adopted it simply because it was a
generalization of well-known syntax;
but the lisp way, brought to us by that
community of programmers most likely to use such an expression,
has done it with the function word"apply;
eg, f(x) apply (y) .

. now the only way a reader could become confused is not knowing
whether a name is a function (so that f(x) is selecting a single)
or the name is actually a generator
( so that f(x) is expanding x into a list or set )

. a generator can be either a number
(ie, any expression that returns a number)
or a record declaration,
which is characterized for the purposes of this context
as declaring some dummy variables that range over specified values,
which is exactly what formal parameters do in a procedure declaration
since the procedure is using the parameter to indicate
a number of routines or mappings, depending on inputs selected,
or the objects chosen to be operated on .


. thus we have:

proc`decl = "( <record> { <code> } )
for-loop = <record> ( <code> )
for-tasking = <record> { <code> } .



2006.{10.14: 11.12}

. what about the similarity between generators and parameters?
. don't we want to merge these ideas,
so that a proc is really a set of proc's when parameterized?

. besides the quantification model,
another reason for not following the generator syntax provided by math or lang"python
--  { x | set }, { x: set }, { x for set } --
is that by not placing the quantification control first,
you'd have to scroll down the page just to see the parameters of a  large piece of code

. since a function is a set of tuples,
it can be defined with a set generator:
f `body = "(x: int = <default>){ code(x) }
--. the default argument is a programming convention,
meaning that if you don't specify that parameter,
it's assumed to be defined anyway with <default>

. you can tell when a for-loop is not modifying it`s control variable,
because it will define itself as a
generated sequence:
    (x: 1..10) ( print x ) --. prints ( 1 2 3 .... 10) .

. a problem still unresolved is that various powers
may need diff'nt operators:
f(3)(x) is a power-apply:  f f f (x),
x(y) is well-known as the power-multipier,
however, when rephrased as prefix operator on a list,
the power-mult is really a mult on a list generator:
*(x#1, x#2, ... x#y) --. this is the power expansion
hence it is power-expanding the arg list rather than the operator list;

a 3rd alternative is that you could power-expand the apply operation,
which is essentially what a for-loop does
when it's defined as a control list of a funtion application:
n(f(x))
ie, you can put the power param's anywhere that's convenient,
since they're distinguishable by the power mark
and for consistency,
the param-first approach is identifying the structure being expanded:
loop(arg)(code step or coprocess),
proc(arg)(code variant)
--. what it's empowering here is an object class ( objects classes include loops, proc's, etc)
but it need not be explicitely connected that way:
 ( (arg)( code) ) by itself is also fine,
since the (^) or superscripting is distinguishing things

. a 3rd variant of the power syntax is for the binary operator,
like so:( x * (y) )
then it's still similar to an arg list expansion  
eg, ( x * (3) ) = (x*(x*(x*1)))
. likewise, a power divide is really just a power-mult by 1/x:
( x / (3) ) =  (1/x, (1/x)2, (1/x)3, ...) = (1/ x)*(y)
and a power subtraction is the negative of a power add:
-( x+(3)) = -(x+(x+(x+0))) =  -x*3



. the inclusion symbol is not used consistently as a container generator in set theory,
but in the subject of calculus,
it's consistently used as a range constraint,
which comes from the fact that the formula"(y - x)
will give you the length between these 2 points
so it's a way if representing all space between two points
. the one example I can recall vividly,
is the definite integral,
which expresses a function -- a set of points --
and then uses a bar to express a range of the arg
on which the integral is to be applied
. the purpose of the integral function can easily be seen graphically:
if you hve a function"f,
and you know it`s integral function"F,
then you can find the area bounded by:
under the graph f(x#0...x#1),
but above y=0
simply by subtracting F(x#1)- F(x#0)
(although things aren't that easy in every case)

. after converting math`s graphical style of expression to plain text,
it looks pretty much like this:
area( 0...f(x) * x0...x1 ) =
     ( sum f(x) | x0...x1 )
which is really a procedure with 4 args:
    sum( formula, the variable to integrate, begin-point, end-point)
and a procedure is really a power-expansion of code variants,
where the parameters are the dimensions of variation:
    "( f, x, x0, x1 ){ <sum`method> }
or
code( f, x, x0, x1 ){ <sum`method> }