On Mon, Sep 25, 2000 at 03:50:20PM -0700, Nathan Wiger wrote:
> So I assume you're suggesting that this:
>
> stat->{'mode'}
>
> be a call to stat(), which returns a hashref, but this:
>
> stat->mode
>
> would be a call to the method mode() in the class 'stat'????
>
> That's not how I read RFC 244. If it is, I like it even worse.
I quote:
Currently,
foo->bar($baz)
can be parsed either as C<<'foo'->bar($baz)>>, or as
C<<foo()->bar($baz)>> depending on how the symbol C<foo> was used on
other places. The proposal is to always choose the first meaning: make
C<< -> >> autoquote the bareword on the left.
> You expect a beginner or even intermediate user to wrap their heads around
> that?
I don't see many beginners trying for such shortcuts. I've called methods
on shift, but I don't expect a beginner to try that, and by the time they
do, I expect them to know enough Perl to understand the source of their
errors. This behaviour should be documented. Enough code will be in place
to drive it home.
> Auto-quoting -> is a Bad Idea. Let's not forget there's plenty of ways
> to disambiguate this already!
>
> $stuff = stat::->mode; # class 'stat'
> $stuff = stat()->mode; # function 'stat'
The point is not that it's easy to disambiguate, the point is it's easy for
the construct to be ambiguous. I'm willing to live with stat()->mode if it
means stat->mode always means "call the method mode in the class 'stat'".
> Why should we make Perl any less flexible by default? I just don't get
> it. I've personally never had any problems with this:
>
> $q = CGI->new
>
> Accidentally calling CGI()->new. Has anyone else really? Or is this a
> theoretical concern?
This is not a theoretical concern. If someone, at some point, defines sub
CGI {} your constructor suddenly fails. If you're using something along the
lines of Animal::Bear->new(), and the author of Animal.pm defines a Bear()
method, your constructor suddenly fails. This is action at a distance.
It's a pain.
Michael
--
Administrator www.shoebox.net
Programmer, System Administrator www.gallanttech.com
--