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

Representing built-in types in the AST (Symbol and Ref) #904

Open
elegios opened this issue Feb 17, 2025 · 0 comments
Open

Representing built-in types in the AST (Symbol and Ref) #904

elegios opened this issue Feb 17, 2025 · 0 comments

Comments

@elegios
Copy link
Contributor

elegios commented Feb 17, 2025

Most of our built-in types have their own AST node (e.g., TyInt, TyFloat, and TySeq) but some are represented by TyCons (at least Symbol and Ref). Before #902 these were distinguished by being left unsymbolized, after #902 they're distinguished by having particular globally set Names. This seems inconsistent.

There are a few ways to approach this:

  • Give Symbol and Ref their own AST-nodes.
  • Represent all built-in types with globally reserved Names. A minor variation of this would be to only do this for atomic types (TyInt, TyFloat, etc.) and not composite ones (TySeq).
  • Make Symbol and Ref externals, not built-ins. These types have relatively little need for special casing in the compiler, and what need there is should be doable anyway (e.g., via something like _getTyConExn added in Loader, generate-json-serializer, generate-pprint, generate-eq, and generate-utest #901).

There is also an orthogonal, but related concern: Int, Float, etc., are reserved keywords in the parser today. This could be changed, make it so that Int, Float, etc., are type aliases in scope when the program starts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant