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

Don't require new in constructor expressions #1141

Closed
degory opened this issue Mar 27, 2024 · 0 comments
Closed

Don't require new in constructor expressions #1141

degory opened this issue Mar 27, 2024 · 0 comments

Comments

@degory
Copy link
Owner

degory commented Mar 27, 2024

Currently, constructor expressions require the new keyword. The main reason for this is that we can't parse generic type expressions in a value expression context, so new is needed to explicitly tell the parser to expect a type expression.

It would be good to support construction without needing new. new is often associated with OOP object construction, but some of the values new constructs in ghūl are not objects (e.g., structs, union variants). While new does highlight that construction is special compared to a regular method call, you could argue that (...) already signals an arbitrary amount of work could happen, including object construction and side effects: new on top of (...) doesn't add any further information.

Once we have a solution for #883 we will be able to recognize constructor expressions without needing them to be preceded by new

To support bootstrapping and until ghul-test and the runtime library are updated to remove use of new, we will need to support constructor expressions with and without new.

let l = Collections.LIST[int]();
degory added a commit that referenced this issue Mar 29, 2024
Enhancements:
- Consistent syntax for explicit generic specializations in expressions (see #883)
- Don't require `new` in constructor expressions (see #1141)
degory added a commit that referenced this issue Mar 29, 2024
Enhancements:
- Consistent syntax for explicit generic specializations in expressions (see #883)
- Don't require `new` in constructor expressions (see #1141)
degory added a commit that referenced this issue Mar 29, 2024
Enhancements:
- Consistent syntax for explicit generic specializations in expressions (see #883)
- Don't require `new` in constructor expressions (see #1141)
degory added a commit that referenced this issue Mar 30, 2024
Enhancements:
- Hint that `new` is deprecated and can be omitted (see  #1141)

Technical:
- Remove use of `new` thoughout compiler and integration tests
@degory degory mentioned this issue Mar 30, 2024
degory added a commit that referenced this issue Mar 30, 2024
Enhancements:
- Hint that `new` is deprecated and can be omitted (see  #1141)

Technical:
- Remove use of `new` thoughout compiler and integration tests
@degory degory closed this as completed Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant