Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Statement vs Expr #51

Closed
jakzale opened this issue Mar 17, 2020 · 1 comment · Fixed by #62
Closed

Fix Statement vs Expr #51

jakzale opened this issue Mar 17, 2020 · 1 comment · Fixed by #62

Comments

@jakzale
Copy link
Collaborator

jakzale commented Mar 17, 2020

In most imperative programming languages statements are the top level forms, with expressions occurring inside statements. At the moment, the language is inside-out, by having statements inside expressions.

We can solve that in two possible ways:

  • make the statements toplevel, with expressions occuring inside them, or
  • forego statements altogether by introducing unit type and treating ; as expression sequencing operator (Add the unit type #44).
@effectfully
Copy link
Owner

forego statements altogether by introducing unit type and treating ; as expression sequencing operator

Quoting another comment (that I just left):

we distinguish between expressions and statements right now (which is something that we have to do, because assertions can only be compiled when they're at the top level, see this comment, so "statements" arise naturally).

I did think about this option of having unit and ; as a sequencing operator, but compiling that is hard and inefficient and it's not clear if this level of generality gives us anything substantial.

We could allow uncompilable syntax trees, but I'd rather clearly express the intentions in the structure of the AST, when possible.

jakzale pushed a commit to jakzale/tiny-lang that referenced this issue May 14, 2020
Fixes effectfully#51, effectfully#52

We make the following changes to the AST by adding
- a newly introduced a top-level `Program` node, which is parent to
- a newly introduced `Statements` node, which is parent to
- a `Statement` node, which is chaned to be a parent of
- an `Expr` node.

In addition we introduce a `EFor` node to the typed AST.

We update update the evaluator by providing an explicit transformer
stack, `EvalT`, and we fix the semantics for for loops.

We also add the following minor improvements
- we fix `Sign` vs `Sig` naming issue,
- clean up some naming conventions,
- provide `stack bench` benchmark for testing generators for the new
  AST.
jakzale pushed a commit to jakzale/tiny-lang that referenced this issue May 15, 2020
Fixes effectfully#51, effectfully#52

We make the following changes to the AST by adding
- a newly introduced a top-level `Program` node, which is parent to
- a newly introduced `Statements` node, which is parent to
- a `Statement` node, which is chaned to be a parent of
- an `Expr` node.

We make the following changes to Statement by
- introduce a `EFor` node to the typed AST.

We update update the evaluator by
- providing an explicit transformer stack (`EvalT`),
- fixing the semantics for for loops, and
- switching to CPS both in evaluator and normaliser.

We also add minor improvements to the codebase by
- fixing `Sign` vs `Sig` naming issue,
- cleaning up some naming conventions, and
- providing `stack bench` benchmark for testing generators for the new
  AST.
effectfully pushed a commit that referenced this issue May 18, 2020
* [AST] fix statement vs expression

Fixes #51, #52

We make the following changes to the AST by adding
- a newly introduced a top-level `Program` node, which is parent to
- a newly introduced `Statements` node, which is parent to
- a `Statement` node, which is chaned to be a parent of
- an `Expr` node.

We make the following changes to Statement by
- introduce a `EFor` node to the typed AST.

We update update the evaluator by
- providing an explicit transformer stack (`EvalT`),
- fixing the semantics for for loops, and
- switching to CPS both in evaluator and normaliser.

We also add minor improvements to the codebase by
- fixing `Sign` vs `Sig` naming issue,
- cleaning up some naming conventions, and
- providing `stack bench` benchmark for testing generators for the new
  AST.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants