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

Syntax for readonly and T #476

Closed
jclark opened this issue Apr 5, 2020 · 4 comments
Closed

Syntax for readonly and T #476

jclark opened this issue Apr 5, 2020 · 4 comments
Assignees
Labels
enhancement Enhancement to language design implementation/done Implementation Done lang Relates to the Ballerina language specification

Comments

@jclark
Copy link
Collaborator

jclark commented Apr 5, 2020

We need to a syntax to specify that something is readonly and belongs to type T.

The immutability proposal uses readonly<T>.

Another approach is to add intersection types using & as the intersection operator, so you would say readonly & T.

This is part of #189.

@jclark jclark added enhancement Enhancement to language design lang Relates to the Ballerina language specification labels Apr 5, 2020
@jclark jclark added this to the 2020R2 milestone Apr 5, 2020
@jclark jclark self-assigned this Apr 5, 2020
@jclark
Copy link
Collaborator Author

jclark commented Apr 5, 2020

A couple of questions to consider:

  • are there existing features that could be expressed with intersection?
  • how does this interact with the *T; feature of records and objects?

@jclark
Copy link
Collaborator Author

jclark commented Apr 7, 2020

Current consensus is to use T & readonly.

@jclark
Copy link
Collaborator Author

jclark commented Apr 13, 2020

I think it might be possible to express lax static typing in terms of intersection. See #488.

@jclark jclark modified the milestones: 2020R3, 2020R2 Apr 24, 2020
@hasithaa hasithaa added the implementation/inprogress Implementation inprogress label Apr 27, 2020
@jclark jclark added the status/inprogress Fixes are in the process of being added label May 1, 2020
jclark added a commit that referenced this issue May 1, 2020
jclark added a commit that referenced this issue May 1, 2020
jclark added a commit that referenced this issue May 1, 2020
@jclark
Copy link
Collaborator Author

jclark commented May 1, 2020

This is now done.

@hasithaa hasithaa removed the implementation/inprogress Implementation inprogress label Jun 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement to language design implementation/done Implementation Done lang Relates to the Ballerina language specification
Projects
None yet
Development

No branches or pull requests

2 participants