-
Notifications
You must be signed in to change notification settings - Fork 5
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
polymorphic accessors #273
Comments
How would this interact with ref types, access into a different parameter and things like global variables? I assume this isn’t the entire design you have in mind as the description sounds far too trivial to deal with every scenario. |
I don't understand your question, |
Nevermind, tested and it and points to https://nim-lang.github.io/Nim/var_t_return.html |
Will this scheme work with copy on write types? |
Can't see why not, make the |
An accessor is polymorphic if it has the signature
proc access(c: Container; ...): var T
where Container does not have thevar
in the signature, if then later the call is used to mutate we have to check that the first parameter of the call access(first, ...) was mutable to begin with.In the ABI such a parameter would always become var implicitly tough. In other words, it eventually always becomes a pointer,
so that no two versions of the proc need to be generated.
This also allows us to omit "overloading based on var-ness" entirely. (Though for backwards compat we will still need it.)
The text was updated successfully, but these errors were encountered: