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

Make Ulf Norell's define example work in all backends #363

Closed
5 tasks done
andreasabel opened this issue Apr 28, 2021 · 6 comments
Closed
5 tasks done

Make Ulf Norell's define example work in all backends #363

andreasabel opened this issue Apr 28, 2021 · 6 comments
Assignees
Labels
Agda Issues of the Agda backend bug C++ C define Issue with define pragma Java lists Concerning list categories and separator/terminator/delimiter pragmas OCaml regression in master
Milestone

Comments

@andreasabel
Copy link
Member

andreasabel commented Apr 28, 2021

The original example for define by Ulf Norell is currently only accepted by the Haskell backends.

define if e s = If e s (Block []) ;
define for i c s b = Block [i, While c (Block [b, s])] ;

  • Agda: wrong list constructors
  • C: list constructors rendered wrongly as make_(:) and make_[].
  • CPP: missing sanitization of if and for (keyword clash, regression), wrong list constructors.
  • Ocaml: missing sanitization (regression), list cons (:) (a,b) instead of (a :: b).
  • Java: missing sanitization (regression), complaint that if clashes with If. Works in 2.9.1 with --force.

Missing sanitization is a regression wrt. 2.9.1, introduced by #287.
The list constructors probably never worked.

@andreasabel andreasabel added bug OCaml C++ C Java lists Concerning list categories and separator/terminator/delimiter pragmas Agda Issues of the Agda backend define Issue with define pragma regression in master labels Apr 28, 2021
@andreasabel andreasabel added this to the 2.9.2 milestone Apr 28, 2021
@shlevy
Copy link
Contributor

shlevy commented Apr 30, 2021

@andreasabel We just hit:

C: list constructors rendered wrongly as make_(:) and make_[]

Any pointers to fix?

@andreasabel
Copy link
Member Author

I am now working to extend the expression type by typing information, so that the printers can pick the right list constructors.

andreasabel added a commit that referenced this issue May 18, 2021
Preparing for a refactoring of the TypeChecker to retain more
information about the list constructors.
andreasabel added a commit that referenced this issue May 18, 2021
Preparing for an algebraic type `Label` with `instance IsFun Label`.
andreasabel added a commit that referenced this issue May 18, 2021
Show Cat is retained for Hspec, but not used in the main code base.
andreasabel added a commit that referenced this issue May 18, 2021
Typing information is preserved in Exp and the Define pragma.

Not used yet in the backends.
andreasabel added a commit that referenced this issue May 18, 2021
- NULL instead of make_[]
- make_ListFoo instead of make_(:)
andreasabel added a commit that referenced this issue May 18, 2021
- do not invoke the type checker a second time
- 'cons' needed in AbsynDef.java
- sanitize Java keywords clashing with definitions
andreasabel added a commit that referenced this issue May 18, 2021
List-cons does not need a type parameter.
andreasabel added a commit that referenced this issue May 18, 2021
This test has a non-linear definition:
```
define inc x        = Assign x (EOp (EVar x) Plus (EInt 1)) ;
```
This creates syntax trees that not trees bug DAGs.
```
  make_Assign (x, make_EOp (make_EVar(x), make_Plus(), make_EInt(1)))
```
E.g. here, `x` is shared.  This causes problems for the C deallocater
which assumes that it is dealing with a tree.

This issue is left open for now.
andreasabel added a commit that referenced this issue May 18, 2021
@andreasabel
Copy link
Member Author

andreasabel commented May 18, 2021

Remaining problem (C): non-linear definitions, like:

define inc x = Assign x (EOp (EVar x) Plus (EInt 1)) ;

This creates syntax trees that not trees but DAGs.

  make_Assign (x, make_EOp (make_EVar(x), make_Plus(), make_EInt(1)))

E.g. here, x is shared. This causes problems for the C deallocator which assumes that it is dealing with a tree.

@shlevy
Copy link
Contributor

shlevy commented May 18, 2021

the C deallocator

A bit off topic, but is there a deallocation function provided with the generated files? I haven't seen one, I've just been manually freeing recursively down the generated structs.

@andreasabel
Copy link
Member Author

@shlevy : The deallocation is a new, yet unreleased functionality added in a9d360d (#348).

andreasabel added a commit that referenced this issue May 19, 2021
andreasabel added a commit that referenced this issue Jun 5, 2021
Sharing introduced by definitions would result in a DAG, crashing the
deallocator which assumes it is a tree.
@andreasabel
Copy link
Member Author

Remaining problem (C): non-linear definitions, like:

This has been fixed by introduction of clone_* and the cloning of duplicate components to prevent pointer aliasing and to preserve the tree-property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Agda Issues of the Agda backend bug C++ C define Issue with define pragma Java lists Concerning list categories and separator/terminator/delimiter pragmas OCaml regression in master
Projects
None yet
Development

No branches or pull requests

2 participants