This file is automatically generated. If you wish to submit a PR, do not
edit this file directly. Please edit
templates/rfc/major-changes.md instead. Use bin/generate_rfc.pl
to regenerate the RFCs.
Due to the fast-moving nature of this project, we won't note every little change to the RFC. You can always clone the repo and read the commits. Instead, we'll cover major changes here.
field
attributes are now formally known as attributes. Previously this was ambiguous. The grammar and RFCs have been updated to reflect this.
- Injected
$class
and$self
variables are now documented as being immutable. That prevents this bug:
method foo () {
$self = 42;
}
- Class data and methods are agreed to be declared with
:common
field $foo :common; # class data
method bar :common () { ... } # class method
-
Class data (declared with
:common
can accept defaults (see the next change) and only allows the:reader
attribute with it. -
Field initialization no longer allows
=
. You must wrap the default in curly braces (an anonymous sub). This is because of this problem:
field $colors = [qw/blue white red/];
Every $color
would get a reference to the same anonymous array. Instead, write
it like this:
field $colors { [qw/blue white red/] };
With that, you can change the colors of a particular instance without changing
the others. Yes, you could do $foo = [qw/blue white black/]'
in a method,
but if someone did $foo->[-1] = 'black';
, they might wonder why all other
instances had their value changed.
We realize this change might seem strange, but we're hopeful people will get used to it.
As of this writing, we do not plan to inject $class
or $self
into that
block. That avoids this bug:
field $color { $self->get_colors };
Because initialization happens when the instance construction might not be complete, some fields may not be properly defined, leading to obscure bugs.
- After considerable discussion,
slot
has been renamed tofield
. A few people objected to "slot" because it's an unusual term (borrowed from Lisp). Some non-native English speakers pointed out that "slot" is also harder for them to understand, while "field" is very clear. There was discussion about confusion with the little-used "fields" pragma, but it was generally agreed this would be unlikely.
- We have removed the special
:handles(*)
syntax. It was proving too problematic and, in fact, would not have allowed us to simulate inheritance because once you enter the delegate, you can't override its methods because it's not in your inheritance hierarchy.
- Clarify that the
:handles(*)
delegation will not auto-delegate to methods beginning with underscores to avoid those becoming part of the public interface. Of course, internally you can still call those methods directly on the slot variable calling the object.
- After many suggestions from Paul Evans and later by Damian Conway, Corinna has been switched over to KIM (Keyword, Identifier, Modifier) syntax. See also Damian Conway's post on the topic.
- Method modifiers RFC section added.
- Classes documentation now shows we use any legal version numbers, not just semver triples.
- Abtract methods in classes and required methods in roles are no longer allowed to declare their argument lists. This gives us room to reconsider this behavior post-MVP.
:name
attribute for slots removed from MVP. Might be returned later.- Version numbers no longer limited to semver. All current Perl version formats intended to be supported.
- Classes which both inherit and consume roles must now declare the parent before the roles (previously, the order was not relevant).
- Method access levels such as
common
,private
, andoverrides
are now attributes that come between the method name and the argument list:
method foo :overrides ($bar, $baz) { ... }
- Class slots now declared with
my
. They do not take attributes.
- Slot declaration keyword renamed from
has
toslot
- First draft of RFC released as markdown in github repo so that pull requests can be received. Wiki is noted to primarily be of historical interest.