Skip to content

Commit

Permalink
please return Nil for no value, not a typeobject
Browse files Browse the repository at this point in the history
We didn't clarify this till recently, so I assume these are mostly fossils.
  • Loading branch information
TimToady committed Dec 3, 2015
1 parent c6cc8a8 commit 887c937
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/Perl6/Metamodel/BOOTSTRAP.nqp
Expand Up @@ -1557,7 +1557,7 @@ BEGIN {
Parameter.HOW.add_method(Parameter, 'WHY', nqp::getstaticcode(sub ($self) {
my $why := nqp::getattr(nqp::decont($self), Parameter, '$!why');
if nqp::isnull($why) || !$why {
Any
Nil
} else {
$why.set_docee($self);
$why
Expand Down
2 changes: 1 addition & 1 deletion src/Perl6/Metamodel/Documenting.nqp
Expand Up @@ -2,7 +2,7 @@ role Perl6::Metamodel::Documenting {
has $!why;

method WHY() {
nqp::isnull($!why) ?? Any !! $!why
nqp::isnull($!why) ?? Nil !! $!why
}

method set_why($why) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/Any.pm
Expand Up @@ -529,7 +529,7 @@ sub DELETEKEY(Mu \d, str $key) {
$value;
}
else {
Mu;
Nil;
}
} #DELETEKEY

Expand Down
4 changes: 2 additions & 2 deletions src/core/Attribute.pm
Expand Up @@ -109,7 +109,7 @@ my class Attribute { # declared in BOOTSTRAP
}
}

method container() is raw { nqp::isnull($!auto_viv_container) ?? Mu !! $!auto_viv_container }
method container() is raw { nqp::isnull($!auto_viv_container) ?? Nil !! $!auto_viv_container }
method has-accessor() { ?$!has_accessor }
method readonly() { !self.rw }
method package() { $!package }
Expand All @@ -119,7 +119,7 @@ my class Attribute { # declared in BOOTSTRAP

method WHY() {
if nqp::isnull($!why) {
Any
Nil
} else {
$!why.set_docee(self);
$!why
Expand Down
2 changes: 1 addition & 1 deletion src/core/Backtrace.pm
Expand Up @@ -158,7 +158,7 @@ my class Backtrace {

return $idx - 1;
}
Int;
Nil;
}

method outer-caller-idx(Backtrace:D: Int $startidx) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/Block.pm
Expand Up @@ -324,7 +324,7 @@ my class Block { # declared in BOOTSTRAP

method WHY() {
if nqp::isnull($!why) {
Any
Nil
} else {
$!why.set_docee(self);
$!why
Expand Down
10 changes: 5 additions & 5 deletions src/core/CompUnit/Handle.pm
Expand Up @@ -22,7 +22,7 @@ class CompUnit::Handle {
nqp::atkey($module, '&EXPORT');
}
else {
Callable
Nil
}
}

Expand All @@ -37,7 +37,7 @@ class CompUnit::Handle {
!! nqp::p6bindattrinvres(nqp::create(Stash), Map, '$!storage', $EXPORT.WHO);
}
else {
Stash
Nil
}
}

Expand All @@ -53,7 +53,7 @@ class CompUnit::Handle {
!! nqp::p6bindattrinvres(nqp::create(Stash), Map, '$!storage', $who);
}
else {
Stash
Nil
}
}

Expand All @@ -63,10 +63,10 @@ class CompUnit::Handle {
method globalish-package() { # returns Stash {
if nqp::defined($!module_ctx) {
my $lexpad := nqp::ctxlexpad($!module_ctx);
nqp::isnull(nqp::atkey($lexpad, 'GLOBALish')) ?? Stash !! nqp::atkey($lexpad, 'GLOBALish')
nqp::isnull(nqp::atkey($lexpad, 'GLOBALish')) ?? Nil !! nqp::atkey($lexpad, 'GLOBALish')
}
else {
Stash
Nil
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/Hash.pm
Expand Up @@ -87,7 +87,7 @@ my class Hash { # declared in BOOTSTRAP
method keyof () { Any }
method of() {
my $d := $!descriptor;
nqp::isnull($d) ?? Nil !! $d.of;
nqp::isnull($d) ?? Mu !! $d.of;
}
method default() {
my $d := $!descriptor;
Expand Down
2 changes: 1 addition & 1 deletion src/core/IO/Socket/INET.pm
Expand Up @@ -108,7 +108,7 @@ my class IO::Socket::INET does IO::Socket {
$line
}
else {
Str
Nil
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/core/Iterable.pm
Expand Up @@ -131,9 +131,7 @@ my role Iterable {
$!source.push-exactly($work.input, $items)
}

method process-buffer(HyperWorkBuffer:D $work) {
Mu
}
method process-buffer(HyperWorkBuffer:D $work --> Nil) { }

method configuration() { $!configuration }
}.new(self.iterator, $configuration));
Expand Down
2 changes: 1 addition & 1 deletion src/core/Map.pm
Expand Up @@ -178,7 +178,7 @@ my class Map does Iterable does Associative { # declared in BOOTSTRAP
my str $skey = nqp::unbox_s(key.Str);
nqp::defined($!storage) && nqp::existskey($!storage, $skey)
?? nqp::atkey($!storage, $skey)
!! Any
!! Nil
}

method STORE(\to_store) {
Expand Down
4 changes: 2 additions & 2 deletions src/core/Pod.pm
Expand Up @@ -78,8 +78,8 @@ my class Pod::Block::Declarator is Pod::Block {
}
}

method leading { @!leading ?? @!leading.join(' ') !! Any }
method trailing { @!trailing ?? @!trailing.join(' ') !! Any }
method leading { @!leading ?? @!leading.join(' ') !! Nil }
method trailing { @!trailing ?? @!trailing.join(' ') !! Nil }

method _add_leading($addition) {
@!leading.push: ~$addition;
Expand Down
8 changes: 4 additions & 4 deletions src/core/PseudoStash.pm
Expand Up @@ -162,8 +162,8 @@ my class PseudoStash is Map {
my Mu $store := nqp::getattr(self, Map, '$!storage');
my Mu $res := nqp::existskey($store, $nkey) ??
nqp::atkey($store, $nkey) !!
Any;
if !($res =:= Any) && nqp::bitand_i($!mode, REQUIRE_DYNAMIC) {
Nil;
if !($res =:= Nil) && nqp::bitand_i($!mode, REQUIRE_DYNAMIC) {
if try !$res.VAR.dynamic {
X::Caller::NotDynamic.new(
symbol => $key,
Expand All @@ -176,13 +176,13 @@ my class PseudoStash is Map {
my $found := nqp::getlexreldyn(
nqp::getattr(self, PseudoStash, '$!ctx'),
$nkey);
nqp::isnull($found) ?? Any !! $found
nqp::isnull($found) ?? Nil !! $found
}
else { # STATIC_CHAIN
my $found := nqp::getlexrel(
nqp::getattr(self, PseudoStash, '$!ctx'),
$nkey);
nqp::isnull($found) ?? Any !! $found
nqp::isnull($found) ?? Nil !! $found
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/core/Range.pm
Expand Up @@ -340,15 +340,15 @@ my class Range is Cool does Iterable does Positional {
!! self.list.roll(*)
}
else {
Any xx *
Nil xx *
}
}
multi method roll(Range:D:) {
if $!is-int {
my $elems = $!max - $!excludes-max - $!min - $!excludes-min + 1;
$elems > 0
?? $!min + $!excludes-min + nqp::rand_I(nqp::decont($elems),Int)
!! Any
!! Nil
}
else {
self.list.roll
Expand Down Expand Up @@ -382,7 +382,7 @@ my class Range is Cool does Iterable does Positional {
!! self.list.roll($todo)
}
else {
Any xx $todo
Nil xx $todo
}
}

Expand Down Expand Up @@ -438,7 +438,7 @@ my class Range is Cool does Iterable does Positional {
!! self.list.pick($todo)
}
else {
Any xx $todo
Nil xx $todo
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/core/Routine.pm
Expand Up @@ -58,9 +58,7 @@ my class Routine { # declared in BOOTSTRAP
$perl
}

method soft() {
Mu
}
method soft( --> Nil ) { }

method wrap(&wrapper) {
my class WrapHandle {
Expand Down
12 changes: 6 additions & 6 deletions src/core/Str.pm
Expand Up @@ -1396,7 +1396,7 @@ my class Str does Stringy { # declared in BOOTSTRAP
multi method encode(Str:D $encoding = 'utf8', Bool:D :$replacement) {
self.encode($encoding, :replacement($replacement
?? ($encoding ~~ m:i/^utf/ ?? "\x[FFFD]" !! "?" )
!! Str
!! Nil
));
}
multi method encode(Str:D $encoding = 'utf8', Str :$replacement) {
Expand Down Expand Up @@ -1889,9 +1889,9 @@ my class Str does Stringy { # declared in BOOTSTRAP
multi method ord(Str:D:) returns Int {
nqp::chars($!value)
?? nqp::p6box_i(nqp::ord($!value))
!! Int;
!! Nil;
}
multi method ord(Str:U:) returns Int { Int }
multi method ord(Str:U: --> Nil) { }
}


Expand Down Expand Up @@ -2225,22 +2225,22 @@ multi sub uniprop(Int:D $code, Stringy:D $propname = "GeneralCategory") {

proto sub uniprop-int(|) {*}
multi sub uniprop-int(Str:D $str, Stringy:D $propname) {
$str ?? uniprop-int($str.ord, $propname) !! Str }
$str ?? uniprop-int($str.ord, $propname) !! Nil }
multi sub uniprop-int(Int:D $code, Stringy:D $propname) {
nqp::getuniprop_int($code,Rakudo::Internals.PROPCODE($propname));
}

proto sub uniprop-bool(|) {*}
multi sub uniprop-bool(Str:D $str, Stringy:D $propname) {
$str ?? uniprop-bool($str.ord, $propname) !! Str
$str ?? uniprop-bool($str.ord, $propname) !! Nil
}
multi sub uniprop-bool(Int:D $code, Stringy:D $propname) {
so nqp::getuniprop_bool($code,Rakudo::Internals.PROPCODE($propname));
}

proto sub uniprop-str(|) {*}
multi sub uniprop-str(Str:D $str, Stringy:D $propname) {
$str ?? uniprop-str($str.ord, $propname) !! Str
$str ?? uniprop-str($str.ord, $propname) !! Nil
}
multi sub uniprop-str(Int:D $code, Stringy:D $propname) {
nqp::getuniprop_str($code,Rakudo::Internals.PROPCODE($propname));
Expand Down

0 comments on commit 887c937

Please sign in to comment.