Skip to content

Commit

Permalink
Fix up various return type constraints in teh built-ins.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Jun 5, 2009
1 parent 636a2b6 commit 7a40779
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/setting/Any-num.pm
Expand Up @@ -47,7 +47,7 @@ class Any is also {
}
# Used by the :Trig subs and methods in the Int and Num classes.
our Int multi method !to-radians($base) {
our Num multi method !to-radians($base) {
given $base {
when /:i ^d/ { self * pi/180 } # Convert from degrees.
when /:i ^g/ { self * pi/200 } # Convert from gradians.
Expand All @@ -57,7 +57,7 @@ class Any is also {
}
}

our Int multi method !from-radians(Num $x, $base) {
our Num multi method !from-radians(Num $x, $base) {
given $base {
when /:i ^d/ { $x * 180/pi } # Convert to degrees.
when /:i ^g/ { $x * 200/pi } # Convert to gradians.
Expand All @@ -68,7 +68,7 @@ class Any is also {
}
}

our Int sub rand (*@args) {
our Num sub rand (*@args) {
die "too many arguments passed - 0 params expected" if @args;
1.rand
}
19 changes: 11 additions & 8 deletions src/setting/Range.pm
Expand Up @@ -6,14 +6,14 @@ class Range is also {
has $.to_exclusive = Bool::False;

our Bool multi method ACCEPTS(Range $topic) {
($.from == $topic.from) && ($.to == $topic.to) &&
($.from_exclusive == $topic.from_exclusive) &&
($.to_exclusive == $topic.from_exclusive) &&
($.by == $topic.by)
?(($.from == $topic.from) && ($.to == $topic.to) &&
($.from_exclusive == $topic.from_exclusive) &&
($.to_exclusive == $topic.from_exclusive) &&
($.by == $topic.by))
}

our Bool multi method ACCEPTS($topic) {
self!from_test($topic) && self!to_test($topic)
?(self!from_test($topic) && self!to_test($topic))
}

our Range multi method iterator() {
Expand Down Expand Up @@ -54,15 +54,18 @@ class Range is also {
}
}

our Range multi method reverse() {
our #(Range) multi method reverse() {
# XXX Should eventually return a reversed Range.
@.list.reverse;
}

our Bool multi method true() {
our #(Bool) multi method true() {
# XXX For some reason, simply ?-ing what follows does not fix the
# return type to Bool. Needs investigating...
self!to_test($.from_exclusive ?? ++($.from.clone) !! $.from)
}

our Str multi method Str() {
$.list
~$.list
}
}

0 comments on commit 7a40779

Please sign in to comment.