[Pharo-project] ProtoObject basicNew :)
Hi I would like to know the methods that I should define in a subclass of ProtoObject so that I can use basicNew. Does any of you have an idea? Stef
Don't you just need the basicNew primitive, and make sure that the "magic number" is set in the object that has the basicNew installed to something that makes sense? If you want to send messages to the object, probably also best install some dictionary as the method dict instvar. Toon On 11/25/2011 09:26 PM, Stéphane Ducasse wrote:
Hi I would like to know the methods that I should define in a subclass of ProtoObject so that I can use basicNew. Does any of you have an idea?
Stef
Apparently I can do a doit I was naively doing an inspect ;)
Don't you just need the basicNew primitive, and make sure that the "magic number" is set in the object that has the basicNew installed to something that makes sense?
I do not know what is the magic number. I guess that my problem was that I have first to define what is the minimal behavior.
If you want to send messages to the object, probably also best install some dictionary as the method dict instvar. But I guess that ProtoObject has some behavior since I can browse the class with a browser.
Toon
On 11/25/2011 09:26 PM, Stéphane Ducasse wrote:
Hi I would like to know the methods that I should define in a subclass of ProtoObject so that I can use basicNew. Does any of you have an idea?
Stef
With the magic number I mean the number that defines the object's structure. It's one of the first 3 instance variables of every class, encoding how many instance variables there are; what kind of object it is supposed to be (normal, array, bytes, words...). Every "class" basically needs 3 instance variables. 1 defines the structure, 1 the superclass, 1 the behavior (method dictionary). I don't know the other; but just look at some class to know what the order is. And yes, if you want to inspect the object, you'll need to support whatever protocol your inspector is using. The format is formed as follows: |format | fieldSize sizeHiBits format | fieldSize := self fieldSize + 1. sizeHiBits := fieldSize // 64. format := sizeHiBits. format := (format bitShift: 5) + compactClassIndex. format := (format bitShift: 4) + self instanceSpecification. format := (format bitShift: 6) + (fieldSize \\ 64). format := (format bitShift: 1). ^ format If I read it correctly (just glancing), instance specification specifies if it's arrayed and if it has fields. 0 -> no fields, not arrayed, 1 -> fields, not arrayed, 2 -> arrayed no fields, 3 -> arrayed fields. | HTH, Toon On 11/25/2011 09:31 PM, Stéphane Ducasse wrote:
Apparently I can do a doit I was naively doing an inspect ;)
Don't you just need the basicNew primitive, and make sure that the "magic number" is set in the object that has the basicNew installed to something that makes sense? I do not know what is the magic number. I guess that my problem was that I have first to define what is the minimal behavior.
If you want to send messages to the object, probably also best install some dictionary as the method dict instvar. But I guess that ProtoObject has some behavior since I can browse the class with a browser.
Toon
On 11/25/2011 09:26 PM, Stéphane Ducasse wrote:
Hi I would like to know the methods that I should define in a subclass of ProtoObject so that I can use basicNew. Does any of you have an idea?
Stef
I'm confused. I'm not creating a class but an instance. if it would be Behavior basicNew then yes I made sure that we could do Behavior new and not crashing the system back in Squeak. On Nov 25, 2011, at 9:45 PM, Toon Verwaest wrote:
With the magic number I mean the number that defines the object's structure. It's one of the first 3 instance variables of every class, encoding how many instance variables there are; what kind of object it is supposed to be (normal, array, bytes, words...). Every "class" basically needs 3 instance variables. 1 defines the structure, 1 the superclass, 1 the behavior (method dictionary). I don't know the other; but just look at some class to know what the order is. Yes format, methodDict, superclass (probably in a different order). And format is ugly because not explicit and coded in several place like instSpec (berk)
And yes, if you want to inspect the object, you'll need to support whatever protocol your inspector is using.
The format is formed as follows:
format | fieldSize sizeHiBits format | fieldSize := self fieldSize + 1. sizeHiBits := fieldSize // 64. format := sizeHiBits. format := (format bitShift: 5) + compactClassIndex. format := (format bitShift: 4) + self instanceSpecification. format := (format bitShift: 6) + (fieldSize \\ 64). format := (format bitShift: 1). ^ format
If I read it correctly (just glancing), instance specification specifies if it's arrayed and if it has fields. 0 -> no fields, not arrayed, 1 -> fields, not arrayed, 2 -> arrayed no fields, 3 -> arrayed fields.
HTH, Toon
On 11/25/2011 09:31 PM, Stéphane Ducasse wrote:
Apparently I can do a doit I was naively doing an inspect ;)
Don't you just need the basicNew primitive, and make sure that the "magic number" is set in the object that has the basicNew installed to something that makes sense?
I do not know what is the magic number. I guess that my problem was that I have first to define what is the minimal behavior.
If you want to send messages to the object, probably also best install some dictionary as the method dict instvar.
But I guess that ProtoObject has some behavior since I can browse the class with a browser.
Toon
On 11/25/2011 09:26 PM, Stéphane Ducasse wrote:
Hi I would like to know the methods that I should define in a subclass of ProtoObject so that I can use basicNew. Does any of you have an idea?
Stef
Ok, I guess I was confused by your initial question: "the methods that I should define in a subclass of ProtoObject so that I can use basicNew"... :) On 11/25/2011 10:05 PM, Stéphane Ducasse wrote:
I'm confused. I'm not creating a class but an instance. if it would be Behavior basicNew then yes I made sure that we could do Behavior new and not crashing the system back in Squeak.
On Nov 25, 2011, at 9:45 PM, Toon Verwaest wrote:
With the magic number I mean the number that defines the object's structure. It's one of the first 3 instance variables of every class, encoding how many instance variables there are; what kind of object it is supposed to be (normal, array, bytes, words...). Every "class" basically needs 3 instance variables. 1 defines the structure, 1 the superclass, 1 the behavior (method dictionary). I don't know the other; but just look at some class to know what the order is. Yes format, methodDict, superclass (probably in a different order). And format is ugly because not explicit and coded in several place like instSpec (berk)
And yes, if you want to inspect the object, you'll need to support whatever protocol your inspector is using.
The format is formed as follows:
format | fieldSize sizeHiBits format | fieldSize := self fieldSize + 1. sizeHiBits := fieldSize // 64. format := sizeHiBits. format := (format bitShift: 5) + compactClassIndex. format := (format bitShift: 4) + self instanceSpecification. format := (format bitShift: 6) + (fieldSize \\ 64). format := (format bitShift: 1). ^ format
If I read it correctly (just glancing), instance specification specifies if it's arrayed and if it has fields. 0 -> no fields, not arrayed, 1 -> fields, not arrayed, 2 -> arrayed no fields, 3 -> arrayed fields.
HTH, Toon
On 11/25/2011 09:31 PM, Stéphane Ducasse wrote:
Apparently I can do a doit I was naively doing an inspect ;)
Don't you just need the basicNew primitive, and make sure that the "magic number" is set in the object that has the basicNew installed to something that makes sense?
I do not know what is the magic number. I guess that my problem was that I have first to define what is the minimal behavior.
If you want to send messages to the object, probably also best install some dictionary as the method dict instvar.
But I guess that ProtoObject has some behavior since I can browse the class with a browser.
Toon
On 11/25/2011 09:26 PM, Stéphane Ducasse wrote:
Hi I would like to know the methods that I should define in a subclass of ProtoObject so that I can use basicNew. Does any of you have an idea?
Stef
On Nov 25, 2011, at 10:09 PM, Toon Verwaest wrote:
Ok, I guess I was confused by your initial question: "the methods that I should define in a subclass of ProtoObject so that I can use basicNew"... :)
:) Yes it is more the methods that I should define to have a usable class (browse, doit, inspect it). I will probably have to do it by try and error. Stef
On 11/25/2011 10:05 PM, Stéphane Ducasse wrote:
I'm confused. I'm not creating a class but an instance. if it would be Behavior basicNew then yes I made sure that we could do Behavior new and not crashing the system back in Squeak.
On Nov 25, 2011, at 9:45 PM, Toon Verwaest wrote:
With the magic number I mean the number that defines the object's structure. It's one of the first 3 instance variables of every class, encoding how many instance variables there are; what kind of object it is supposed to be (normal, array, bytes, words...). Every "class" basically needs 3 instance variables. 1 defines the structure, 1 the superclass, 1 the behavior (method dictionary). I don't know the other; but just look at some class to know what the order is. Yes format, methodDict, superclass (probably in a different order). And format is ugly because not explicit and coded in several place like instSpec (berk)
And yes, if you want to inspect the object, you'll need to support whatever protocol your inspector is using.
The format is formed as follows:
format | fieldSize sizeHiBits format | fieldSize := self fieldSize + 1. sizeHiBits := fieldSize // 64. format := sizeHiBits. format := (format bitShift: 5) + compactClassIndex. format := (format bitShift: 4) + self instanceSpecification. format := (format bitShift: 6) + (fieldSize \\ 64). format := (format bitShift: 1). ^ format
If I read it correctly (just glancing), instance specification specifies if it's arrayed and if it has fields. 0 -> no fields, not arrayed, 1 -> fields, not arrayed, 2 -> arrayed no fields, 3 -> arrayed fields.
HTH, Toon
On 11/25/2011 09:31 PM, Stéphane Ducasse wrote:
Apparently I can do a doit I was naively doing an inspect ;)
Don't you just need the basicNew primitive, and make sure that the "magic number" is set in the object that has the basicNew installed to something that makes sense?
I do not know what is the magic number. I guess that my problem was that I have first to define what is the minimal behavior.
If you want to send messages to the object, probably also best install some dictionary as the method dict instvar.
But I guess that ProtoObject has some behavior since I can browse the class with a browser.
Toon
On 11/25/2011 09:26 PM, Stéphane Ducasse wrote:
Hi I would like to know the methods that I should define in a subclass of ProtoObject so that I can use basicNew. Does any of you have an idea?
Stef
Stef, You can easily obtain the list by using a Ghost proxy. 1) Install the package : Gofer new squeaksource: 'Marea'; package: 'GhostProxies'; package: 'GhostProxiesTests'; load. 2) uncomment the body of method SimpleForwarderHandler>>log: aString Transcript show: aString; cr. 3) open a transcript 4) create a proxy on any object and play with it (ObjectProxy proxyFor: (Object new)) inspect 5) analyze the log on the transcript :-) On 25 nov. 2011, at 22:19, Stéphane Ducasse wrote:
On Nov 25, 2011, at 10:09 PM, Toon Verwaest wrote:
Ok, I guess I was confused by your initial question: "the methods that I should define in a subclass of ProtoObject so that I can use basicNew"... :)
:)
Yes it is more the methods that I should define to have a usable class (browse, doit, inspect it). I will probably have to do it by try and error.
Stef
On 11/25/2011 10:05 PM, Stéphane Ducasse wrote:
I'm confused. I'm not creating a class but an instance. if it would be Behavior basicNew then yes I made sure that we could do Behavior new and not crashing the system back in Squeak.
On Nov 25, 2011, at 9:45 PM, Toon Verwaest wrote:
With the magic number I mean the number that defines the object's structure. It's one of the first 3 instance variables of every class, encoding how many instance variables there are; what kind of object it is supposed to be (normal, array, bytes, words...). Every "class" basically needs 3 instance variables. 1 defines the structure, 1 the superclass, 1 the behavior (method dictionary). I don't know the other; but just look at some class to know what the order is. Yes format, methodDict, superclass (probably in a different order). And format is ugly because not explicit and coded in several place like instSpec (berk)
And yes, if you want to inspect the object, you'll need to support whatever protocol your inspector is using.
The format is formed as follows:
format | fieldSize sizeHiBits format | fieldSize := self fieldSize + 1. sizeHiBits := fieldSize // 64. format := sizeHiBits. format := (format bitShift: 5) + compactClassIndex. format := (format bitShift: 4) + self instanceSpecification. format := (format bitShift: 6) + (fieldSize \\ 64). format := (format bitShift: 1). ^ format
If I read it correctly (just glancing), instance specification specifies if it's arrayed and if it has fields. 0 -> no fields, not arrayed, 1 -> fields, not arrayed, 2 -> arrayed no fields, 3 -> arrayed fields.
HTH, Toon
On 11/25/2011 09:31 PM, Stéphane Ducasse wrote:
Apparently I can do a doit I was naively doing an inspect ;)
Don't you just need the basicNew primitive, and make sure that the "magic number" is set in the object that has the basicNew installed to something that makes sense?
I do not know what is the magic number. I guess that my problem was that I have first to define what is the minimal behavior.
If you want to send messages to the object, probably also best install some dictionary as the method dict instvar.
But I guess that ProtoObject has some behavior since I can browse the class with a browser.
Toon
On 11/25/2011 09:26 PM, Stéphane Ducasse wrote:
Hi I would like to know the methods that I should define in a subclass of ProtoObject so that I can use basicNew. Does any of you have an idea?
Stef
Noury -- http://twitter.com/#!/NouryBouraqadi
On Sat, Nov 26, 2011 at 5:05 PM, Noury Bouraqadi <bouraqadi@gmail.com>wrote:
Stef,
You can easily obtain the list by using a Ghost proxy.
Good PhD supervisor that checks student's code :):):)
1) Install the package : Gofer new squeaksource: 'Marea'; package: 'GhostProxies'; package: 'GhostProxiesTests'; load.
2) uncomment the body of method SimpleForwarderHandler>>log: aString Transcript show: aString; cr.
3) open a transcript
4) create a proxy on any object and play with it (ObjectProxy proxyFor: (Object new)) inspect
Be careful that by default there are some debugging methods that I DO NOT forward but rather do something. Check for example the method: debuggingMessagesToHandle | dict | dict := Dictionary new. dict at: #basicInspect put:#handleBasicInspect:. dict at: #inspect put:#handleInspect:. dict at: #inspectorClass put:#handleInspectorClass:. dict at: #defaultLabelForInspector put:#handleDefaultLabelForInspector:. dict at: #printStringLimitedTo: put: #handlePrintStringLimitedTo:. dict at: #printString put: #handlePrintString:. dict at: #longPrintOn:limitedTo:indent: put: #handleLongPrintOnLimitedToIndent:. ^ dict That means that whenever the proxy receives #basicInspect I do not forward that to the target but instead, the proxy itself executes #handleBasicInspect: This let me debug with proxies without problem. That being said, even if the message is not forwarded, it is shown in the transcript, so for that Stef needs, it should work :)
5) analyze the log on the transcript :-)
On 25 nov. 2011, at 22:19, Stéphane Ducasse wrote:
On Nov 25, 2011, at 10:09 PM, Toon Verwaest wrote:
Ok, I guess I was confused by your initial question: "the methods that
I should define in a subclass of ProtoObject so that I can use basicNew"... :)
:)
Yes it is more the methods that I should define to have a usable class
(browse, doit, inspect it). I will probably have to do it by try and error.
Stef
On 11/25/2011 10:05 PM, Stéphane Ducasse wrote:
I'm confused. I'm not creating a class but an instance. if it would be Behavior basicNew then yes I made sure that we could do
Behavior new and not crashing the system back in Squeak.
On Nov 25, 2011, at 9:45 PM, Toon Verwaest wrote:
With the magic number I mean the number that defines the object's
structure. It's one of the first 3 instance variables of every class, encoding how many instance variables there are; what kind of object it is supposed to be (normal, array, bytes, words...). Every "class" basically needs 3 instance variables. 1 defines the structure, 1 the superclass, 1 the behavior (method dictionary). I don't know the other; but just look at some class to know what the order is.
Yes format, methodDict, superclass (probably in a different order). And format is ugly because not explicit and coded in several place like instSpec (berk)
And yes, if you want to inspect the object, you'll need to support whatever protocol your inspector is using.
The format is formed as follows:
format | fieldSize sizeHiBits format | fieldSize := self fieldSize + 1. sizeHiBits := fieldSize // 64. format := sizeHiBits. format := (format bitShift: 5) + compactClassIndex. format := (format bitShift: 4) + self instanceSpecification. format := (format bitShift: 6) + (fieldSize \\ 64). format := (format bitShift: 1). ^ format
If I read it correctly (just glancing), instance specification specifies if it's arrayed and if it has fields. 0 -> no fields, not arrayed, 1 -> fields, not arrayed, 2 -> arrayed no fields, 3 -> arrayed fields.
HTH, Toon
On 11/25/2011 09:31 PM, Stéphane Ducasse wrote:
Apparently I can do a doit I was naively doing an inspect ;)
Don't you just need the basicNew primitive, and make sure that the "magic number" is set in the object that has the basicNew installed to something that makes sense?
I do not know what is the magic number. I guess that my problem was that I have first to define what is the minimal behavior.
If you want to send messages to the object, probably also best install some dictionary as the method dict instvar.
But I guess that ProtoObject has some behavior since I can browse the class with a browser.
Toon
On 11/25/2011 09:26 PM, Stéphane Ducasse wrote:
Hi I would like to know the methods that I should define in a subclass of ProtoObject so that I can use basicNew. Does any of you have an idea?
Stef
Noury -- http://twitter.com/#!/NouryBouraqadi
-- Mariano http://marianopeck.wordpress.com
On 26 nov. 2011, at 21:11, Mariano Martinez Peck wrote:
On Sat, Nov 26, 2011 at 5:05 PM, Noury Bouraqadi <bouraqadi@gmail.com> wrote: Stef,
You can easily obtain the list by using a Ghost proxy.
Good PhD supervisor that checks student's code :):):)
:-)
That means that whenever the proxy receives #basicInspect I do not forward that to the target but instead, the proxy itself executes #handleBasicInspect: This let me debug with proxies without problem. That being said, even if the message is not forwarded, it is shown in the transcript, so for that Stef needs, it should work :)
Yes. Your log says it :-) It's well done :-)
5) analyze the log on the transcript :-)
On 25 nov. 2011, at 22:19, Stéphane Ducasse wrote:
On Nov 25, 2011, at 10:09 PM, Toon Verwaest wrote:
Ok, I guess I was confused by your initial question: "the methods that I should define in a subclass of ProtoObject so that I can use basicNew"... :)
:)
Yes it is more the methods that I should define to have a usable class (browse, doit, inspect it). I will probably have to do it by try and error.
Stef
On 11/25/2011 10:05 PM, Stéphane Ducasse wrote:
I'm confused. I'm not creating a class but an instance. if it would be Behavior basicNew then yes I made sure that we could do Behavior new and not crashing the system back in Squeak.
On Nov 25, 2011, at 9:45 PM, Toon Verwaest wrote:
With the magic number I mean the number that defines the object's structure. It's one of the first 3 instance variables of every class, encoding how many instance variables there are; what kind of object it is supposed to be (normal, array, bytes, words...). Every "class" basically needs 3 instance variables. 1 defines the structure, 1 the superclass, 1 the behavior (method dictionary). I don't know the other; but just look at some class to know what the order is. Yes format, methodDict, superclass (probably in a different order). And format is ugly because not explicit and coded in several place like instSpec (berk)
And yes, if you want to inspect the object, you'll need to support whatever protocol your inspector is using.
The format is formed as follows:
format | fieldSize sizeHiBits format | fieldSize := self fieldSize + 1. sizeHiBits := fieldSize // 64. format := sizeHiBits. format := (format bitShift: 5) + compactClassIndex. format := (format bitShift: 4) + self instanceSpecification. format := (format bitShift: 6) + (fieldSize \\ 64). format := (format bitShift: 1). ^ format
If I read it correctly (just glancing), instance specification specifies if it's arrayed and if it has fields. 0 -> no fields, not arrayed, 1 -> fields, not arrayed, 2 -> arrayed no fields, 3 -> arrayed fields.
HTH, Toon
On 11/25/2011 09:31 PM, Stéphane Ducasse wrote:
Apparently I can do a doit I was naively doing an inspect ;)
Don't you just need the basicNew primitive, and make sure that the "magic number" is set in the object that has the basicNew installed to something that makes sense?
I do not know what is the magic number. I guess that my problem was that I have first to define what is the minimal behavior.
If you want to send messages to the object, probably also best install some dictionary as the method dict instvar.
But I guess that ProtoObject has some behavior since I can browse the class with a browser.
Toon
On 11/25/2011 09:26 PM, Stéphane Ducasse wrote:
Hi I would like to know the methods that I should define in a subclass of ProtoObject so that I can use basicNew. Does any of you have an idea?
Stef
Noury -- http://twitter.com/#!/NouryBouraqadi
-- Mariano http://marianopeck.wordpress.com
Noury -- http://twitter.com/#!/NouryBouraqadi
thanks noury! Stef On Nov 26, 2011, at 9:05 PM, Noury Bouraqadi wrote:
Stef,
You can easily obtain the list by using a Ghost proxy. 1) Install the package : Gofer new squeaksource: 'Marea'; package: 'GhostProxies'; package: 'GhostProxiesTests'; load.
2) uncomment the body of method SimpleForwarderHandler>>log: aString Transcript show: aString; cr.
3) open a transcript
4) create a proxy on any object and play with it (ObjectProxy proxyFor: (Object new)) inspect
5) analyze the log on the transcript :-)
On 25 nov. 2011, at 22:19, Stéphane Ducasse wrote:
On Nov 25, 2011, at 10:09 PM, Toon Verwaest wrote:
Ok, I guess I was confused by your initial question: "the methods that I should define in a subclass of ProtoObject so that I can use basicNew"... :)
:)
Yes it is more the methods that I should define to have a usable class (browse, doit, inspect it). I will probably have to do it by try and error.
Stef
On 11/25/2011 10:05 PM, Stéphane Ducasse wrote:
I'm confused. I'm not creating a class but an instance. if it would be Behavior basicNew then yes I made sure that we could do Behavior new and not crashing the system back in Squeak.
On Nov 25, 2011, at 9:45 PM, Toon Verwaest wrote:
With the magic number I mean the number that defines the object's structure. It's one of the first 3 instance variables of every class, encoding how many instance variables there are; what kind of object it is supposed to be (normal, array, bytes, words...). Every "class" basically needs 3 instance variables. 1 defines the structure, 1 the superclass, 1 the behavior (method dictionary). I don't know the other; but just look at some class to know what the order is. Yes format, methodDict, superclass (probably in a different order). And format is ugly because not explicit and coded in several place like instSpec (berk)
And yes, if you want to inspect the object, you'll need to support whatever protocol your inspector is using.
The format is formed as follows:
format | fieldSize sizeHiBits format | fieldSize := self fieldSize + 1. sizeHiBits := fieldSize // 64. format := sizeHiBits. format := (format bitShift: 5) + compactClassIndex. format := (format bitShift: 4) + self instanceSpecification. format := (format bitShift: 6) + (fieldSize \\ 64). format := (format bitShift: 1). ^ format
If I read it correctly (just glancing), instance specification specifies if it's arrayed and if it has fields. 0 -> no fields, not arrayed, 1 -> fields, not arrayed, 2 -> arrayed no fields, 3 -> arrayed fields.
HTH, Toon
On 11/25/2011 09:31 PM, Stéphane Ducasse wrote:
Apparently I can do a doit I was naively doing an inspect ;)
Don't you just need the basicNew primitive, and make sure that the "magic number" is set in the object that has the basicNew installed to something that makes sense?
I do not know what is the magic number. I guess that my problem was that I have first to define what is the minimal behavior.
If you want to send messages to the object, probably also best install some dictionary as the method dict instvar.
But I guess that ProtoObject has some behavior since I can browse the class with a browser.
Toon
On 11/25/2011 09:26 PM, Stéphane Ducasse wrote:
Hi I would like to know the methods that I should define in a subclass of ProtoObject so that I can use basicNew. Does any of you have an idea?
Stef
Noury -- http://twitter.com/#!/NouryBouraqadi
It crashed my NBCog and Cog one vm. so I should probably upgrade. Stef On Nov 27, 2011, at 11:36 AM, Stéphane Ducasse wrote:
thanks noury!
Stef
On Nov 26, 2011, at 9:05 PM, Noury Bouraqadi wrote:
Stef,
You can easily obtain the list by using a Ghost proxy. 1) Install the package : Gofer new squeaksource: 'Marea'; package: 'GhostProxies'; package: 'GhostProxiesTests'; load.
2) uncomment the body of method SimpleForwarderHandler>>log: aString Transcript show: aString; cr.
3) open a transcript
4) create a proxy on any object and play with it (ObjectProxy proxyFor: (Object new)) inspect
5) analyze the log on the transcript :-)
On 25 nov. 2011, at 22:19, Stéphane Ducasse wrote:
On Nov 25, 2011, at 10:09 PM, Toon Verwaest wrote:
Ok, I guess I was confused by your initial question: "the methods that I should define in a subclass of ProtoObject so that I can use basicNew"... :)
:)
Yes it is more the methods that I should define to have a usable class (browse, doit, inspect it). I will probably have to do it by try and error.
Stef
On 11/25/2011 10:05 PM, Stéphane Ducasse wrote:
I'm confused. I'm not creating a class but an instance. if it would be Behavior basicNew then yes I made sure that we could do Behavior new and not crashing the system back in Squeak.
On Nov 25, 2011, at 9:45 PM, Toon Verwaest wrote:
With the magic number I mean the number that defines the object's structure. It's one of the first 3 instance variables of every class, encoding how many instance variables there are; what kind of object it is supposed to be (normal, array, bytes, words...). Every "class" basically needs 3 instance variables. 1 defines the structure, 1 the superclass, 1 the behavior (method dictionary). I don't know the other; but just look at some class to know what the order is. Yes format, methodDict, superclass (probably in a different order). And format is ugly because not explicit and coded in several place like instSpec (berk)
And yes, if you want to inspect the object, you'll need to support whatever protocol your inspector is using.
The format is formed as follows:
format | fieldSize sizeHiBits format | fieldSize := self fieldSize + 1. sizeHiBits := fieldSize // 64. format := sizeHiBits. format := (format bitShift: 5) + compactClassIndex. format := (format bitShift: 4) + self instanceSpecification. format := (format bitShift: 6) + (fieldSize \\ 64). format := (format bitShift: 1). ^ format
If I read it correctly (just glancing), instance specification specifies if it's arrayed and if it has fields. 0 -> no fields, not arrayed, 1 -> fields, not arrayed, 2 -> arrayed no fields, 3 -> arrayed fields.
HTH, Toon
On 11/25/2011 09:31 PM, Stéphane Ducasse wrote:
Apparently I can do a doit I was naively doing an inspect ;)
Don't you just need the basicNew primitive, and make sure that the "magic number" is set in the object that has the basicNew installed to something that makes sense?
I do not know what is the magic number. I guess that my problem was that I have first to define what is the minimal behavior.
If you want to send messages to the object, probably also best install some dictionary as the method dict instvar.
But I guess that ProtoObject has some behavior since I can browse the class with a browser.
Toon
On 11/25/2011 09:26 PM, Stéphane Ducasse wrote:
Hi I would like to know the methods that I should define in a subclass of ProtoObject so that I can use basicNew. Does any of you have an idea?
Stef
Noury -- http://twitter.com/#!/NouryBouraqadi
On Sun, Nov 27, 2011 at 6:07 PM, Stéphane Ducasse <stephane.ducasse@inria.fr
wrote:
It crashed my NBCog and Cog one vm. so I should probably upgrade.
Yes, there were some bugs related to #cannotInterpret: a while ago with Cog. It should not crash with newest Cog versions. Please tell me if it happens.
Stef
On Nov 27, 2011, at 11:36 AM, Stéphane Ducasse wrote:
thanks noury!
Stef
On Nov 26, 2011, at 9:05 PM, Noury Bouraqadi wrote:
Stef,
You can easily obtain the list by using a Ghost proxy. 1) Install the package : Gofer new squeaksource: 'Marea'; package: 'GhostProxies'; package: 'GhostProxiesTests'; load.
2) uncomment the body of method SimpleForwarderHandler>>log: aString Transcript show: aString; cr.
3) open a transcript
4) create a proxy on any object and play with it (ObjectProxy proxyFor: (Object new)) inspect
5) analyze the log on the transcript :-)
On 25 nov. 2011, at 22:19, Stéphane Ducasse wrote:
On Nov 25, 2011, at 10:09 PM, Toon Verwaest wrote:
Ok, I guess I was confused by your initial question: "the methods
that I should define in a subclass of ProtoObject so that I can use basicNew"... :)
:)
Yes it is more the methods that I should define to have a usable class
(browse, doit, inspect it). I will probably have to do it by try and error.
Stef
On 11/25/2011 10:05 PM, Stéphane Ducasse wrote:
I'm confused. I'm not creating a class but an instance. if it would be Behavior basicNew then yes I made sure that we could
do Behavior new and not crashing the system back in Squeak.
On Nov 25, 2011, at 9:45 PM, Toon Verwaest wrote:
With the magic number I mean the number that defines the object's
structure. It's one of the first 3 instance variables of every class, encoding how many instance variables there are; what kind of object it is supposed to be (normal, array, bytes, words...). Every "class" basically needs 3 instance variables. 1 defines the structure, 1 the superclass, 1 the behavior (method dictionary). I don't know the other; but just look at some class to know what the order is.
Yes format, methodDict, superclass (probably in a different order). And format is ugly because not explicit and coded in several place like instSpec (berk)
And yes, if you want to inspect the object, you'll need to support whatever protocol your inspector is using.
The format is formed as follows:
format | fieldSize sizeHiBits format | fieldSize := self fieldSize + 1. sizeHiBits := fieldSize // 64. format := sizeHiBits. format := (format bitShift: 5) + compactClassIndex. format := (format bitShift: 4) + self instanceSpecification. format := (format bitShift: 6) + (fieldSize \\ 64). format := (format bitShift: 1). ^ format
If I read it correctly (just glancing), instance specification specifies if it's arrayed and if it has fields. 0 -> no fields, not arrayed, 1 -> fields, not arrayed, 2 -> arrayed no fields, 3 -> arrayed fields.
HTH, Toon
On 11/25/2011 09:31 PM, Stéphane Ducasse wrote:
Apparently I can do a doit I was naively doing an inspect ;)
Don't you just need the basicNew primitive, and make sure that the "magic number" is set in the object that has the basicNew installed to something that makes sense?
I do not know what is the magic number. I guess that my problem was that I have first to define what is the minimal behavior.
If you want to send messages to the object, probably also best install some dictionary as the method dict instvar.
But I guess that ProtoObject has some behavior since I can browse the class with a browser.
Toon
On 11/25/2011 09:26 PM, Stéphane Ducasse wrote:
Hi I would like to know the methods that I should define in a subclass of ProtoObject so that I can use basicNew. Does any of you have an idea?
Stef
Noury -- http://twitter.com/#!/NouryBouraqadi
-- Mariano http://marianopeck.wordpress.com
it works with the latest version published by esteban On Nov 29, 2011, at 8:45 PM, Mariano Martinez Peck wrote:
On Sun, Nov 27, 2011 at 6:07 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote: It crashed my NBCog and Cog one vm. so I should probably upgrade.
Yes, there were some bugs related to #cannotInterpret: a while ago with Cog. It should not crash with newest Cog versions. Please tell me if it happens.
Stef
On Nov 27, 2011, at 11:36 AM, Stéphane Ducasse wrote:
thanks noury!
Stef
On Nov 26, 2011, at 9:05 PM, Noury Bouraqadi wrote:
Stef,
You can easily obtain the list by using a Ghost proxy. 1) Install the package : Gofer new squeaksource: 'Marea'; package: 'GhostProxies'; package: 'GhostProxiesTests'; load.
2) uncomment the body of method SimpleForwarderHandler>>log: aString Transcript show: aString; cr.
3) open a transcript
4) create a proxy on any object and play with it (ObjectProxy proxyFor: (Object new)) inspect
5) analyze the log on the transcript :-)
On 25 nov. 2011, at 22:19, Stéphane Ducasse wrote:
On Nov 25, 2011, at 10:09 PM, Toon Verwaest wrote:
Ok, I guess I was confused by your initial question: "the methods that I should define in a subclass of ProtoObject so that I can use basicNew"... :)
:)
Yes it is more the methods that I should define to have a usable class (browse, doit, inspect it). I will probably have to do it by try and error.
Stef
On 11/25/2011 10:05 PM, Stéphane Ducasse wrote:
I'm confused. I'm not creating a class but an instance. if it would be Behavior basicNew then yes I made sure that we could do Behavior new and not crashing the system back in Squeak.
On Nov 25, 2011, at 9:45 PM, Toon Verwaest wrote:
With the magic number I mean the number that defines the object's structure. It's one of the first 3 instance variables of every class, encoding how many instance variables there are; what kind of object it is supposed to be (normal, array, bytes, words...). Every "class" basically needs 3 instance variables. 1 defines the structure, 1 the superclass, 1 the behavior (method dictionary). I don't know the other; but just look at some class to know what the order is. Yes format, methodDict, superclass (probably in a different order). And format is ugly because not explicit and coded in several place like instSpec (berk)
And yes, if you want to inspect the object, you'll need to support whatever protocol your inspector is using.
The format is formed as follows:
format | fieldSize sizeHiBits format | fieldSize := self fieldSize + 1. sizeHiBits := fieldSize // 64. format := sizeHiBits. format := (format bitShift: 5) + compactClassIndex. format := (format bitShift: 4) + self instanceSpecification. format := (format bitShift: 6) + (fieldSize \\ 64). format := (format bitShift: 1). ^ format
If I read it correctly (just glancing), instance specification specifies if it's arrayed and if it has fields. 0 -> no fields, not arrayed, 1 -> fields, not arrayed, 2 -> arrayed no fields, 3 -> arrayed fields.
HTH, Toon
On 11/25/2011 09:31 PM, Stéphane Ducasse wrote:
Apparently I can do a doit I was naively doing an inspect ;)
Don't you just need the basicNew primitive, and make sure that the "magic number" is set in the object that has the basicNew installed to something that makes sense?
I do not know what is the magic number. I guess that my problem was that I have first to define what is the minimal behavior.
If you want to send messages to the object, probably also best install some dictionary as the method dict instvar.
But I guess that ProtoObject has some behavior since I can browse the class with a browser.
Toon
On 11/25/2011 09:26 PM, Stéphane Ducasse wrote:
Hi I would like to know the methods that I should define in a subclass of ProtoObject so that I can use basicNew. Does any of you have an idea?
Stef
Noury -- http://twitter.com/#!/NouryBouraqadi
-- Mariano http://marianopeck.wordpress.com
Stef, Attached are methods I clearly felt the need to add to ProtoObject. I vaguely recall much trial and even more error :) In my one meaningful (and very little used, due to changing priorities) subclass of ProtoObject, I added #= and #hash. I also customized #printOn:, but that *shouldnt'* be important - caveat emptor :) There are some other finalization related methods, and some "Dolphinization" of events, etc. Again, I don't think those things are crucial outside of my world. Speaking of Dolphin, two things come to mind. First is protocols, which Dolphin makes concrete and editable. One can define the methods that constitute a protocol, and impose protocols on any number of classes. Any class can implement any number of protocols too. The system then complains if changes cause one or more classes to not understand one or more methods in declared protocols. Pretty slick. Another thing is the ability to assign multiple categories to any given method. I think that's something one has to have experienced in order to understand how completely useful it can be. HTH. Bill ________________________________________ From: pharo-project-bounces@lists.gforge.inria.fr [pharo-project-bounces@lists.gforge.inria.fr] on behalf of Stéphane Ducasse [stephane.ducasse@inria.fr] Sent: Friday, November 25, 2011 4:19 PM To: Pharo-project@lists.gforge.inria.fr Subject: Re: [Pharo-project] ProtoObject basicNew :) On Nov 25, 2011, at 10:09 PM, Toon Verwaest wrote:
Ok, I guess I was confused by your initial question: "the methods that I should define in a subclass of ProtoObject so that I can use basicNew"... :)
:) Yes it is more the methods that I should define to have a usable class (browse, doit, inspect it). I will probably have to do it by try and error. Stef
On 11/25/2011 10:05 PM, Stéphane Ducasse wrote:
I'm confused. I'm not creating a class but an instance. if it would be Behavior basicNew then yes I made sure that we could do Behavior new and not crashing the system back in Squeak.
On Nov 25, 2011, at 9:45 PM, Toon Verwaest wrote:
With the magic number I mean the number that defines the object's structure. It's one of the first 3 instance variables of every class, encoding how many instance variables there are; what kind of object it is supposed to be (normal, array, bytes, words...). Every "class" basically needs 3 instance variables. 1 defines the structure, 1 the superclass, 1 the behavior (method dictionary). I don't know the other; but just look at some class to know what the order is. Yes format, methodDict, superclass (probably in a different order). And format is ugly because not explicit and coded in several place like instSpec (berk)
And yes, if you want to inspect the object, you'll need to support whatever protocol your inspector is using.
The format is formed as follows:
format | fieldSize sizeHiBits format | fieldSize := self fieldSize + 1. sizeHiBits := fieldSize // 64. format := sizeHiBits. format := (format bitShift: 5) + compactClassIndex. format := (format bitShift: 4) + self instanceSpecification. format := (format bitShift: 6) + (fieldSize \\ 64). format := (format bitShift: 1). ^ format
If I read it correctly (just glancing), instance specification specifies if it's arrayed and if it has fields. 0 -> no fields, not arrayed, 1 -> fields, not arrayed, 2 -> arrayed no fields, 3 -> arrayed fields.
HTH, Toon
On 11/25/2011 09:31 PM, Stéphane Ducasse wrote:
Apparently I can do a doit I was naively doing an inspect ;)
Don't you just need the basicNew primitive, and make sure that the "magic number" is set in the object that has the basicNew installed to something that makes sense?
I do not know what is the magic number. I guess that my problem was that I have first to define what is the minimal behavior.
If you want to send messages to the object, probably also best install some dictionary as the method dict instvar.
But I guess that ProtoObject has some behavior since I can browse the class with a browser.
Toon
On 11/25/2011 09:26 PM, Stéphane Ducasse wrote:
Hi I would like to know the methods that I should define in a subclass of ProtoObject so that I can use basicNew. Does any of you have an idea?
Stef
On Nov 26, 2011, at 9:58 PM, Schwab,Wilhelm K wrote:
Stef,
Attached are methods I clearly felt the need to add to ProtoObject. I vaguely recall much trial and even more error :) In my one meaningful (and very little used, due to changing priorities) subclass of ProtoObject, I added #= and #hash. I also customized #printOn:, but that *shouldnt'* be important - caveat emptor :) There are some other finalization related methods, and some "Dolphinization" of events, etc. Again, I don't think those things are crucial outside of my world.
Speaking of Dolphin, two things come to mind. First is protocols, which Dolphin makes concrete and editable. One can define the methods that constitute a protocol, and impose protocols on any number of classes. Any class can implement any number of protocols too. The system then complains if changes cause one or more classes to not understand one or more methods in declared protocols. Pretty slick.
yes this is a cool idea. This is the same as SmallInterfaces http://scg.unibe.ch/archive/papers/Sade02aDynamicInterfaces.pdf I would really like to see how we can use that.
Another thing is the ability to assign multiple categories to any given method. I think that's something one has to have experienced in order to understand how completely useful it can be.
No I can understand it ;)
HTH.
Bill
________________________________________ From: pharo-project-bounces@lists.gforge.inria.fr [pharo-project-bounces@lists.gforge.inria.fr] on behalf of Stéphane Ducasse [stephane.ducasse@inria.fr] Sent: Friday, November 25, 2011 4:19 PM To: Pharo-project@lists.gforge.inria.fr Subject: Re: [Pharo-project] ProtoObject basicNew :)
On Nov 25, 2011, at 10:09 PM, Toon Verwaest wrote:
Ok, I guess I was confused by your initial question: "the methods that I should define in a subclass of ProtoObject so that I can use basicNew"... :)
:)
Yes it is more the methods that I should define to have a usable class (browse, doit, inspect it). I will probably have to do it by try and error.
Stef
On 11/25/2011 10:05 PM, Stéphane Ducasse wrote:
I'm confused. I'm not creating a class but an instance. if it would be Behavior basicNew then yes I made sure that we could do Behavior new and not crashing the system back in Squeak.
On Nov 25, 2011, at 9:45 PM, Toon Verwaest wrote:
With the magic number I mean the number that defines the object's structure. It's one of the first 3 instance variables of every class, encoding how many instance variables there are; what kind of object it is supposed to be (normal, array, bytes, words...). Every "class" basically needs 3 instance variables. 1 defines the structure, 1 the superclass, 1 the behavior (method dictionary). I don't know the other; but just look at some class to know what the order is. Yes format, methodDict, superclass (probably in a different order). And format is ugly because not explicit and coded in several place like instSpec (berk)
And yes, if you want to inspect the object, you'll need to support whatever protocol your inspector is using.
The format is formed as follows:
format | fieldSize sizeHiBits format | fieldSize := self fieldSize + 1. sizeHiBits := fieldSize // 64. format := sizeHiBits. format := (format bitShift: 5) + compactClassIndex. format := (format bitShift: 4) + self instanceSpecification. format := (format bitShift: 6) + (fieldSize \\ 64). format := (format bitShift: 1). ^ format
If I read it correctly (just glancing), instance specification specifies if it's arrayed and if it has fields. 0 -> no fields, not arrayed, 1 -> fields, not arrayed, 2 -> arrayed no fields, 3 -> arrayed fields.
HTH, Toon
On 11/25/2011 09:31 PM, Stéphane Ducasse wrote:
Apparently I can do a doit I was naively doing an inspect ;)
Don't you just need the basicNew primitive, and make sure that the "magic number" is set in the object that has the basicNew installed to something that makes sense?
I do not know what is the magic number. I guess that my problem was that I have first to define what is the minimal behavior.
If you want to send messages to the object, probably also best install some dictionary as the method dict instvar.
But I guess that ProtoObject has some behavior since I can browse the class with a browser.
Toon
On 11/25/2011 09:26 PM, Stéphane Ducasse wrote:
Hi I would like to know the methods that I should define in a subclass of ProtoObject so that I can use basicNew. Does any of you have an idea?
Stef
<ProtoObject-*dolphinCompatibility-idioms.st>
participants (5)
-
Mariano Martinez Peck -
Noury Bouraqadi -
Schwab,Wilhelm K -
Stéphane Ducasse -
Toon Verwaest