Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

class, method, multi keywords #16

rurban opened this issue Sep 11, 2015 · 1 comment


None yet
1 participant
Copy link

commented Sep 11, 2015

Parse them into the existing structures.

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 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, but not with :method attributes, only method declarations.
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)
classes can have the :native attribute, to layout the hash fields as in C, to be used as native structs for the ffi.

fail at 'Invalid method call on class subroutine' and vice versa 'Invalid subroutine call on class method'.
warn on redefining packages as classes, as classes are more restrictive.
when redefining classes as packages it will fail at the readonly stash.

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 milestones: v5.26.0, v5.24.0 May 10, 2016

@rurban rurban added the in progress label Dec 1, 2016

@rurban rurban removed this from the v5.26.0c milestone Mar 2, 2017

@rurban rurban added this to the v5.26.0c milestone Mar 30, 2017

@rurban rurban added ready and removed in progress ready labels Mar 30, 2017

@rurban rurban modified the milestones: v5.28.0c, v5.26.0c Apr 29, 2017


This comment has been minimized.

Copy link
Member Author

commented Jul 18, 2017

  • class, method, role, multi syntax done with e3d7df1
  • fields (has) mostly done with 476edcc (only scalars, or assignment as a whole)


  • oelemfast optim #309
  • oelem tests (computed field names) #310
  • compose role methods (2 days, different pad) #311
  • use mro on classes #312
  • multi dispatch (2 weeks) #313
  • has @field[] %field{} syntax (2 days) #316
  • :before, :after, :around composition(4 days) (#98)
  • class :native (1 week) #314
  • class :open (if needed, package {} should be enough) (1 day) #315

@rurban rurban closed this Jul 21, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.