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

Allow record fields to be readonly #464

Closed
jclark opened this issue Mar 25, 2020 · 4 comments
Closed

Allow record fields to be readonly #464

jclark opened this issue Mar 25, 2020 · 4 comments
Assignees
Labels
enhancement Enhancement to language design implementation/done Implementation Done lang Relates to the Ballerina language specification status/inprogress Fixes are in the process of being added

Comments

@jclark
Copy link
Collaborator

jclark commented Mar 25, 2020

See this section of immutable proposal.

This is enough of #189 to be able to do tables #47.

Readonly fields cannot be assigned to after construction.

In this stage the type of a readonly field is restricted to be readonly as in issue #462 i.e. belong to inherently immutable basic type.

Also should allow a mapping constructor to specify readonly before the field name.

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

jclark commented Mar 26, 2020

This is a little bit harder than it looks because the readonly-ness has to be part of the value (so it can be part of the shape).

@jclark jclark added the status/inprogress Fixes are in the process of being added label Mar 29, 2020
jclark added a commit that referenced this issue Mar 29, 2020
jclark added a commit that referenced this issue Mar 29, 2020
@jclark
Copy link
Collaborator Author

jclark commented Mar 30, 2020

Still need explanation of semantics of readonly in record type descriptor and mapping constructor.

jclark added a commit that referenced this issue Mar 31, 2020
jclark added a commit that referenced this issue Apr 1, 2020
@jclark
Copy link
Collaborator Author

jclark commented Apr 1, 2020

Should infer precise rather than broad-type for field when it is read-only.

@jclark jclark modified the milestones: 2020R3, 2020R2 Apr 24, 2020
@hasithaa hasithaa added the implementation/inprogress Implementation inprogress label Apr 27, 2020
@jclark
Copy link
Collaborator Author

jclark commented May 1, 2020

As discussed in #469, if all the fields of a closed record type are immutable, then it should be considered immutable also.

@jclark jclark closed this as completed in d9f2037 May 12, 2020
@hasithaa hasithaa added implementation/done Implementation Done and removed implementation/inprogress Implementation inprogress labels 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 status/inprogress Fixes are in the process of being added
Projects
None yet
Development

No branches or pull requests

2 participants