class, method, multi keywords #16

Open
rurban opened this Issue Sep 11, 2015 · 0 comments

Projects

None yet

1 participant

@rurban
Member
rurban commented Sep 11, 2015 edited

Parse them into the existing structures.
See https://design.perl6.org/S12.html#multi_Declarations

perl6 creates a longname of the sig types and aliases them to the combined shortname, the proto (aka generic). Their multiple dispatch is the global shortest distance over all argument types, as in Damian's Class::MultiMethods http://cpansearch.perl.org/src/DCONWAY/Class-Multimethods-1.70/tutorial.html with an error if there are equally ranked candidates.
perl6 allows multi subs and methods, plus proto and only prefix keywords. (similar to extern/native). sub is even optional, so they favor multi subs over methods.

for the beginning with cperl only allow it within classes, and favor methods over subs:
allow method only within class {} blocks, to allow stricter and better semantics.
allow sub class{} and class() sub decl and calls, which e.g. is used in B
allow multi (aka generics) outside of class {} blocks.
allow $class: invocant syntax
pass $self onto the signature of methods automatically (?)
add has fields and methods accessor methods
re-implement pseudo-hashes for the internal object layout for the default BUILD
method for class->new objects.
method-dispatch via global shortest distance, as in Class::MultiMethods, seems to be too much overhead and counterintuitive. much better would be a trivial left-to-right shortest distance (via c3 of course) without backtracking. this can be optimized to simple dynamic decision trees embedded into the method op, as in most other efficient method dispatch implementations. (see e.g "Efficient Method Dispatch in PCL", Kiczales, Rodriguez 1990", or the Cecil, profile guided Self-93 or Squeak dispatcher)

See the branch feature/gh16-multi

@rurban rurban added the enhancement label Sep 11, 2015
@rurban rurban self-assigned this Sep 11, 2015
@rurban rurban added this to the v5.24.0 milestone Sep 13, 2015
This was referenced Dec 24, 2015
@rurban rurban modified the milestone: v5.26.0, v5.24.0 May 10, 2016
@rurban rurban added the in progress label Dec 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment