Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

class, method, multi keywords #16

Closed
rurban opened this issue Sep 11, 2015 · 1 comment
Closed

class, method, multi keywords #16

rurban opened this issue Sep 11, 2015 · 1 comment
Assignees
Milestone

Comments

@rurban
Copy link
Member

rurban commented Sep 11, 2015

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, 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 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 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 modified the milestones: v5.28.0c, v5.26.0c Apr 29, 2017
@rurban
Copy link
Member Author

rurban 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)

Todo:

@rurban rurban closed this as completed Jul 21, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant