Damien Neil wrote:
> 
> On Thu, Aug 17, 2000 at 03:10:44PM -0700, Steve Fink wrote:
> > My proposal would be what I implemented for perl5 a while back (Sarathy
> > didn't dislike it, but wasn't convinced enough to put it in): all
> > dereferencing can be done with ->.
> >
> > $x->@ is the same as @$x
> > $x->% is the same as %$x
> > $x->@[1,2,3] is the same as @$x[1,2,3]
> > $x->@{a,b,c} is the same as @$x{a,b,c}
> > f()->@ is the same as @{ f() }
> 
> The big objection to this is that this destroys one of the great
> advantages of the current punctuation: the ability to tell the
> context of an expression by examining the first character.
> 
>   @{$foo{@bar{1..20}}
> 
> The above is complex and filled with line noise, but one glance tells
> me that the result is a list.  If you look at your third and fourth
> examples above, the expression context is buried in the middle.  And
> you haven't removed a single character of line noise, either -- indeed,
> you've added two more characters.

I think of -> as a single digraph, so my count is a little better. :-)
But really, providing context is the least of what @{...} does. It's
actually performing a dereferencing _action_. And ->@ visually describes
that better, to my eyes at least. As for the return value, I'd prefer
not to rely on that when I have to examine the entire expression to see
if it really holds anyway -- which I must, because of $x->f().

(I think you meant "return value" where you said "context", since you
don't seem to be talking about f() getting called in list context in
@{f}. Unless you're using a different meaning of the word that perl's
expression contexts.)

The main cleanup this provides is the overloading of {} with both hash
lookup and @{EXPR} dereferencing, which tend to be used in close
proximity. Or at least, it no longer requires it -- I think @{EXPR}
still works better in some situations, like @{ foo() || bar() }.

For completeness, I should mention someone else's suggestion of @<-$x
and @[1,2,3]<-$x->f(). It preserves the
first-character-gives-return-type-in-most-cases property, at the expense
of being (IMHO) really bizarre-looking. I guess it makes for good ASCII
art, though: @<-$x->Q

Reply via email to