Skip to content

Commit 60f7e78

Browse files
author
Ovid
committed
Remove the :version attribute.
1 parent 77ee921 commit 60f7e78

File tree

4 files changed

+36
-46
lines changed

4 files changed

+36
-46
lines changed

rfc/classes.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ say Person->num_people; # 0
113113
`ADJUST` and `DESTRUCT` are [phasers](phasers.md).
114114

115115
## 4.2.1 Versions
116-
Just add the version number after the class name as a `:version(...)`
117-
attribute. This should accept any standard version number.
116+
Just add the version number after the class name. This should accept any
117+
standard version number.
118118

119119
```perl
120-
class My::Class :version(3.14) {
120+
class My::Class 3.14 {
121121
...
122122
}
123123
```
@@ -128,7 +128,7 @@ optionally add a version number to the name of the class you're inheriting
128128
from to show the minimum allowed version of the class.
129129

130130
```perl
131-
class Customer :isa(Person 3.14) :version(v2.1.0) {
131+
class Customer v2.1.0 :isa(Person 3.14) {
132132
field $customer_id :param;
133133

134134
method name :overrides () {
@@ -207,7 +207,7 @@ say $customer->to_string(); # Ford Prefect (#42)
207207
Multiple roles may be consumed.
208208

209209
```perl
210-
class Customer :isa(Person) :does(RoleStringify, RoleJSON) :version(v1.2.3) {
210+
class Customer 1.2 :isa(Person) :does(RoleStringify, RoleJSON) {
211211
...
212212
}
213213
```

rfc/overview.md

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,14 @@ roles):
211211
```perl
212212
use feature 'class';
213213

214-
class Cache::LRU :version(v0.1.0) {
214+
class Cache::LRU v0.1.0 {
215215
use Hash::Ordered;
216216
use Carp 'croak';
217217

218-
field $num_caches :common { 0 };
219-
field $cache :handles(exists delete) { Hash::Ordered->new };
220-
field $max_size :param :reader { 20 };
221-
field $created :reader { time };
218+
field $num_caches :common = 0;
219+
field $cache :handles(exists delete) = Hash::Ordered->new;
220+
field $max_size :param :reader = 20;
221+
field $created :reader = time;
222222

223223
ADJUST { # called after new()
224224
$num_caches++;
@@ -230,23 +230,18 @@ class Cache::LRU :version(v0.1.0) {
230230

231231
method num_caches :common () { $num_caches }
232232

233-
method set ( $key, $value ) {
234-
if ( $self->exists($key) ) {
235-
$self->delete($key);
233+
method set( $key, $value ) {
234+
$cache->unshift( $key, $value ); # new values in front
235+
if ( $cache->keys > $max_size ) {
236+
$cache->pop;
236237
}
237-
elsif ( $cache->keys > $max_size ) {
238-
$cache->shift;
239-
}
240-
$cache->set( $key, $value ); # new values in front
241238
}
242239

243240
method get($key) {
244-
if ( $self->exists($key) ) {
245-
my $value = $cache->get($key);
246-
$self->set( $key, $value ); # put it at the front
247-
return $value;
248-
}
249-
return;
241+
return unless $cache->exists($key);
242+
my $value = $cache->get($key);
243+
$self->unshift( $key, $value ); # put it at the front
244+
return $value;
250245
}
251246
}
252247
```

templates/rfc/classes.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ say Person->num_people; # 0
103103

104104
## Versions
105105

106-
Just add the version number after the class name as a `:version(...)`
107-
attribute. This should accept any standard version number.
106+
Just add the version number after the class name. This should accept any
107+
standard version number.
108108

109109
```perl
110-
class My::Class :version(3.14) {
110+
class My::Class 3.14 {
111111
...
112112
}
113113
```
@@ -119,7 +119,7 @@ optionally add a version number to the name of the class you're inheriting
119119
from to show the minimum allowed version of the class.
120120

121121
```perl
122-
class Customer :isa(Person 3.14) :version(v2.1.0) {
122+
class Customer v2.1.0 :isa(Person 3.14) {
123123
field $customer_id :param;
124124

125125
method name :overrides () {
@@ -199,7 +199,7 @@ say $customer->to_string(); # Ford Prefect (#42)
199199
Multiple roles may be consumed.
200200

201201
```perl
202-
class Customer :isa(Person) :does(RoleStringify, RoleJSON) :version(v1.2.3) {
202+
class Customer 1.2 :isa(Person) :does(RoleStringify, RoleJSON) {
203203
...
204204
}
205205
```

templates/rfc/overview.md

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,14 @@ roles):
209209
```perl
210210
use feature 'class';
211211

212-
class Cache::LRU :version(v0.1.0) {
212+
class Cache::LRU v0.1.0 {
213213
use Hash::Ordered;
214214
use Carp 'croak';
215215

216-
field $num_caches :common { 0 };
217-
field $cache :handles(exists delete) { Hash::Ordered->new };
218-
field $max_size :param :reader { 20 };
219-
field $created :reader { time };
216+
field $num_caches :common = 0;
217+
field $cache :handles(exists delete) = Hash::Ordered->new;
218+
field $max_size :param :reader = 20;
219+
field $created :reader = time;
220220

221221
ADJUST { # called after new()
222222
$num_caches++;
@@ -228,23 +228,18 @@ class Cache::LRU :version(v0.1.0) {
228228

229229
method num_caches :common () { $num_caches }
230230

231-
method set ( $key, $value ) {
232-
if ( $self->exists($key) ) {
233-
$self->delete($key);
231+
method set( $key, $value ) {
232+
$cache->unshift( $key, $value ); # new values in front
233+
if ( $cache->keys > $max_size ) {
234+
$cache->pop;
234235
}
235-
elsif ( $cache->keys > $max_size ) {
236-
$cache->shift;
237-
}
238-
$cache->set( $key, $value ); # new values in front
239236
}
240237

241238
method get($key) {
242-
if ( $self->exists($key) ) {
243-
my $value = $cache->get($key);
244-
$self->set( $key, $value ); # put it at the front
245-
return $value;
246-
}
247-
return;
239+
return unless $cache->exists($key);
240+
my $value = $cache->get($key);
241+
$self->unshift( $key, $value ); # put it at the front
242+
return $value;
248243
}
249244
}
250245
```

0 commit comments

Comments
 (0)