Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Do you know where your variables are?
 
PerlMonks  

Re: indirect object in camel book

by John M. Dlugosz (Monsignor)
on Oct 05, 2001 at 22:13 UTC ( [id://117126]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to indirect object in camel book

To prevent ambiguity, write:
new CGI::;
with the trailing :: after the module name.

Replies are listed 'Best First'.
Re: Re: indirect object in camel book
by dragonchild (Archbishop) on Oct 08, 2001 at 14:51 UTC
    Nonononono. This is one reason why the indirect syntax is bad. You want to use the new function provided by the CGI package, right? Then, instead of forcing Perl to do your thinking for you, think for yourself!
    my $cgi = CGI->new;
    Tell Perl which new function you want to use!

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

      I don't see your point. Saying new CGI:: is exactly the same in meaning to CGI->new. That is, you are telling Perl to look at a package named CGI and find the new function using virtual lookup rules.

      Using the ::, the point of my post, makes this syntax unambiguous.

        Yes, new CGI:: is the exact same as CGI->new, in terms of the interpreter.

        However, how do you explain to someone that every single method call you make uses the '->' syntax ... except for the constructor, which doesn't, but instead starts using this (seemingly) random '::' syntax. This isn't the most maintainable concept. What happens if you forget to put the second ':'? The difference between ':' and ';' isn't entirely obvious to a casual glance. In addition, as ':' and ';' are on the same key, mistyping problems are multiplied.

        Essentially, what this boils down to is "Wow, that's a neat way of doing things. I didn't know I could do that. But, why on earth would I want to obfuscate my production code?"

        ------
        We are the carpenters and bricklayers of the Information Age.

        Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://117126]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.