Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^5: Perl "new" command

by nemesdani (Friar)
on Mar 01, 2012 at 12:42 UTC ( #957199=note: print w/ replies, xml ) Need Help??


in reply to Re^4: Perl "new" command
in thread Perl "new" command

Well, if I had to, I'd name it a multiple constructor. I would find it a "silly and confusing" way to do things ;). I read that definition in the Perl documentation by the way.


Comment on Re^5: Perl "new" command
Re^6: Perl "new" command
by JavaFan (Canon) on Mar 01, 2012 at 12:54 UTC
    So, a subroutine that creates a couple of objects, none of which survive the life time of said subroutine, and which returns an integer, is a "multiple constructor", but it's also "silly and confusing"?

    I find both your classifications of the subroutine not very useful.

      1. I just stated originally, that there is no built in new function in Perl.
      2. I totally agree with you, that Perl's approach is very dangerous, but it doesn't change the fact, that - by the documentation I read - a constructor is simply a sub, that returns a blessed reference.
      If not so, please point me towards the correct documentation, I am not a seasoned Perl veteran.
        a constructor is simply a sub, that returns a blessed reference.
        Note that's not what you said before. There you said:
        I thought a constructor is any routine that calls the bless operator.
        which I find a silly and confusing term.

        BTW, just because something is mentioned in the documentation doesn't mean 1) it's useful, 2) it's true, or 3) I agree with it.

        a constructor is simply a sub, that returns a blessed reference.
        Even if that's in the documentation, that's also a silly and confusing term:
        my foo {$_[0]} use CGI; my $obj = CGI::->new; foo($obj);
        foo returns a blessed reference. Is it useful to call it a constructor?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2015-07-05 02:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls