Perl 6 - the future is here, just unevenly distributed

IRC log for #perl6-lwp-gsoc, 2014-05-26

| Channels | #perl6-lwp-gsoc index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
14:21 ilbot3 joined #perl6-lwp-gsoc
14:30 sergot moritz++ thanks! :)
14:32 Topic for #perl6-lwp-gsoc is now logs at http://irclog.perlgeek.de/perl6-lwp-gsoc/
14:34 FROGGS moritz++
14:48 FROGGS joined #perl6-lwp-gsoc
14:55 sergot moritz: about this redundant new: https://github.com/sergot/http-headers/blob/master/lib/HTTP/Headers.pm6#L5
14:56 sergot Because of * before %headers we can write this: 'HTTP::Headers.new(a => 1, b => 2)'
14:57 sergot We are not able to do this using default new()
14:57 sergot Am I wrong?
14:57 sergot $ perl6 -e 'class A { has %.headers is rw; }; my $b = A.new(headers => { a => 1, b => 2 }); say $b.perl;'
14:57 sergot A.new(headers => ("b" => 2, "a" => 1).hash)
15:00 dalek http-headers: be3c2fc | sergot++ | lib/HTTP/Headers.pm6:
15:00 dalek http-headers: [lib/HTTP/Headers.pm6] we dont have to check if parameters are Positional
15:00 dalek http-headers: review: https://github.com/sergot/http-headers/commit/be3c2fcb81
15:06 FROGGS joined #perl6-lwp-gsoc
15:07 sergot FROGGS: http://irclog.perlgeek.de/perl6-lwp-gsoc/2014-05-26#i_8776922
15:07 sergot 14:55
15:12 FROGGS I am trying to open that page right now :o)
15:12 FROGGS seems to take a while
15:13 sergot oooh, ok :)
15:14 sergot FROGGS: moritz said I should use Str instead of as_string - am I doing this correctly:
15:14 sergot 55 method Str {
15:14 sergot 56     my @s = gather for %.headers.keys {
15:14 sergot 57         take ($_, %.headers{$_}).join(': ');
15:14 sergot 58     };
15:14 sergot 59     @s.join("\n");
15:14 sergot 60 }
15:14 sergot ?
15:15 FROGGS I agree that you cannot use the default .new in this case
15:15 sergot also works: %.headers.kv -> $k, $v { ... }
15:17 dalek http-headers: 4322462 | sergot++ | lib/HTTP/Headers.pm6:
15:17 dalek http-headers: [lib/HTTP/Headers.pm6] .Str added
15:17 dalek http-headers: review: https://github.com/sergot/http-headers/commit/4322462102
15:19 sergot FROGGS: what do you think about keeping orderd in HTTP::Headers?
15:19 FROGGS gimme a sec
15:19 sergot order*
15:19 FROGGS would be nice, yes
15:19 FROGGS so, push pairs to an array
15:20 sergot Ok :)
15:21 sergot HTTP::Cookies seems to be quite big module.
15:23 FROGGS I'd do it like: my @s = %.headers.map({ "$_.key(): $_.value()" }).join("\n");
15:23 FROGGS because .map is usually faster than gather/take
15:24 FROGGS and gather/take only makes sense if you sometime want to take nothing, or take more than one thing per iteration
15:26 FROGGS err, is is more like my $str = %.headers.map({ "$_.key(): $_.value()" }).join("\n");
15:26 FROGGS :o)
15:27 FROGGS my %headers = a => 1, b => 2;
15:27 FROGGS say %headers.map(*.fmt("%s: %s")).join("\n");
15:27 FROGGS sergot: ^^
15:32 sergot great! thanks
15:33 sergot awesome :)
15:36 dalek http-headers: 5f757b2 | sergot++ | lib/HTTP/Headers.pm6:
15:36 dalek http-headers: [lib/HTTP/Headers.pm6] map instead of gather-take
15:36 dalek http-headers: review: https://github.com/sergot/http-headers/commit/5f757b290b
15:38 sergot FROGGS++
15:39 FROGGS glad you like it :o)
17:09 FROGGS joined #perl6-lwp-gsoc
17:11 moritz shouldn't it be map(*.fmt("%s: %s\n")).join ?
17:11 moritz I mean, you'll want a trailing newline, no?
17:12 FROGGS hmmm, probably yes
17:14 FROGGS I'm not sure, but I thought there is \r\n\r\n after the headers
17:17 moritz well, yes
17:17 moritz but the string representation of the headers themselves shouldn't contain the final double newline
17:18 FROGGS exactly, so there should not be a newline at the end at all perhaps?
18:21 sergot good point
18:21 sergot :)
18:21 sergot I'll think it over again :)

| Channels | #perl6-lwp-gsoc index | Today | | Search | Google Search | Plain-Text | summary