Re: problams with IO::Socket::INET

Mark Mielke (markm@nortel.ca)
28 Jan 1998 09:59 EST


In message "Re: problams with IO::Socket::INET", 
'tchrist@jhereg.perl.com' writes:
>>ERROR! I'm not even going to read anymore. If you continue to ignore good
>>programming practices you're screwed. If you want i could compile a list of
>>newbie errors and then present them as reasons for why the syntax in perl
>>is wrong. Anybody who chooses to use ambiguous code is stupid.
>>
>>   my $copy = new $type();
>>
>>Get it right.
>
>That's not what the docs say.  Get it right, yourself.

Sorry, saw too many examples of the same mistake and didn't feel like
continuing on :-) In fact i'm still along the thinking that if the ()
isn't there... it's ambiguous and it's an error at compile time... Would
possibly fix those who don't up.

I always use -> syntax except in the case of ->new(). I always use the ()
after the class/object in the case of ->new().

         $object = new X();
         $x = $object->x;

>Nothing in perlobj tells you to use those parens, and a C++ programmer
>isn't going to.  I don't recall being forced to use parens in C++.
>We can't stop people from doing it.  The docs currently lead you down
>a primrose path.

In C++ I always used the (). :-) Well for objects that is. Perhaps that's
why i never hit any of these branches just off the path? :-)

>I developed the syntax for a lot of this, stuff, Mark.  I've *very*
>familiar with it.  For example, I'm the one who first thought about
>CLASS->meth as well as $obj->meth.
>I made some mistakes.  We all did.  I'm sorry for that now.  Don't
>compound the error.

I don't think it's that bad a mistake. It generalizes something that perl
has already supported for some of its internal functions. In fact i have
this stupid thinking that the "print STDOUT ..." should be generalized as
well, allowing a user to inherit from IO::File or similar. Override a few
methods? Now i don't know all the issues involved and i guess if it could
have been done properly it would have... oh well.

So.. how about we fix it? Make this an error:

    $object = new X;

If X is a ClassName or a blessed object tell the user "Your being dangerous,
suggestions are new X() or even safer, X->new()."

>No I/O syntax.  End of Story.  It's just too dangerous.

Pretty please? just for ->new() and with some ()-parser-gum right after?

mark

--                                                  _________________________
.  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|