Open Kixiron opened 3 years ago
Some suggestions.
let x = 5
or do we allow mutable variables and function arguments (let mut x = 0; x = 5
)?bit<5>
) and bigint
's. They are non-standard, complicate the compiler and haven't proved very useful in practice. I think we can achieve most of the benefits using libraries, while simplifying the compiler, and unifying our type system with Rust.bigint is useful. But it could be a library - although you lose the literals.
Yah, I totally agree with those sentiments. Purity is a tricky question, it's a tradeoff between user control and compiler freedom. However, since we have the ability to drop into writing and using Rust code within ddlog, I think that making the surface language pure can sidestep that particular drawback
I have no problems with mutable variables in imperative code. It should be clear that you cannot mutate any value that is in a relation, though.
I have no problems with mutable variables in imperative code. It should be clear that you cannot mutate any value that is in a relation, though.
There will no longer be any distinction between imperative and relational code at the language level. Relation<>
is just a type like any other. However, since there is no API to get a mutable reference to a record in a relation, its contents is immutable.
I thought you gave up on embedding the language in Rust or something else. So then we still have these two clear layers imperative/relational. Except some functions can compute on relations. Then there is no "main", and you still want input and output relations. That is also more modular - you cannot just add arguments to an existing function.
Yah, I totally agree with those sentiments. Purity is a tricky question, it's a tradeoff between user control and compiler freedom. However, since we have the ability to drop into writing and using Rust code within ddlog, I think that making the surface language pure can sidestep that particular drawback
You can always convert mutable variables to single static assignment form.
I guess if we want to allow loops, then we want mutable variables. Loops are not very useful if you cannot modify variables in the body of the loop :)
Variables are not as interesting as containers. Do you want mutable vectors and maps?
Variables are not as interesting as containers. Do you want mutable vectors and maps?
That's a library design question. Assuming we have mutable arguments, you can define methods that mutate the container. You can also have immutable containers, where mutator methods return a new container.
I thought you gave up on embedding the language in Rust or something else.
We're not embedding in an existing language, but are designing our own functional language. Relations are first-class objects that can be passed to functions and back. All relational operators are just methods (#2); Datalog-style rules will be implemented as syntactic sugar on top of this language.
At least this is the current proposal.
Not sure exactly what main
looks like in this world.
Upd: but I still like the idea that input and output relations are just inputs and outputs of a function.
Opened #4
The syntax is described in an EBNF flavor loosely based off of W3C's EBNF
Note: As of now this grammar is not complete or final, it's just what I've implemented. A lot of the constraints are much loser than they seem like they should be, that's just because of the error recovery I've implemented in the parser, things accepted within parsing are not always valid and errors are emitted