Luke Palmer wrote:
> Jonathan Lang writes:
> > Luke Palmer wrote:
> > > Well, "multi" is no longer a declarator in its own right, but rather
> > > a modifier.  Synopsis & Exegesis 6 show this.  
> > 
> > I don't know about Exegesis 6, 
> 
> Then you should probably read it.  It is the most recent of the
> documents, so what it says is closest to the current thinking. Plus,
> it's a fun read.

OK; I just finished it.  Apparently, there's a distinction between
"multimethod" and "multi sub", and it's a distinction which renders one of
my points invalid.  A multimethod has multiple invocants and handles
dispatching based on the types of said invocants.  A "multi sub" has no
invocants; instead, it has a subset of its parameters (seperated from the
others by a colon) which it uses for dispatching purposes.  As such,
"multi sub ($a: $b) {...}" already has meaning, in that dispatching will
be decided strictly off of $a's type.  

So the following three declarations cover very similar (but not quite
identical) things: 

  multi sub call ($a: $b) {...}
  submethod invoke ($a: $b) {...}
  method check ($a: $b) {...}

All three of these use multiple dispatching.  The only distinctions are
that "invoke" and "check" can be called using method-like syntax, whereas
"call" cannot; and "check" pays attention to inheritence, whereas "call"
and "invoke" do not.  

In the case of multiple "dispatch variables", the situation gets a bit
messier as I understand you:

  multi sub call ($a, $b: $c) {...}
  multi submethod invoke ($a, $b: $c) {...}
  multi method check ($a, $b: $c) {...}

Why do we suddenly need to append the "multi" keyword to "submethod" and
"method"?  Because it has a different meaning for method or submethod:
with "sub", the "multi" keyword means "use multiple dispatching", and so
we use it any time that we have one or more "dispatch parameters"; with
"submethod" and "method", multiple dispatching is assumed and the keyword
means "use more than one invocant".  

IMHO, we should choose one of these definitions for "multi" and stick with
it.  If you go with "use multiple dispatching", multi becomes redundant
for method and submethod; if you go with "allow more than one dispatch
parameter", then you ought to be able to declare a multiply dispatching
sub with a single dispatch parameter without using the multi keyword. 
Personally, I think that the first definition is the less confusing one.  

If you choose it, you'll never have need to use the "multi" keyword in
conjunction with "method" or "submethod", restricting its use in practice
to cases where multiple dispatching doesn't normally occur (subs and
macros, mostly).  In those cases, one _could_ implicitly determine whether
the sub or function is multiply dispatched by looking for the colon in the
signature; but I tend to agree in these cases that requiring the "multi"
keyword might be a good idea.  

=====
Jonathan "Dataweaver" Lang

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

Reply via email to