in reply to Re: OO style: Placement of "new"
in thread OO style: Placement of "new"

A blanket prohibition like this is as unwarranted as forbidding the use of $_ on the assertion that it is obfuscation. I use the indirect syntax for constructor calls almost exclusively and I have never encountered the problems described in perlobj.

crenz, use whatever form suits your tastes or the coding style your project settles upon, and allow the constraints of a particular situation to guide your selection of syntax.


"The dead do not recognize context" -- Kai, Lexx

Replies are listed 'Best First'.
•Re: Re: Re: OO style: Placement of "new"
by merlyn (Sage) on Apr 08, 2003 at 04:22 UTC
    Well, maybe you haven't, but that doesn't mean nobody hasn't, because I have. So it happens in real code.

    Don't use IO notation. It was an interesting experiment, but it failed.

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

      Bad things happen in real code all the time, and it's not an argument for the wholesale banishment of certain tools/techniques, but rather a case for better education. In this example, the possible errors are easily obviated by a correct choice of syntax given a very particular set of conditions. If the list parsing is getting munged using indirect invocation, then use direct invocation, or employ parentheses appropriately.

      Respectfully, I must say I'm surprised that so many old timers would argue to avoid a feature whose negative consequences are so easily corrected.


      "The dead do not recognize context" -- Kai, Lexx
        but rather a case for better education
        The "better education" you are asking for is what we are telling you. "Don't use IO notation - it's broken, at unpredictable times for the lay user".

        The precise definition of when it is broken requires an understanding of the symbol table and things seen so far in the current compilation unit. Since direct-object notation always works, and indirect-object notation is sometimes broken at hard-to-describe times, what's wrong with a wholesale ban?

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