proj-oot-old-150618DataSyntaxNotes

(absorbed into other notes, just keeping this around in case i want to see it again for some reason, although i don't imagine that i would)

another idea for graph constructor syntax: nested dicts:

example_graph = [a=[1=b, 2=c]; b=[n=c, p=__root], c=[m=a]]

example_graph.a.1.n.m == example_graph.a example_graph.a.1.p == example_graph

what if you want to use a variable?

v = example_graph.a example_graph.b.q = v

wait no those should be vars be default; uppercase for keywords; so

v1 = C example_graph = [A=[1=B, 2=v1]; B=[N=C, P=__ROOT]; v1=[M=A]]

example_graph.A.1.N.M == example_graph.A example_graph.A.1.P == example_graph

what if you want to use a variable?

v = example_graph.A example_graph.B.Q = v v2 = A v.1.N.M == v.1.p.v2

instead of keywords and ints, could have used any immutable value type, eg strings

v.__SELF == v e = v.1. e.__SRC == v

hmm that shows that the trailing period isnt so useful because it forces you to end traversal and store in a temporary var (here, e)

or, could use & to refer to an edge, too.. perhaps postfix

v.1&.__SRC == v

hey, that's not so bad!

is v.1&& then the meta edge connecting v.1 and v.1&? or perhaps it's a port. v.1&& is the dst side port, v.&&1 is the src side? but why not just one &? and why not use ..? and what if a path contains multiple clusters of &&&s?

mb the trailing period and the forced use of temporary var isnt so bad. itll keep the program less dense/more readable when ascending to thee meta-level of an edge.

postfix & could be like prefix * in C, eg ptr& is like c's *ptr. so eg (&x)& == x

the constructor syntax above isnt quite right, bc we must distinguish setting the target of an edge to a node by name, vs setting the target to the keyword itself. Mb use prefix . for this; prefix . means "resolve this key in the context of the current graph". so the abovee would become:

v1 = C example_graph = [A=[1=.B, 2=.v1]; B=[N=.C, P=.__ROOT]; v1=[M=.A]]

example_graph.A.1.N.M == example_graph.A example_graph.A.1.P == example_graph

what if you want to use a variable?

v = example_graph.A example_graph.B.Q = v v2 = A v.1.N.M == .v.1.p.v2 #note here that the graph context is implicit; whichever graph 'v' is in

  1. if you gave thee literal .X at the top level, it might be a first-class reference to variable binding for variable x, or label X, or something like that. how is that different from &x, if at all?

i guess variables and labels and functions may as well all be in the same namespace

alternate/complementary/optional notation for graph constructors: give some edges separately, rather than in node lists:

v1 = C example_graph = [A=[1=.B, 2=.v1]; B=[N=.C, P=.__ROOT]; C/.A ]

also mb invert the convention for prefix .; the default is that everything refers to a node name prefix . gives you the literal itself? but only within constructors??

mb dont use uppercase for __language-reserved-identifiers; just lowercase

is having both _ and - in ideentifieeers overkill? should we use _ for something else and use prefix - and -- instead of _ and __?

idiv for integer/truncating division, div for normal division

a-b a valid identifier (is a-- valid tho?) (note: prefix _ denote privatee, __ is language reserved) + addition ++ unary increment (pre)

no need to use (()) for big parens and {} for func scope/hoist scope, just use {} and dont hoist metaprog (or anything else)

if &x is addressof (referenceto) and x& is deref, then maybe 'x is 'enclose in maybe' and x' is 'strip maybe'?

to have an atomic literal in place of a node:

g = [A=[B=.B]; B=3]

or equivalently: g = [A=[B=3]]

now g.A.B == 3

maybe , is pythonic implicit tuple constructor, and ,, is for syntactic separation (autoenclose each side in parens), but within [] , is arrayish implicit constructor ,, is higherdim

eg

a,b = f(x) is [a,b] = f(x) a,,b is (a) (b) [a,b] is [0=a; 1=b] [a,b,,c,d] is [0,0=a, 0,1=b, 1,0=c, 1,1=d] is [[0=0,1=0]=a, [0=0,1=1]=b, [0=1,1=0]=c, [0=1,1=1]=d]

otoh having ,, operate differeently in data context is slightly non-homoiconic, but its just a macro anyway, not part of oot core, so mb we dont care

note: oot core and oot have thee same lexer and parser, but oot has a bunch of macros and metaprogrammed syntax that oot core does not

(why r we using = instead of / to bind? is it because the rhs is either an edgelist (if this name is bound to a multiedge node) or an atomic primitive? if we used / then the rhs would be bound to a node name, not a node constructor literal. but that seems a little redundant with the supposed need to have C/.A in the above example, rather than just C/A)

also, what if the edgelist is given by the value bound to a variable? maybe use the preefix $ (inteerpolation) operator? eg [N=$edgelist]

is prefix . within node constructors related to addressof (prefix &)? b/c these are just like variable bindings in code, homoiconicity and all that, right? interesting.. i think it may be different.. levels? its kinda like antiquote/quasiquote, i guess

if we're locally eager by default, need cheap syntax for suspend / lazy list construction

btw can still use trailing . in numeric literals to indicate a float, if desired. probably too confusin tho (also gets more complicated with units, see below)

note the idea of using node literals as nodenames for multidims

mb _ is leveldown, the inveerse of ^

dont allow users to define new unary punctuation; all usr punc is binary (or, maybe have a special prefix to denotee unaryness? maybe +? so +f is a unary func? and maybe not have -- as decrement; or mb that's special)

--language-reserveds are not keywords in that they are just identifiers, syntactically

the + convention for unary interferes with the idea of +- to denotee uncertainty, but we could just use -+ for that

also could use literals like 1.3.meter for units. but what if x is a variale that we are adding units to? then this doesnt work: x.meter. need syntax for this. or mb not; mb just unit(x, --meter). or mb *u: x *u --meter. hmm thats a bit verbose.

wait what about prohibitng camelcase and making that syntactic? eg:

xUmeter is not an identifier, but rather something involving lexical sugaroperator 'U'? could do our cheap syntactic 'map' and 'fold' sugar in the same way. its like a perl6 metaoperator. in this case tho it just means:

xUmeter == (unit 'meter' x)

or mb even shorter, first lookup in a unit abbreviation table --unitabbrevs:

xUm == (unit (--unitabbrevs 'm') x)

should we let users define these sorts of metaoperators/macros? maybe reserve the single letters and force userdefined ones to be multiletter? also when defining it how to give access to both the strings and the variables? mb use .prefixperiod again? is .prefixperiod just antiquote/quasiquote? does getting the string value makes this a 'reader macro' or does that mean preparsing?

note: i guess .X, meaning the node with name X, and X., meaning the edgee from root to X, might be symmetric in a buildup/builddown way. and this might be related to quasiquoting.

mb antiquote == interpolate? mb quote should be a leading $, and antiquote a trailing $?

also mb a leading ^ is annotate, and a trailing ^ is antiannotate?

mb attached "" is literal quoting of one word, eg ""xyz == "xyz, and xyz"" is "take the value of variable xyz, which should be a string, and substitute the variable that this string is bound to in the current context". eg (a=3; xyz='a'; xyz"" == 3). note this is different from quasiquotee bc xyz holds an actual string, not a preparsed AST (graph/node/sexpr) (is that rly different?). how does this relate to .prefixperiod in data context?

two kinds of 'interpolation' quoting here; postfix $ passes from variable to the value bound to that variable (substitution); postfix "" passes from string to the variable (string->AST). so mb the above example should really be xyz""$ == 3; so xyz"" would not be substituion, but just returning a value which happens to be a node in the environment. So is --ROOT"" the way to refeer to the environment itself? whereas .--ROOT is a reference to thee enclosing block?

so " is ordinary quote; "" is single-word metasyntactic quote; and """ is HERE document ("""x for a different delimiter, then x""" to end)

note: unicode is only allowed within strings, not in identifier names or other syntax! everything else is ascii

mixed case macros must be 'local' in that they only get to lookat/change the stuff that is not separated from them

need to loudly proclaim that _ is not part of identifiers, and that division is div, not /, that spacing matters, that linebreaks matter, that unbalanced parens is no EOL, that everything can be a oneliner, that mixed case is not alloweed/is special. users cannot define custom precedence or parsing. clojuree's concept of everything being an AST before u get it: "One might say the reader has syntax defined in terms of characters, and the Clojure language has syntax defined in terms of symbols, lists, vectors, maps etc. The reader is represented by the function read, which reads the next form (not character) from a stream, and returns the object represented by that form."

teach oot core first, then oot, then metaprogramming

different kinds of macros depending on what compilation stage they interferee with?

[] to entter data context, () to enter code context

so is: like /, / like =, : like ^? or something like that?

still thinking that -- should be comment, and should be a metaprogrammy thing. so no room for -- as unary decrement. mb inc should be +1 anyways, and dec +-1.