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

Support proper mutually-recursive definitions in Crochet #10

Closed
robotlolita opened this issue Aug 5, 2021 · 0 comments · Fixed by #47
Closed

Support proper mutually-recursive definitions in Crochet #10

robotlolita opened this issue Aug 5, 2021 · 0 comments · Fixed by #47
Labels
error Something is confusing, misbehaving, or harmful. s:0 minor It's annoying that this is happening, but we can live with it for now.

Comments

@robotlolita
Copy link
Contributor

Crochet separates declarations from expressions to avoid imposing an evaluation order for declarations (and to allow analysis of shapes without security nightmares). However, as currently implemented, declarations are evaluated in the order they appear. This is particularly problematic for types for two reasons:

  1. It makes it harder to properly organise modules, leading to the current 0-types.crochet pattern; but more importantly
  2. It makes it impossible to declare recursive or mutually recursive types, and that makes field contracts often useless. Though this is mitigated by separating cases in a sum type into independent declarations.

Anyway, this should be fixed in the VM so it can conform to the (not yet described) language spec. The simple solution is to allow referring to non-existing definitions with a placeholder, and then replace the placeholder with the correct implementation once we've seen all of its dependencies. We do, however, expect to be able to know some things about the type in several declarations (e.g.: in order to sort commands), so this change has quite some annoying ripple effects.

@robotlolita robotlolita added the error Something is confusing, misbehaving, or harmful. label Aug 5, 2021
@robotlolita robotlolita added the s:0 minor It's annoying that this is happening, but we can live with it for now. label Oct 3, 2021
@robotlolita robotlolita added this to the First stable release milestone Dec 11, 2021
robotlolita added a commit that referenced this issue Jan 9, 2022
Long overdue. This allows types and traits to be defined in any order **within a package** (circular type dependencies will never be allowed outside of a package because Crochet's capabilities require a proper hierarchy of dependencies), and can finally get rid of the awkward `0-types.crochet` convention. Types and traits can now be defined wherever makes most sense for them to be, and circular constraints now work properly. 

This fixes #10.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error Something is confusing, misbehaving, or harmful. s:0 minor It's annoying that this is happening, but we can live with it for now.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant