Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

First cut at an implementation of 'gist' (from specs commit 669e0dd).

  • Loading branch information...
commit ba6af41de599c8eda493c5d91903139cd813e67a 1 parent de6c43d
@pmichaud pmichaud authored
View
12 src/core/IO.pm
@@ -1,12 +1,14 @@
# XXX Relatively cheaty, just to get us able to output something.
# But you should see what USED to be here! O.O
-sub say(*@list) {
+sub print(*@list) {
pir::print(@list.shift) while @list.gimme(1);
- pir::print("\n");
1.Bool
}
-sub print(*@list) {
- pir::print(@list.shift) while @list.gimme(1);
- 1.Bool
+sub say(|$) {
+ print pir__perl6_box_rpa__PP(pir::perl6_current_args_rpa__P()).gist, "\n"
+}
+
+sub gist(|$) {
+ pir__perl6_box_rpa__PP(pir::perl6_current_args_rpa__P()).gist
}
View
2  src/core/Iterable.pm
@@ -1,3 +1,5 @@
my class Iterable {
# Has parent Cool declared in BOOTSTRAP
+
+ method item($self:) { $self }
}
View
15 src/core/List.pm
@@ -5,10 +5,11 @@ class List {
# has $!flattens; # true if this list flattens its parcels
# has $!nextiter; # iterator for generating remaining elements
- method Bool() { self.gimme(1).Bool }
- method Int() { self.elems }
- method Numeric() { self.elems }
- method Parcel() { self.gimme(*); pir__perl6_box_rpa__PP(self.RPA) }
+ method Bool() { self.gimme(1).Bool }
+ method Int() { self.elems }
+ method Numeric() { self.elems }
+ method Parcel() { self.gimme(*); pir__perl6_box_rpa__PP(self.RPA) }
+ method Str(List:D:) { self.join(' ') }
method list() { self }
method flattens() { $!flattens }
@@ -74,6 +75,12 @@ class List {
pir__perl6_box_rpa__PP($rpa)
}
+ method push(*@values) {
+ my $pos = self.elems;
+ fail '.push on infinite lists NYI' if $!nextiter.defined;
+ self.STORE_AT_POS($pos++, @values.shift) while @values;
+ }
+
method shift() {
# make sure we have at least one item, then shift+return it
self.gimme(1) && pir::shift__PP($!items)
View
12 src/core/Mu.pm
@@ -30,22 +30,22 @@ my class Mu {
proto method Str(|$) { * }
multi method Str(Mu:U:) {
- self.HOW.name(self) ~ '()'
+ '' # TODO: should be a warning of some sort
}
multi method Str(Mu:D:) {
self.HOW.name(self) ~ '<' ~ self.WHERE ~ '>'
}
- proto method Stringy(|$) { * }
- multi method Stringy(Mu:U:) {
- '' # TODO: should be a warning of some sort
- }
- multi method Stringy(Mu:D:) { self.Str }
+ method Stringy(Mu:D:) { self.Str }
method item() { self }
method say() { say(self) }
+ proto method gist(|$) { * }
+ multi method gist(Mu:U:) { self.HOW.name(self) ~ '()' }
+ multi method gist(Mu:D:) { self.Stringy }
+
proto method perl(|$) { * }
multi method perl(Mu:D:) { self.Str }
multi method perl(Mu:U:) { self.HOW.name(self) }
View
7 src/core/Parcel.pm
@@ -9,6 +9,13 @@ my class Parcel {
pir::perl6_list_from_rpa__PPPP(List, pir::clone__PP($!storage), Mu)
}
+ multi method gist(Parcel:D:) {
+ my @gist;
+ my Mu $rpa := pir::clone__PP($!storage);
+ @gist.push( pir::shift__PP($rpa).gist ) while $rpa;
+ @gist;
+ }
+
multi method perl(Parcel:D:) {
my Mu $rpa := pir::clone($!storage);
my $perl = '(';
Please sign in to comment.
Something went wrong with that request. Please try again.