in reply to Re: Object Troubles
in thread Object Troubles

This is news to me. Is it something new in 5.6?

++ for you, milkfire, if you update with references explaining how this syntax can break, or at least a few people who have expressed their disapproval.

Update: Aha. I see it now. Thanks to milkfire and chromatic for setting me straight. I hadn't read that far down perlobj and was relying on fading memories of Programming Perl.

++ for all involved, 'cept me of course. ;)

  • Comment on RE: Re: Object Troubles (CMonster: Wrong Way new?)

Replies are listed 'Best First'.
(chromatic) RE: RE: Re: Object Troubles (CMonster: Wrong Way new?)
by chromatic (Archbishop) on Jul 13, 2000 at 19:17 UTC
    It depends on at least two things. First (and most important), that the interpreter knows about the existence of that class before you make that call. Otherwise, the program could die with an 'unquoted bareword' error. That doesn't sound too bad, until you get a few thousand lines in your program and don't remember what gets defined where. Ack.

    The second is a little more obscure, but equally mysterious. Suppose you have an overloaded method somewhere, and you use the indirect syntax (verb object, not object->verb) to call it. What happens if there's a namespace collision? Perl will try for the main::method_name() first, and that'll probably break things.

    Yes, you can program for a long time before running into those kinds of errors, but when you do, you'll wish you'd listened. :)

RE: RE: Re: Object Troubles (CMonster: Wrong Way new?)
by mikfire (Deacon) on Jul 13, 2000 at 19:52 UTC
    It is in perlobj. Search for indirect and read - perlobj describes it better than I can. The essence is that perl's smoke-and-mirrors can get confused when using the indirect syntax and it can be very painful to track down. The wisdom of the elders is to leave it alone.

    mikfire

RE: RE: Re: Object Troubles (CMonster: Wrong Way new?)
by davorg (Chancellor) on Jul 13, 2000 at 19:00 UTC

    mikfire is right that I should have spotted this. As far as I know it's always been a deprecated way to call object methods. I don't have the references with me at the moment, but I'm sure it's discussed in Object Oriented Perl and The Perl Cookbook.

    --
    <http://www.dave.org.uk>

    European Perl Conference - Sept 22/24 2000, ICA, London
    <http://www.yapc.org/Europe/>