-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
const fields for composite types #359
Comments
Rather than introduce a function like new(), you could follow the example of the java compiler. If you do that, you could either |
The |
Seems like a decent approach. |
We've talked about keyword arguments to functions in general — and once that feature exists, it would be natural for |
I suppose we could use this syntax with the assignable-cell model: fields not marked |
I think that's way too verbose for the default. If we go with immutable composites with assignable ref fields, I was thinking that using & in the syntax would be nice and terse — and conceptually similar to its use in ccall. Either &x::T or x::&T. |
Fair enough. Another issue is finalization --- it seems to me we can only support finalizers on objects with mutable fields; then the finalizer can be attached to one of the ref cells. |
yeah, that seems sensible. |
Merging with issue #13. |
Essentially something like this:
A
const
field, like aconst
variable is write-once. In the case of a const field, that means that the value assigned bynew
is the permanent value of the field and it cannot be changed.The text was updated successfully, but these errors were encountered: