develooper Front page | perl.perl6.language | Postings from April 2003

Re: S6 multimethod invocants

Thread Previous | Thread Next
From:
Uri Guttman
Date:
April 11, 2003 14:17
Subject:
Re: S6 multimethod invocants
Message ID:
x73ckoom0h.fsf@mail.sysarch.com
>>>>> "P" == Paul  <ydbxmhc@yahoo.com> writes:

  >> Next, you don't want . at all, unless you want to try single
  >> dispatch first and then fall back on multimethod dispatch. You
  >> typically call a multimethod as if it were a sub:
  >> 
  >> foo($o, 1);     # calls version 1
  >> foo($o, qw/ this  calls version 2 /);
  >> foo($o, $x,@y); # calls version 3

  P> Huh? Why? And could you elaborate "try single dispatch first and then
  P> fall back on multimethod dispatch"? Suddenly I feel stupid again. :)

well, if there is a plain sub foo declared in scope (or whatever) it
will be called regardless of any multi foo declarations. if none is
found then a search for multi foo's will be done and multidispatch will
pick the 'best' one to call.

as for feeling stupid again, it is all part of the p6 game and we are
all players. :)

  P> Probably Scalar rather that Str, yes?
  P> Speaking of which, can we typecast?

  P>   my @a = String qw/ 1 2 3 / ;

  P> Looks bogus to me, but the effect could come in handy. Maybe

  P>   my String @a = 1..3; 

  P> is better?

i think that should be:

	my @a of Str = 1..3; 

maybe that is just a synonym for your version. i am still (in)digesting
A6/S6. :)

@a is not a Str but its elements are.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About