> Hi guys. I usually like to take a look to ProtoObject and see what is really needed for the minimal object. But having 30% of the methods being #tryNamedPrimitive:with: * is not fun.
what are these?
what are these?
On Jan 23, 2012, at 5:52 PM, Mariano Martinez Peck wrote:
> Hi guys. I usually like to take a look to ProtoObject and see what is really needed for the minimal object. But having 30% of the methods being #tryNamedPrimitive:with: * is not fun.
> So...I wonder, do you think there could be another way so that to avoid having all those methods in ProtoObject ?
>
> Thanks
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
Hi guys. I usually like to take a look to ProtoObject and see what is really needed for the minimal object. But having 30% of the methods being #tryNamedPrimitive:with: * is not fun.
So...I wonder, do you think there could be another way so that to avoid having all those methods in ProtoObject ?
Thanks
--
Mariano
http://marianopeck.wordpress.com
What are these tryNamedPrimitive?
Why do we need them in ProtoObject?
Because I'm not sure that adding primitive to VM is always a good solution.
Stef
Hi elliot
What are these tryNamedPrimitive?
Why do we need them in ProtoObject?
Because I'm not sure that adding primitive to VM is always a good solution.
On Mon, Jan 23, 2012 at 12:57 PM, Stéphane Ducasse <stephane...@inria.fr> wrote:Hi elliot
What are these tryNamedPrimitive?The methods in ProtoObject implement invoking primitives in the context of the debugger.
The debugger used to use methods in Object, tryPrimitive0, tryPrimitive1: tryPrimitive2:with: et al, to invoke normal primitives. The debugger would choose the tryPrimitive1: method with the right number of arguments, modify its header to change its primitive number of the desired primitive, and then call it to invoke the primitive. This is not reentrant. If one is trying to debug the debugger then the tryPrimitive: method can be modified by the debugger that is debugging the debugger that is in the process of editing the tryPrimitive: method. To fix this, and eliminate the tryPrimitiveN methods, someone introduced the tryPrimitive:withArgs: primitive. (Note that in VisualWorks we solved this by creating a method on the fly to invoke a given primitive and evaluating it using a primitive that did the same thing as withArgs:executeMethod:).
Analogously, one needs a way of invoking named primitives in the debugger, and using tryNamedPrimitive[:with:with:...] et al has exactly the same weaknesses as tryPrimitiveN above. So introducing a primitive to run named primitives is in keeping with tryPrimitive:withArgs:. Using the VisualWorks approach is feasible but violates Occam's razor.
>
>
> On Mon, Jan 23, 2012 at 12:57 PM, Stéphane Ducasse <stephane...@inria.fr> wrote:
> Hi elliot
>
> What are these tryNamedPrimitive?
>
> The methods in ProtoObject implement invoking primitives in the context of the debugger. The debugger used to use methods in Object, tryPrimitive0, tryPrimitive1: tryPrimitive2:with: et al, to invoke normal primitives. The debugger would choose the tryPrimitive1: method with the right number of arguments, modify its header to change its primitive number of the desired primitive, and then call it to invoke the primitive. This is not reentrant. If one is trying to debug the debugger then the tryPrimitive: method can be modified by the debugger that is debugging the debugger that is in the process of editing the tryPrimitive: method. To fix this, and eliminate the tryPrimitiveN methods, someone introduced the tryPrimitive:withArgs: primitive. (Note that in VisualWorks we solved this by creating a method on the fly to invoke a given primitive and evaluating it using a primitive that did the same thing as withArgs:executeMethod:).
Thanks for the explanation.
I have another question
is this for invoking primitive directly? Or my question is why we cannot simply call the method that is flagged as a primitive?
I started to read the interpreter of camillo and I did not arrive yet at primitives :)
> Analogously, one needs a way of invoking named primitives in the debugger, and using tryNamedPrimitive[:with:with:...] et al has exactly the same weaknesses as tryPrimitiveN above. So introducing a primitive to run named primitives is in keeping with tryPrimitive:withArgs:. Using the VisualWorks approach is feasible but violates Occam's razor.
You lost me. You mean that you want to avoid to have a primitive to execute primitives?
>
> Why do we need them in ProtoObject?
>
> Once tryNamedPrimitiveIn:for:withArgs: is implemented in all relevant virtual machines we don't need them. You'll notice that there is no trace of the tryPrimitiveN methods anymore, even though they're in Smalltalk-80.
>
> Because I'm not sure that adding primitive to VM is always a good solution.
>
> Agreed. But it is in keeping with the primitive for invoking numbered primitives, tryPrimitive:withArgs:.
Yes I see.
Thanks for the explanation.