On Mon, Sep 25, 2000 at 04:50:32PM -0700, Nathan Wiger wrote:
> Is just as much of a pain because of action-at-a-distance. Solving this
> problem with highly-specific solutions gains us nothing but more
> syntactic inconsistencies and ambiguities, like these:
>
> stat->{'mode'}
> stat->mode
>
> working massively differently. That's confusing!! It is!!! Really.
Then say stat()->{'mode'} and stat::->mode, if it makes you feel better. Or
better yet, always say stat()->anything when you mean the function call.
Honestly, if you're using both a stat class and a stat function in your
code it's up to you to keep it straight; Perl should make the easy thing
(calling a class method, for certain) easy.
The solutions are:
use bareword 'literals';
# ... lots of intervening code ...
stat->mode; # call the mode method in the class 'stat'
stat->{'mode'}; # you can't dereference a scalar, silly
or
use bareword 'functions';
# ... lots of intervening code ...
stat->{'mode'}; # call stat(), access the mode key
stat->mode; # call stat(), die when it's discovered it isn't an object
or
stat->{'mode'}; # call stat(), access the mode key
stat->mode; # call the mode method in the class 'stat'
The last seems more DWIMish to me.
> We need to step back and fix the *problem*: barewords vs. functions are
> ambiguous. In *all* contexts. Always. You can screw yourself with any of
> these equally:
>
> $SIG{TERM} = IGNORE; # "IGNORE" or IGNORE()?
>
> print output @stuff; # print(output(@stuff))
> # or output->print(@stuff)?
>
> $r = new CGI; # new(CGI) or CGI->new?
> $q = CGI->new; # "CGI"->new or CGI()->new?
>
> $name = first . middle; # "firstmiddle" or
> # first() . middle()?
>
> $total = number + 42; # number() + 42 or
> # "number" + 42?
I only see two action-at-a-distance potentials in the above, the two class
method calls. I addressed everything else, I'm not going to repeat the
list.
> The problem is this: barewords and functions are ambiguous. Always.
> *ALL* contexts.
You keep uttering these absolutes as if the more times you utter them the
more true they'll get. From all of the examples shown the only ambiguity
I've seen is when it comes to class methods.
Michael
--
Administrator www.shoebox.net
Programmer, System Administrator www.gallanttech.com
--