>>>>> "Steve" == Steve Grazzini <[EMAIL PROTECTED]> writes:

Steve> Now, I don't particularly like "$obj->new", but it's not really "wrong"
Steve> either.  If you want to let people call your constructor that way, then
Steve> go ahead and use "ref($proto) || $proto".  And conversely, if you think
Steve> "$obj->new" is an abomination, then just use "my $class = shift".

Steve> But either way, make an informed decision.  Don't cargo-cult it in
Steve> because it's in the examples in perltoot.  And don't cargo-cult it out
Steve> because Randal smacks you whenever you use "ref($proto)" in public.

Well, if you want to obscure your code, go ahead.  But I thought
real world code wasn't about JAPHs and Golf and Obfu-Perl.

So, it has no place in *real world* code. That's all I'm saying.  It
obscures more than it helps, and shouldn't be carbon-copied into every
constructor out of habit.  If you use it, DOCUMENT THE HELL OUT OF IT,
because it comes out of left field.

Note that I have no problem with other method names being used
for both class methods and instance methods.  It's only the highly
overloaded term "new" that I'm referencing here.

In fact, I can make a (albeit weaker) case that "new" is the wrong
name for a constructor anyway, and that constructors should be named
as natural verbs, like DBI's "connect".  But nobody from the C++ camp
would ever support me on that, because their minds are already
corrupt. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to