in reply to Constructors Without ->new()

This would make it impossible to have class methods, only instance methods. However, if you don't mind creating new null objects every time you want to call a "class method", I guess that's OK.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re: •Re: Constructors Without ->new()
by ihb (Deacon) on Oct 24, 2003 at 16:04 UTC

    Now now, never say never. Especially not when it comes to Perl.

    It's quite right that Constructor->foo will resolve to Constructor()->foo, but that's not the only way to call a class method. Both

      Constructor::->foo

    and

      'Constructor'->foo

    will be "class method invocation".

    I even prefer to use Constructor::->foo over the one without colons, for reasons explained in Re: Capitalized subroutine names and packages.

    ihb
      Ahh, OK. Cool. I don't like having to call with an explicit hashref though. Maybe make it take a list and turn into a hash if it's not already a hashref. Maybe it does that already... dunno... I'm on a cellmodem link right now and didn't look.

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.