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>