---------- Forwarded message ---------- From: Igor Stasenko <[email protected]> Date: 19 May 2013 06:11 Subject: Re: NB primitives inheritance To: [email protected], Pharo Development <[email protected]>
On 19 May 2013 04:26, Ciprian Teodorov <[email protected]> wrote: > yep I agree with your arguments... what about selfInstance (because on the > class side 'self' means the current class, and Instance will make us think > that is an instance of it)? > i don't know.. maybe 'newInstance' then? i wish i could find a name which is short and precise enough to express what is behind it. (i cc to Pharo-dev list, asking for help). > > On Sun, May 19, 2013 at 3:11 AM, Igor Stasenko <[email protected]> wrote: >> >> On 18 May 2013 22:26, Ciprian Teodorov <[email protected]> wrote: >> > >> > >> > On Thursday, March 21, 2013 12:54:23 PM UTC+1, Igor Stasenko wrote: >> >> >> >> On 21 March 2013 12:21, Ciprian Teodorov <[email protected]> wrote: >> >> > >> >> > On Mar 21, 2013 12:03 PM, "Igor Stasenko" <[email protected]> wrote: >> >> >> >> >> >> On 5 March 2013 22:38, Ciprian Teodorov <[email protected]> >> >> >> wrote: >> >> >> > Yeah traits seem to work nicely... >> >> >> > >> >> >> does self works that way (as return type)? >> >> >> >> >> >> never tried nor intended it to work. >> >> >> But yeah, you found a nice use case :) >> >> >> >> >> > If i remember correctly, self as return type does not work >> >> > directly... >> >> > Though we can make it work easily(just a little patch on return type >> >> > parsing) however just doing that raises inheritance problems, since >> >> > in >> >> > the >> >> > generated code we will have a hard coded class. >> >> > So that explains my initial question? How can we get around this, and >> >> > have >> >> > diferrent classes instantiated depending on the receiver of the call >> >> > >> >> yeah.. >> >> you want a single method which serves to instantiate different >> >> subclass instances. >> >> >> >> 'self' as return type can do that.. At least for pointer-type objects >> >> (no variable objects) >> >> you can instantiate them based on receiver (since the method is on >> >> class side, the receiver is the class to instantiate). >> >> >> >> I would modify NBExternalObjectType to: >> >> 1. add a flag, to use receiver of method for instantiation >> >> 2. modify #coerceReturnValue: to generate different code when flag is >> >> true. >> >> >> >> 3. setting this flag to true in NBFFICallout>>returnType:, if: >> >> - type name is 'self' >> >> - method belongs to class side >> >> - method's class is a subclass of NBExternalObject >> >> >> > Hi all, >> > I've just commited an implementation of this receiver-based >> > instantiation in >> > NativeBoost-Core-CiprianTeodorov.123. >> >> >> >> (but im not sure that using 'self' to denote that type is good idea, >> >> maybe using different name will be better). >> >> >> > Igor since you were not sure about using 'self' as type I called it >> > 'receiver'... What do you think? >> > >> >> I think this having same problem as with 'self'. >> What prevents me (or someone else) to think that 'self' or 'receiver' >> special type >> means "disregard a function return value, and answer a receiver of >> message as a primitive result, e.g. >> equivalent to: >> >> someMethod: args >> >> ... do something. ... >> >> ^ self >> >> I think 'receiverClass' is better.. but still ambiguous: does it means >> "answer the class of receiver" >> or "create an new instance of same class as receiver?" >> >> What about, 'receiverClassInstance'? It is very precise, which i >> like.. but it looks too long , which i don't like. >> :) >> >> > for example: >> > if we have two classes NPointB as subclass of NPointA and: >> > >> > NPointA class>>x: x y: y >> > <primitive: 'primitiveNativeCall' module: 'NativeBoostPlugin' error: >> > errorCode> >> > ^self nbCallout >> > function: #(receiver PointCreate(int x, int y)) module: self >> > nbLibraryNameOrHandle >> > >> > NPointA x: 3 y: 4. "creates instance of NPointA" >> > NPointB x: 5 y: 6. "creates instance of NPointB" >> > >> > cheers, >> > >> >> >> >> -- >> >> Best regards, >> >> Igor Stasenko. >> >> >> >> -- >> Best regards, >> Igor Stasenko. > > > > > -- > Dr. Ciprian TEODOROV > Ingénieur Développement CAO > > tél : 06 08 54 73 48 > mail : [email protected] > www.teodorov.ro -- Best regards, Igor Stasenko. -- Best regards, Igor Stasenko.
