Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Getting rid of "new", Implied actions are bad

by cerelib (Novice)
on Jul 07, 2006 at 21:41 UTC ( [id://559870]=note: print w/replies, xml ) Need Help??


in reply to Getting rid of "new"

The "new" convention seems logical and the same goes for "spawn" or "create". The problem with your idea is that it lacks a verb. I will grant you that "new" it not an English verb, but it is a Perl verb. Without a verb, your statement "Some::Other::Class( \%options )" has no visible action although one is being performed. For that reason alone it goes against many design decisions of Perl itself. In Perl there are visual cues to help you understand what you are seeing. A scalar looks like a scalar '$', an array looks like an array '@', and so on. To this extent an action looks like an action in the direct form 'Class->new', the indirect 'new Class', or with the implied subject 'new' (this is the most deceptive of the three). That last one may look like it justifies your idea, but what you want is an explicit subject with an implied action. So, I think the implied constructor is a bad decision. It will lead to more confusing code. If you really hate "new", get with the people responsible for Class::Struct and talk to them about changing naming conventions.
  • Comment on Re: Getting rid of "new", Implied actions are bad

Replies are listed 'Best First'.
Re: Implied actions are bad
by HuckinFappy (Pilgrim) on Jul 09, 2006 at 03:25 UTC
    Without a verb, your statement "Some::Other::Class( \%options )" has no visible action although one is being performed

    And heaven help the poor fool who has to maintain it when it becomes this:

    my $foo = Some::Other::Class( code => sub { DoThingsWith( $_[0] ) } );
    In the previously mentioned absence of a verb, someone is definitely going to think the action comes from DoThingsWith()....

    But I'd be the last person in the world to discourage a Very Cool, if Quite Tricky Idea. It's cleverness personified, and I don't care what The Damian says...cleverness has a place in the world!

    Put it in Acme please, so nobody I code with uses it :)

    ~Jeff

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://559870]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (7)
As of 2024-04-19 09:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found