-
Notifications
You must be signed in to change notification settings - Fork 12
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
What should happen when a class's fields are mutated? #40
Comments
In Squeak, you'll have to trigger the compiler manually to regenerate methods (tested on Squeak 5). Pharo uses a more elaborate system, but I think the key there is that the return array is simply a snapshot of the class at that point. I don't know what the right thing for SOM is. Considering also #35, these things should ideally be following a consistent approach. One option would be to say, yes, these methods always return snapshots, and any mutation is without effect on the actual system. Another option would be to have methods bind dynamically to fields. Though, this would mean unknown fields raise |
Having thought about this a bit, I think a plausible course of action is to diverge from #35. The difference between |
This returns a class's fields. However, SOM's semantics on this are currently unclear (see SOM-st/SOM#40). Although we allow users to mutate the 'methods' array, this is less sensible with fields in my opinion, since it would turn SOM from a statically into a dynamically scoped language. Thus, each time you call 'fields' you get a fresh array back such that any mutations made are ignored (see the `mutate_fields` test).
142: Add the 'fields' primitive. r=ptersilie a=ltratt This returns a class's fields. However, SOM's semantics on this are currently unclear (see SOM-st/SOM#40). Although we allow users to mutate the 'methods' array, this is less sensible with fields in my opinion, since it would turn SOM from a statically into a dynamically scoped language. Thus, each time you call 'fields' you get a fresh array back such that any mutations made are ignored (see the `mutate_fields` test). Co-authored-by: Laurence Tratt <[email protected]>
What should the output of the following be?
Java SOM prints:
yksom would probably print the same if/when I implement the
fields
primitive. In a sense, it seems like reasonable behaviour to me, but I'm not sure if anyone has thought of this before and/or has opinions on what should happen.The text was updated successfully, but these errors were encountered: