> -----Original Message-----
> From: Larry Wall [mailto:[EMAIL PROTECTED]
>
> On Fri, Apr 23, 2004 at 01:15:51PM -0400, Austin Hastings wrote:
> : A12 sez:
> :
> :   If your delegation object happens to be an array:
> :
> :     has @:handlers handles 'foo';
> :
> :   then something cool happens. <cool rays> In this case
> :   Perl 6 assumes that your array contains a list of potential
> :   handlers, and you just want to call the first one that
> :   succeeds.
> :
> : This is not clear, and I'm not liking it at the moment anyway.
> It has the
> : effect of saying:
> :
> : "If you HAS-A attribute that is an array, you cannot delegate
> to it, but if
> : you IS-A array, no worries."
> :
> : So Queue classes that start out:
> :
> :   class Queue is Array {...}
> :
> : can get push/pop/splice whatever methods for free, but:
> :
> :   class Queue is PersistentObject
> :   {
> :     has @:elements handles «push pop splice»;
> :
> : can not work (unless one of the things inside @:elements
> happens to be an
> : array).
>
>     has $:elements handles «push pop splice»;
>
> can hold an array in that case.

This surprises me.

case 1:s
  has $:obj handles 'a';
  $:obj = new Foo;
  $self.a(); # Foo::a

case 1:n
  has $:obj handles 'a';
  $:obj = «new» (Foo, Bar, Baz);
  $self.a(); # one(Foo::a, Bar::a, Baz::a)

case 1:a
  has $:obj handles 'a';
  $:obj = «new» (Foo, Bar, Baz);
  $self.a(); # Array::a


case a:n
  has @:obj handles 'a';
  @:obj = «new» (Foo, Bar, Baz);
  $self.a(); # one(Foo::a, Bar::a, Baz::a)

case a:a
  has @:obj handles 'a';
  @:obj = «new» (Foo, Bar, Baz);
  $self.a(); # Array::a

I guess I'm more strongly attached to the sigil than I realized. IMO, if you
have

  $obj handles 'a';

and put an arrayref in $obj, then you get what's coming: iteration. But if
you have

  @obj handles 'a';

then you know it's an array, or array subtype, and delegate array-things to
it.

So I prefer cases 1:s, 1:n, and a:a instead of 1:s, 1:a, and a:n.

> : Also, it's not clear:
> :
> :   "first one that succeeds"
> :
> : Does that mean "First one for which a matching method exists" or does it
> : mean "First one for which a method exists that does not C<fail>
> or return
> : undef or some other badness"?
>
> The latter is the intent.

Then array handling is doing some sort of .+method dispatch instead of
"plain old dispatch", no?

I think this should be made explicit. At first glance, I'd hate to lose
C<return undef;> or C<return FALSE;> as an option just because than means
"keep searching for handlers".

Can you tell us why the initial spec calls for continuing search?

=Austin

Reply via email to