pugscode.org/ | nopaste: sial.org/pbot/perl6 | pugs: [~] <m oo se> (or rakudo:, kp6:, elf: etc.) (or perl6: for all) | irclog: irc.pugscode.org/
Set by Tene on 29 July 2008.
masak perl6: sub f($l) { $l <= 0 ?? '' !! map { $l ~ f($l-1) }, 1..3 }; f(2) 10:35
p6eval pugs: RESULT[("21 1 1", "21 1 1", "21 1 1")]
..rakudo 30669: OUTPUT[maximum recursion depth exceeded␤current instr.: 'f' pc 179 (EVAL_17:69)␤]
..elf 22078: OUTPUT[Unknown rule: infix:conditional␤It needs to be added to ast_handlers.␤ at ./elf_f line 1918␤]
masak perl6: sub f($l) { $l ?? 0 !! join ''. map { $l ~ f($l-1) }, 1..3 }; f(2) 10:42
p6eval rakudo 30669: OUTPUT[Statement not terminated properly at line 1, near ". map { $l"␤␤current instr.: 'parrot;PGE::Util;die' pc 119 (runtime/parrot/library/PGE/Util.pir:82)␤]
..pugs: OUTPUT[*** ␤ Unexpected " map"␤ expecting ".", "\187", ">>", "=", "^", operator name, qualified identifier, variable name, "...", "--", "++", "i", array subscript, hash subscript or code subscript␤ at /tmp/hKwRQDZvZR line 1, column 32␤]
..elf 22078: OUTPUT[Parse error in: /tmp/T7jpRrFX0B␤panic at line 1 column 12 (pos 12): Missing right brace␤WHERE: sub f($l) { $l ?? 0 !! join ''. map { $l ~␤WHERE: /\<-- HERE␤ STD_red/prelude.rb:99:in `panic'␤ STD_red/std.rb:255:in `_block_rest'␤ STD_red/std.rb:242:in `block in
..block'...
masak perl6: sub f($l) { $l ?? 0 !! join '', map { $l ~ f($l-1) }, 1..3 }; f(2) 10:43
p6eval elf 22078: OUTPUT[Unknown rule: infix:conditional␤It needs to be added to ast_handlers.␤ at ./elf_f line 1918␤]
..pugs, rakudo 30669: RESULT[0]
ruoso Hello! 13:08
masak ruoso: greetings. 13:23
pmurias ruoso: Hi! 13:45
ruoso hi masak, pmurias... 13:46
masak slow Perl 6 day today.
on #parrot too :/ 13:47
ruoso getting some documentation up-to-date in a $work related projet 13:48
masak hacking away on the new HTML::Template, but mostly blocking on a Parrot bug
ruoso pmurias, so.. what do you think about the capture expand thing? 13:50
pmurias getting round to reading it& 13:51
ruoso: i'm not sure if's better to do a proxy object instead of just merging captures 13:52
ruoso too ;) 13:53
that's why I'm asking for other opinions... ;)
pmurias most of the time captures will be IMHO small 13:54
so it might be faster to just merge them
ruoso pmurias, would you like to write the p6 code that would do the merging? 13:56
pmurias plus native captures are expected in a lot of places 13:59
ruoso: what is simpler for you to implement?
ruoso: have to some other $stuff first, i was away on a windsurfing camp this week 14:00
pmurias tends to have less free time on weekends
ruoso pmurias, I think keeping native captures is nice, although we have to deal with that some time...
I was thinking on taking the "for" implementation
pmurias i think kp6 implemented for in terms of map 14:01
ruoso pmurias, "for" is actually simple... I just need to ask for .arity of the signature of the code and use the iterator api 14:03
pmurias ruoso: you mean "map"? 14:03
ruoso I understand prefix:<=> takes the next element... but I don't see how prefix:<=> will signalize the end of the iteration..
pmurias, no... I did mean 'for'... 14:04
s/prefix:<=> takes/prefix:<=> returns/ 14:07
pmurias hm, for =$iterator {...} is possible, as prefix:<=> returns a lazy list in list context 14:10
we can turn for @array {...} into @array.map(-> {...}) 14:12
ruoso hmmm 14:14
but for @array is also lazy...
I mean...
if @array is lazy, obviously...
masak does the evaluation of a for result in a value? 14:15
ruoso but I was thinking on 'for' in terms of while ($value.has_next) { $code.($value.next) }
masak, I don't think so...
masak so you have to hide that as well. probably not too difficult, though. 14:16
pmurias pugs: my @array = for (1,2,3) {$_};
p6eval pugs: OUTPUT[*** ␤ Unexpected "@array"␤ expecting "=", context, ":" or "("␤ postfix op␤ at /tmp/kT0buKHxVU line 1, column 4␤]
pmurias masak: for is not an expression 14:17
masak right. but map is.
pmurias yes
masak so there's a bit of an impedence mismatch.
pmurias no
masak ...in the sense that a for build on top of a map has to hide the value returned from the map 14:18
pmurias no
masak ok :)
pmurias we have void context
masak ah. ok.
pmurias ruoso: iterators are just a less powerfull version of lists, so if you have a (lazy) list there is no point in treating it as one 14:20
ruoso as a list you mean... you can treat it only as an iterator... 14:21
and that's my plan...
I mean... 14:22
in the end I have two options...
"for" might start with .[0] and end in the last element... 14:23
and the other is having an iterator-like api
which is .has_next and .next
the reason I'm trying to push towards an iterator-like API
is to allow navigating in iterators that are not representing index-oriented lists... or unordered lists... 14:24
or streams...
for instance...
BerkeleyDB loses a lot of its efficiency if you have to support index-based access
it's much more efficient when you have a cursor-based access... 14:25
that's what I mean...
pmurias if we implemnt for as .map we still get the efficiency, and it's the simplest way 14:27
as we have to implement .map anyway 14:29
ruoso right... 14:29
but anyway... that doesn't answer my question... 14:30
.map needs to iterate the list anyway...
ah...
wait...
map is implemented by the list itself...
now I got it...
it's easier...
ruoso pmurias++... I've just updated the roadmap... now we need unshift, grep and map in the list 14:34
and for is just a call to .map
pmurias, but... 14:35
map is supposed to be lazy, isn't it?
for is supposed to evaluate each item eagerly, isn't it? 14:38
I mean...
it won't expand the list before...
but it will execute immediately the code block for every item.. 14:39
while map will only evaluate the block as the returned array is traversed...
so that 'map { } grep { } map { } @foo' work as expected 14:40
I even think that Perl 6 should warn about "useless use of map in void context..." 14:42
to be clear that map is lazy 14:43
pmurias pugs: my @foo=(1,2,3,4);@foo.map(-> { say $_}); 14:44
p6eval pugs: OUTPUT[␤␤␤␤]
pmurias pugs: my @foo=(1,2,3,4);@foo.map(->($arg) { say $arg});
p6eval pugs: OUTPUT[1␤2␤3␤4␤]
pmurias pugs: my @foo=(1,2,3,4);my @bar = @foo.map(->($arg) { say $arg});
p6eval pugs: OUTPUT[1␤2␤3␤4␤]
ruoso pugs: my @foo = (1,2,3,4); @foo.map(->($arg) { say $arg }); 'the last statement is returned...' 14:46
p6eval pugs: OUTPUT[1␤2␤3␤4␤]
pmurias pugs: my @foo=(1,2,3,4);my @bar = @foo.map(->($arg) { say $arg});'last'
p6eval pugs: OUTPUT[1␤2␤3␤4␤]
pmurias pugs might be wrong here 14:47
ruoso I think it is... 14:48
pmurias TimToady: does map in void context run the block at all?
we can always use "eager @array.map {...}" 14:49
ruoso eager simply iterates the list... 14:50
causing the lazy list to be evaluated... 14:51
which brings us to the same problem...
pmurias all the code blocks will be executed
ruoso OTOH... I could argue that "for" could be part of the Array API
Array.for($code)
masak pmurias++, ruoso++ # doing cool nitty-gritty stuff 14:52
ruoso pmurias, the problem is how to iterate some list...
pmurias using iterators you mean? 14:53
ruoso yes...
but... I think including .for in the Array API is a very much interesting option... 14:54
pmurias ruoso: i don't now how to get the iterator for a list, iterators are barely specced and probably not encouraged in Perl 6 14:58
ruoso pmurias, yeah... but I'm now convinced "for" should be a method of the Array API
;)
and bare "for" is a global sub... 14:59
pmurias a bare for can be just translated to a method call 15:00
ruoso yeah... it's probably better, since it has a special syntax 15:01
pmurias hates multi tasking, as he ends up doing one thing with half the brain power 15:03
ruoso out to by drinks for lunch... 15:04
Khisanth pugs: my $foo = [ 1 .. 10 ]; say $foo[ 3 .. 8 ] 17:35
p6eval pugs: OUTPUT[456789␤]
Khisanth pugs: my $foo = [ 1 .. 10 ]; say $foo[ 3 .. 8 ].join( " " )
p6eval pugs: OUTPUT[4 5 6 7 8 9␤]
Khisanth pugs: my $foo = [ 1 .. 10 ]; say $foo[ 3 .. $foo.end ].join( " " ) 17:36
p6eval pugs: OUTPUT[4 5 6 7 8 9 10␤]
moritz_ re 18:09
rakudo_svn r30671 | moritz++ | [rakudo] Str.subst can take a closure as second argument 18:30
pugs_svn r22079 | moritz++ | [t/spec] unfudge subst.t for rakudo
moritz_ @tell dr_df0 very nice work on the test suite. In future try to separate words in file names with '-', not with '_'; but that's just a minor nit 19:19
lambdabot Consider it noted.
moritz_ anyway, dr_df0++ # test suite work 20:23
rakudo_svn r30672 | moritz++ | [rakudo] add 8 more files to spectest_regression, dr_df0++ and others++ 20:24
moritz_ on the train today I a few more posts for my perl-5-to-6 blog 20:58
and I now I have to restrain myself from publishing them all at once 20:59
(but I know that I won't have the time to write enough this week)
;-)
meppl good night 23:54