-
Notifications
You must be signed in to change notification settings - Fork 6
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
Primitive Failed #14
Comments
The mutation over literals is not supported because they are readonly objects since Pharo 10. They can't be modified. The equivalent error would be for an expression: #(4 3 3 8 11 34 1) at: 2 put: 100. The error here is more explicit ModificationForbidden. The MirrorPrimitives can be improved to reflect it as well. But generally your example is not correct. The mutation instance is not a proxy. It modifies given object (an array here) in the way to intercept all messages and process it with the configured behaviour. So it does not replace the object. object := #(4 3 3 8 11 34 1) copy.
mutation := GHObjectMutation behaviour: (GHDelegatorBehaviour target: #(-1 -2 -3)).
mutation mutate: object.
object collect: [ :it | it * 2 ]. "==> #(-1 -4 -6)" Notice that I added a target array into GHDelegatorBehaviour because the delegator simply resends all intercepted messages into it. Otherwise there will be an error DNU to nil: object := #(4 3 3 8 11 34 1) copy.
mutation := GHObjectMutation behaviour: GHDelegatorBehaviour new.
mutation mutate: object.
object printString => " ==> 'nil' " |
Humm. This project is related to https://hal.inria.fr/inria-00614720/document? I though so... Well, GHObjectMutation creates an interceptor that I can use to create proxies? It seems so considering your explanation. Anyway thanks, I manage to understand better and make a simple example works. Besides that, I agree this is not an error. Maybe providing an specific error could be considered an enhancement? Something like 'Trying to mutate a literal which is not supported'? |
I slightly changed the vocabulary and the implementation. So this version is quite different than one from the paper.
Yes, it will be a good improvement but it is part of Pharo , not this project. |
The problem occurs using this lib, why providing better information of the error is part of Pharo? Instead of a "Primitive Failed' error, if |
My comment was about incompleteness of the implementation of MirrorPrimitives method #setClass:to: . It is core part of Pharo. And it have to raise a better exception describing the inability to modify the object: ModificationForbidden in that case. I don't mind to have a ghost-specific error as well. But I don't see the use case for this. |
On a Pharo 10 image in a Windows 10, when I execute this code :
I got a "PrimitiveFailed: primitive #setClass:to: in GHMetaMessages class failed":
The text was updated successfully, but these errors were encountered: