-
-
Notifications
You must be signed in to change notification settings - Fork 372
/
Nil.pm6
41 lines (34 loc) · 1.72 KB
/
Nil.pm6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
my class Nil is Cool { # declared in BOOTSTRAP
method new(*@ --> Nil) { }
multi method gist(Nil:) { 'Nil' }
method Numeric() { warn "Use of {self.gist} in numeric context"; 0 }
method Str() { warn "Use of {self.gist} in string context"; '' }
method sink(--> Nil) { } # required by RESTRICTED setting
method AT-POS(| --> Nil) { }
method AT-KEY(| --> Nil) { }
# method ACCEPTS(*@ --> Nil) { } # XXX spec says Nil, but makes install fail
method BIND-POS(|) { die "Attempted to BIND-POS to {self.gist}." }
method BIND-KEY(|) { Failure.new(X::Bind.new(target => self.gist)) }
method ASSIGN-POS(|) { die "Attempted to ASSIGN-POS to {self.gist}." }
method ASSIGN-KEY(|) { die "Attempted to ASSIGN-KEY to {self.gist}." }
method STORE(|) { X::Assignment::RO.new(:value<Nil>).throw }
method push(|) is nodal { die "Attempted to push to {self.gist}." }
method append(|) is nodal { die "Attempted to append to {self.gist}." }
method unshift(|) is nodal { die "Attempted to unshift to {self.gist}." }
method prepend(|) is nodal { die "Attempted to prepend to {self.gist}." }
method FALLBACK(| --> Nil) { }
# These suggest using Nil.new if they fall through, which is LTA
method ords() { self.Str.ords }
method chrs() { self.Int.chrs }
method chop() { self.Str.chop }
method chomp() { self.Str.chomp }
method iterator() { self.list.iterator }
# QuantHash coercions
method Set() { Set.new(Nil) }
method SetHash() { SetHash.new(Nil) }
method Bag() { Bag.new(Nil) }
method BagHash() { BagHash.new(Nil) }
method Mix() { Mix.new(Nil) }
method MixHash() { MixHash.new(Nil) }
}
# vim: expandtab shiftwidth=4