in reply to Re: How to call Class method inside an object?
in thread How to call Class method inside an object?
In Smalltalk, classes are objects. As objects they have methods. Those methods are the class methods.
Instances of the class are objects. As objects they have methods. Those methods are instance methods.
Since the class and the instance are different objects, and moreover different kinds of objects, it comes as no surprise that they have different methods.
None of this is applicable in Perl, of course, since Perl packages are not objects. (Simon Cozens wanted to make that possible, but last I heard it got vetoed as potentially breaking too much old code.) But in languages where classes are themselves objects, the Smalltalk terminology is how you should think about things. And people who come from languages like that (for instance merlyn) tend in Perl to like distinguishing between methods that are meant to be called through the name of the class (eg new) and those that are called from an instance (everything else).
Which is why I, along with merlyn, dislike the construct you sometimes see of:
Its purpose is to blur the distinction between methods of the class and methods of instances of the class, and we see no reason that that distinction is a bad thing to have.my $pkg = ref($self) || $self;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re (tilly) 2: How to call Class method inside an object?
by chromatic (Archbishop) on Apr 27, 2001 at 23:24 UTC | |
by tilly (Archbishop) on Apr 28, 2001 at 20:42 UTC |