Tom Christiansen wrote:
> 
> You pretend that a reference is not a "true" scalar.
> That's certainly not valid.  It obviously is.

Well, this is a matter of semantics, pure and simple. Technically, it
is. But I would argue that cognitively it is not by any means.
Especially if a reference points to an array or hash or object, all of
which contain multiple things and properties.

The argument that "it points to one thing" is fallacious, IMO. If we
extend this argument, then @ and % are superfluous and should be
dropped, since they point to single arrays and hashes. But they're not,
and pointing to @ and % with a $ is strange. I'm used to it, but it's
still strange.
 
> I happen to strongly appreciate that the invocant in
> 
>     $a->blah
> 
> can be of either sort; that is:
> 
>     $a = "MyClass";
>     $a->blah;
> 
> or
> 
>     $a = MyClass->generate();
>     $a->blah();
> 
> In fact, who knows what generate() returned?  It could have
> been a class name.

Outstanding point. You're right, this RFC would make not caring about
this impossible. And this is an important issue.

However, consider this in a different light for a moment:

   $a = "MyClass";
   *a = MyClass->generate;   # ask for ref back
   $a->blah;
   *a->blah;                 # use our ref

Whether or not having to care about your refs is good or bad depends on
which way you look at it. In one case, it's bad if you don't want to
have to care at all. On the other hand, what if you don't want to care,
and MyClass->generate returns "5"? This probably won't work. So you do
want to care, at least a little, and * helps with this by doing implicit
ref sanity checks for you.

For example, here you know roughly what you're addressing:

   $a[0][1]      # element of array
   $h{key}       # element of hash

Why not make that easier still?

   print $this   # "true" scalar
   *a[0]->func   # first element (ref) of @a
   *h{key}->func # key element (ref) of %h

You can already tell hashes and arrays apart, why not references vs.
simple scalars?

> You introduce bizarre *foo[$i] syntax.  Why should that be
> any different than $foo[$i]?

First, just because it's new doesn't necessarily make it bizarre. :-)
The only syntactic difference between the two is the prefix - * vs. $.
The * is used to explicitly address a reference, just like @ explicitly
addresses an array.

It's also less obtuse that this, since -> connotes an "action" to many:

   $hash{key}       # non-action
   $$hash{key}      # non-action
   $hash->{key}     # action??
   $*hash{key}      # non-action

Some will claim that "dereferencing" is the action. So why doesn't the
second one have a ->? This is inconsistent. The use of a * to specify
references makes them explicit and easy to see, instead of inferred.

I'm not arguing this is the solution to the world's problems. What I
*am* arguing is that it's something worth pondering, especially since
there are at least 4 other RFC's claiming that "prefixes are useless"
for the reasons I mention in the RFC. Rather than just saying "drop
'em!", I'm proposing something which I think could potentially improve
their usefulness.

-Nate

Reply via email to