Open cgrand opened 4 years ago
I'm considering switching the whole surface syntax to expressions.
It means no and
, or
or not
as we know them.
I'm looking at a special form taking a "binding" vector and then a single expression. Current candidate is such
as it doesn't come loaded with preconceptions.
(ez/such [expr0 expr1
...,
expr2n expr2n+1]
expr-body)
Ok let's try to list some ops:
(or a b)
its return attribute is the union of a and b return attributes(and a b)
expands to (such [true a] b)
(do a b)
expands to (such [_ a] b)
(if test a b)
expands to (or (such [true test] a) (such [false test] b))
(if-such [...] a b)
expands to (or (such [...] a) (and (no (such [...] true)) b))
(case a v1 b1 v2 b2)
(or (such [v1 a] b1) (such [v2 a] b2))
It seems like or
, such
and no
could be the three ops to which expressions should expand.
Then these expanded expressions can be converted to statements.
A relational expression is an expression. I use the word expression in contrast to statement (see https://en.wikipedia.org/wiki/Expression_(computer_science) for example). Expressions nest, statements don't.
In typical datalog, clauses don't nest. To me it's a loss in expressivity because it means that you must name a lot more of variables.
In Datalog a predicate has no direction: it has no output or input attributes, all attributes are full duplex so to say. However while a predicate may not technically have a direction, it generally has a semantical one: that's why by default the last argument is considered to be the return attribute.