Permalink
Browse files

Implement ($@%&)foo.VAR.default

Although I don't think this is formally specced, it seems logical that we can
introspect this at runtime using .VAR
  • Loading branch information...
1 parent 81eec1b commit eea1906d6564555f5f27e13776429d7d614962e1 @lizmat lizmat committed Aug 8, 2013
Showing with 14 additions and 0 deletions.
  1. +5 −0 src/core/Array.pm
  2. +5 −0 src/core/Hash.pm
  3. +4 −0 src/core/Scalar.pm
View
@@ -73,6 +73,11 @@ class Array { # declared in BOOTSTRAP
method flattens() { 1 }
+ method default() {
+ my $d := $!descriptor;
+ nqp::isnull($d) ?? Mu !! $d.default;
+ }
+
multi method perl(Array:D \SELF:) {
nqp::iscont(SELF)
?? '[' ~ self.map({.perl}).join(', ') ~ ']'
View
@@ -69,6 +69,11 @@ my class Hash { # declared in BOOTSTRAP
self
}
+ method default() {
+ my $d := $!descriptor;
+ nqp::isnull($d) ?? Mu !! $d.default;
+ }
+
proto method delete(|) { * }
multi method delete(Hash:U:) { Nil }
multi method delete($key as Str) {
View
@@ -8,4 +8,8 @@ my class Scalar {
my $d := $!descriptor;
nqp::isnull($d) ?? Mu !! $d.of;
}
+ method default() {
+ my $d := $!descriptor;
+ nqp::isnull($d) ?? Mu !! $d.default;
+ }
}

0 comments on commit eea1906

Please sign in to comment.