class name

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

class name

Lee Breisacher-2
I'm not sure how to handle this. I'm simply doing
    self class name.
and getting (basically) 'name not understood'. But I'm not sure where to implement #name - presumably an instance method in Class - or how to implement it. A "real" Smalltalk has a 'name' inst var on Class, but here in RL 'self class' is..something internal. 

Please advise.

Thanks,

Lee
Reply | Threaded
Open this post in threaded view
|

Re: class name

James Ladd
Ok so name is a method on object and when you check Pharo it is defined like this:

name
    "Answer a name for the receiver.  This is used generically in the title of certain inspectors, such as the referred-to inspector, and specificially by various subsystems.  By default, we let the object just print itself out..  "

    ^ self printString

And printString on object is called which calls printStringLimitedTo: nnn
And that in turn calls 'class name'.

So you need to add the 'name' instance variable to Class and add the name method:

name
    "Answer the name of the receiver."
    name == nil
        ifTrue: [^super name]
        ifFalse: [^name]

Of course this can get Cyclic.

What I need to do is ensure that as part of creating a subclass that the setName: method is called with
the appropriate name. I'll check where this is done, and please can you take care of the rest?

On Fri, Dec 23, 2011 at 6:15 PM, Lee Breisacher <[hidden email]> wrote:
I'm not sure how to handle this. I'm simply doing
    self class name.
and getting (basically) 'name not understood'. But I'm not sure where to implement #name - presumably an instance method in Class - or how to implement it. A "real" Smalltalk has a 'name' inst var on Class, but here in RL 'self class' is..something internal. 

Please advise.

Thanks,

Lee

Reply | Threaded
Open this post in threaded view
|

Re: class name

Lee Breisacher-2
" ensure that as part of creating a subclass that the setName: method is called "

Yes, that's the part I was unclear about. I can take care of the rest. 
Reply | Threaded
Open this post in threaded view
|

Re: class name

James Ladd
I'm looking at class names now. Will work through and post .a.s.a.p

On Fri, Dec 23, 2011 at 7:18 PM, Lee Breisacher <[hidden email]> wrote:
" ensure that as part of creating a subclass that the setName: method is called "

Yes, that's the part I was unclear about. I can take care of the rest.