Re: problams with IO::Socket::INET

Mark Mielke (markm@nortel.ca)
27 Jan 1998 23:30 EST


In message "Re: problams with IO::Socket::INET", 
'tchrist@jhereg.perl.com' writes:

>>As well, C++ and Java require you to use new(). I know that's not a
>>bulletproof reason, but it makes it more obvious to someone who has
>>never used the class in question before.
>
>That's a good reason not to.  Perl's constructors are very 
>different.  They don't call overridden versions.  They have 
>to allocate memory.  etc.  Better not to deceive.

Implementation of objects and interfaces to objects are different things.
In C++/Java, the allocation is hidden from the class author. In perl,
the author of the class must allocate the object themselves.

The methods of an object are its interface to the users. The users could
care less how ->new() works internally. They just want their object.
As well, writers of Java/C++ code will be most familiar with the possibly
deceiving ->new() interface, but i don't really see where it would cause
problems? Perhaps i'm blinded by my own preferences :-)

mark

P.S. The level of abstraction that a generic constructor name offers
     is _in general_ a good thing. In my opinion. <P> I've seen classes that
     use some variant of open() as a constructor method. I find it confusing.

     Now what i'm really wishing existed was a _generic_ version of TomC's
     delegation object model. I want the derived class data type (hash,etc.) to
     be completely independant of the implementation of the base class. And
     i don't want to have an AUTOLOAD() sub{} in each of my classes. But i can
     tell this won't happen anytime soon :-) See with this kind of model, we
     _could_ have the constructor for each class (including MI) run properly.
--                                                  _________________________
.  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|