GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  SUB::MULTI (3)

.ds Aq ’

NAME

Sub::Multi - Data::Bind-based multi-sub dispatch

CONTENTS

SYNOPSIS



 my $multi_sub = Sub::Multi->new($sub1, $sub2, $sub3);



Now dispatch to the right subroutine, based on @args.



 $multi_sub->(@args);



DESCRIPTION

Perl6 allows multiple subs and methods with the same name, differing only in their signature.



    multi sub bar (Dog $foo) {?}
    multi sub bar (Cat $foo) {?}



Dispatching will happen based on the runtime signature of the subroutine or method call.

    new



 my $multi_sub = Sub::Multi->new($sub1, $sub2, $sub3);
 $multi_sub->(@args);



Build and return a code reference that will dispatch based on the Perl6 multi dispatch semantics.

TODO: Verify this statement: Before the method is actually dispatched, a call to Data::Bind->sub_signature should be made to register the subroutine signature.

    add_multi



  my $multi_sub  =  Sub::Multi->add_multi($sub_name, \&sub );
  $multi_sub->(@args);



Associates $sub_name with \&sub, and returns code reference that will dispatch appropriately. add_multi can be called multiple times with the same $sub_name to build a multi-dispatch method.

TODO: Verify this statement: Before the method is actually dispatched, a call to Data::Bind->sub_signature should be made to register the subroutine signature.

SEE ALSO

Data::Bind

<B>TODO: B> Add a good reference to Perl6 multiple dispatch here.

AUTHORS

Chia-liang Kao <clkao@clkao.org>

COPYRIGHT

Copyright 2006 by Chia-liang Kao and others.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See <http://www.perl.com/perl/misc/Artistic.html>

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 SUB::MULTI (3) 2007-03-20

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.