Skip to content

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

Closed

Description

@andreasabel

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.

Activity

  1. added
    lists
    Agda
    define
    on Apr 28, 2021
  2. added this to the 2.9.2 milestone on Apr 28, 2021
  3. shlevy commented on Apr 30, 2021

    @shlevy
    Contributor

    @andreasabel We just hit:

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

    Any pointers to fix?

  4. added 2 commits that reference this issue on May 2, 2021
  5. self-assigned this
    on May 18, 2021
  6. 5 remaining items

  7. added 8 commits that reference this issue on May 18, 2021
  8. andreasabel commented on May 18, 2021

    @andreasabel
    MemberAuthor

    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.

  9. shlevy commented on May 18, 2021

    @shlevy
    Contributor

    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.

  10. andreasabel commented on May 19, 2021

    @andreasabel
    MemberAuthor

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

  11. added a commit that references this issue on May 19, 2021
  12. added a commit that references this issue on Jun 5, 2021
  13. andreasabel commented on Jun 5, 2021

    @andreasabel
    MemberAuthor

    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

Metadata

Metadata

Assignees

Labels

AgdaCC++JavaOCamlbugdefinelistsregression in master

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions