-
-
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
ability to mark fields of types as immutable-const #9448
Comments
this is a specific case of wanting the ability to mark specific fields of a type as being constant (also helps type inference in many places). also related: #6713 |
parameters
field of DataType
Another approach is to make specific fields of an |
yes. and that would be equivalent to the approach taken by the codegen when creating a closure environment (we can replace I think the real value in this change is that we could merge the isbits and immutable distinction. Then the immutable property would directly set whether a type was inlined or not, regardless of its contents. |
|
seems like a very simple syntax for this, and is backwards compatible to boot. |
Seems like a relatively minor change that could potentially lead to big performance increases. |
I don't think that's quite right. If any field of a struct is mutable, then you can no longer copy it around freely, so even one mutable field poisons the whole thing and forces the structure to behave as if it has a stable memory address, i.e. like a |
We could make a |
Can we have both? Could Julia use some heuristic to decide which strategy is most likely to increase performance? You can pretty easily translate one to the other, and they both have the same semantics, I think, except for the memory address bit. |
We could, but if you need a stable address for part of it, it's likely to always be much cheaper and faster to get one stable address for the whole thing, than to essentially carry around multiple very fat pointers to a the mutable fields. |
I think it might just be a matter of documenting that tradeoff, then? Unless I'm misunderstanding. |
(Julia Version 0.3.4-pre+47)
I should know better than to even be attempting what I was attempting, but perhaps something loud should happen if a user tries to set the
.parameters
field of aDataType
object.The text was updated successfully, but these errors were encountered: