Skip to content
Permalink
Browse files

Streamline .defined

- remove todo for Failure.defined
- use a multi from Mu.defined
- simplify Failure.defined
- give Slip.defined a shortcut (.so calls .Bool so why not call .Bool directly)
  • Loading branch information...
lizmat committed Dec 26, 2018
1 parent 2d704af commit 1611795d524fea7e2e623e4779813f3f59dee363
Showing with 8 additions and 9 deletions.
  1. +1 −4 src/core/Failure.pm6
  2. +1 −1 src/core/Junction.pm6
  3. +3 −3 src/core/Mu.pm6
  4. +3 −1 src/core/Slip.pm6
@@ -49,10 +49,7 @@ my class Failure is Nil {
method AT-POS(|) { self }
method AT-KEY(|) { self }

# TODO: should be Failure:D: multi just like method Bool,
# but obscure problems prevent us from making Mu.defined
# a multi. See http://irclog.perlgeek.de/perl6/2011-06-28#i_4016747
method defined(--> False) { $!handled = 1 if nqp::isconcrete(self) }
multi method defined(Failure:D: --> False) { $!handled = 1 }

multi method Bool(Failure:D: --> False) { $!handled = 1 }
method handled() is rw {
@@ -68,7 +68,7 @@ my class Junction { # declared in BOOTSTRAP
nqp::create(Junction)!SET-SELF(type,values)
}

method defined(Junction:D:) {
multi method defined(Junction:D:) {
nqp::hllbool(
nqp::stmts(
(my int $elems = nqp::elems($!storage)),
@@ -105,9 +105,9 @@ Perhaps it can be found at https://docs.perl6.org/type/$name"
method so() { self.Bool }
method not() { self ?? False !! True }

method defined() {
nqp::hllbool(nqp::isconcrete(self))
}
proto method defined(|) {*}
multi method defined(Mu:U: --> False) { }
multi method defined(Mu:D: --> True) { }

proto method new(|) {*}
multi method new(*%attrinit) {
@@ -2,7 +2,9 @@
# or another List. Other than that, it's a totally normal List.
my class Slip { # is List
multi method Slip(Slip:D:) { self }
method defined () { self.so }
multi method defined (Slip:D:) { # XXX this makes an empty Slip undefined?
self.Bool
}
method CALL-ME (+args) { args.Slip }
multi method perl(Slip:D:) {
nqp::if(

0 comments on commit 1611795

Please sign in to comment.
You can’t perform that action at this time.