»ö« | perl6.org/ | nopaste: paste.lisp.org/new/perl6 | evalbot usage: 'perl6: say 3;' or rakudo: / pugs: / std: , or /msg p6eval perl6: ... | irclog: irc.pugscode.org/ | UTF-8 is our friend!
Set by wolfe.freenode.net on 30 October 2009.
ash_ jnthn in S02-builtin_data_types/anon_block.t line #76 and line #80, are those two tests actually different? just curious 00:06
{$foo = "blah"}; vs {$foo2 = "blah"}; shouldn't the first one be a bare block without a semi-colon?
or maybe the second, well 1 of them 00:07
colomon_ ng: say 1; 03:35
p6eval ng d5a7de: 1␤
colomon_ ng: (1...10).grep({$_ % 3 == 2}).perl.say
p6eval ng d5a7de: []␤
colomon_ ng: (1...10).grep({$^a % 3 == 2}).perl.say
p6eval ng d5a7de: [2, 5, 8]␤
colomon_ blast, I was hoping pmichaud's move to parrot 2.0.0 might have fixed that one 03:38
sjohnson :( 03:41
Tene um... why? how would it have any effect? 03:46
ash_ ng: (-> $a { -> $b { $a + $b } })(4)(5); 03:46
p6eval ng d5a7de: Not enough positional parameters passed; got 0 but expected 1␤current instr.: '_block34' pc 218 (EVAL_1:103)␤
ash_ rakudo: say (-> $a { -> $b { $a + $b } })(4)(5); 03:47
p6eval rakudo 1d4928: 9␤
ash_ hmm
ng: say (-> $a { $a })(4);
p6eval ng d5a7de: sh: ./perl6: No such file or directory␤
ash_ locally that just prints 4 03:48
for some reason, putting a pointy block in a pointy block it gets an error
ash_ well, not a parse error, but its not functioning right, hmmm 03:51
k23z__ can I compile perl6 on windows ? 06:56
rakudo to be specific
or maybe I can find binaries somewherE ? 06:57
someone care to provide me with binaries for rakudo on windows ?
Tene k23z__: sourceforge.net/projects/parrotwin32/files/ has what you need. 07:02
k23z__: I'm not sure which combination of those files is the one you need, but they're in there somewhere. :)
I don't use win32, but that link came from rakudo.org/ which I think mentions in slightly more detail. 07:03
k23z__ ok 07:05
thanks
Tene No problem. I'm glad I could help. Also, welcome to the channel! :)
Su-Shee good morning 07:22
moritz_ good morning 08:50
sjohnson hi moritz_ 09:28
(´ー` )
jnthn oh morning 09:50
moritz_ \o/
sjohnson ( ° ー°)
szbalint jnthn: still in Vienna? 09:54
jnthn szbalint: Bratislava...just went to Vienna for Vienna.pm last night.
szbalint aw. I had a free evening yesterday in Wien, too late now :S 09:55
jnthn Aw. 09:58
frettled morning-thing! 10:00
sjohnson heh 10:06
meneldor morning all 10:08
sjohnson hi hi hi 10:13
xinming read the synopsis again, everytime he reads, everytime he feels the exciting future. :-) 10:54
colomon morning 11:08
jnthn morning, colomon 11:12
colomon 2nd night in a row I got 7 hours uninterrupted sleep 11:12
jnthn \o/ 11:13
colomon I think this is the first time that's happened in about 18 months....
so very \o/ !
what's on the ng agenda for today? 11:14
jnthn I'm pondering either trying to do hash or trying to get a bit further with S12-*. 11:17
do Hash, that is. :-) 11:18
colomon :)
just don't drink beer and do hash at the same time, m'kay? ;) 11:19
sjohnson heh 11:20
mathw And don't code and drink beer and do hash either 11:22
jnthn I think if I was drinking beer and doing hash I'd be too relaxed to code. :-) 11:27
mathw That seems likely 11:30
Guest18693 hi 11:34
mathw hi 11:39
sjohnson hi matt 11:42
mathw hi sjohnson 11:54
colomon sjohnson: my impression is Canada is getting pretty excited about the Olympics. 12:08
sjohnson colomon: yeah the Vancouver 2010 campaign has been around for a while 12:11
it's a bit of a misnomer, as i'm sure most of the things will happen in cities near Vancouver that any foreigners don't even know about 12:12
like Whistler, BC
etc
colomon thought Whistler was someplace people knew about. ;)
sjohnson ahh probably is 12:13
colomon I have to admit that mostly I only know southern Ontario and eastern Newfoundland. 12:13
jnthn I've heard of Whistler. :-)
colomon \o/ 12:14
jnthn Never been to Canada though yet. :-(
colomon I think we just officially scheduled our sixth vacation of more than a week there (as a couple). 12:15
At least, I booked the motel for it. 12:16
sjohnson i landed in toronto once
colomon (Canada, that is, not Whistler.)
sjohnson on a flight to India
toronto and vancouver distance is like a 5 day drive 12:17
colomon That can't be right, can it? I would have guessed 3 days. 12:18
of course, that's based on my parents' stories of Ohio to Oregon driving time, so might be wildly off. :) 12:19
jnthn I keep thinking "ah, YAPC::NA will be in Canada some day, and then I'll go to that and make a holiday around it." :-) 12:20
colomon speaking of which, anyone know if YAPC::NA has a date yet? Columbus is in easy driving range for me... 12:21
sjohnson colomon: i suppose it depends on pitstops, motels, etc 12:29
but its a long ways
colomon :) 12:31
sjohnson ( `ー´) 12:34
takadonet morning all 13:03
colomon morning!
takadonet colomon: how are u?
colomon great! u? 13:05
I got a good night's sleep, the sun is shining, my boy is in a good mood, ng progress is being made...
takadonet doing good. Work is going great and ng progress is being made :) 13:11
pmichaud good morning #perl6 13:21
last night's hacking on list assignment was full of FAIL :-( 13:22
so, I'm at it again this morning. :-)
moritz_ good morning 13:23
colomon these things always work better in the morning, in my experience. :)
colomon 's boy just ripped two keys off the MBP keyboard, meaning a trip to the Apple Store is in my near future. 13:24
pugs_svn r29570 | pmichaud++ | [pm.txt]: Another spec clarification question. 13:35
r29570 |
r29570 | Pm-17: Are the builtin types such as C<Num>, C<Int>, C<Rat>,
r29570 | C<Str>, C<List>, etc. subclasses of C<Cool> or do they
r29570 | rely on C<Cool>'s method fallback mechanisms for the
r29570 | common methods? (Or, another way of asking: is
pugs_svn r29570 | C<List ~~ Cool> true?) 13:35
moritz_ I'm pretty sure that List ~~ Cool is true 13:36
pmichaud okay. The spec and #perl6 logs I could find were fairly unclear on that point. 13:36
s/were/are/
as I read the spec currently, though, it seems weird that MyClass ~~ Cool would be false but it would still respond to Cool's methods. 13:38
(assuming the builtin types have ~~ Cool as true)
colomon I thought the entire point of having Cool was that MyClass wouldn't have all those methods? 13:39
pmichaud colomon: it doesn't have the methods, but it still responds to them
colomon (Is this S12?)
pmichaud: that seems like a distinction without much of a difference.
jnthn pmichaud: That wasn't my understanding of it.
pmichaud: You inherit from Cool if you want your class to have those methods. 13:40
pmichaud Cool is a "fallback class namespace" where the dispatcher looks if it's unable to find a method for a given object
moritz_ [S02] rough in idea of moritz_++ to have separate type for convenience loopbacks
also conjecturally put all "last-resort" multis there to see if jnthn++ freaks
jnthn pmichaud: ah, hm.
moritz_ so it seems that the method fallback is still conjectural
pmichaud so is Cool
jnthn pmichaud: Use "is Cool" on varius built-in types.
pmichaud: iiuc
pmichaud: Any is still default thing we inherit from 13:41
pmichaud: Cool ~~ Any
pmichaud jnthn: yes, I know that. That's not my question/point.
jnthn pmichaud: tbh, I don't know why we need such a fallback yet.
pmichaud: It's worth asking, but I don't think it impedes putting Cool in. 13:42
pmichaud S02:1568 says "The C<Cool> namespace also contains all multimethods of last resort;
these are automatically searched if normal multiple dispatch does not
find a viable candidate."
If this is true, then it's not necessary for builtin classes to inherit from Cool. (more)
Not only that, but all user-defined types respond to Cool methods even if they aren't defined as "is Cool". 13:43
with the point being that when you ask a user-defined type for its methods, the Cool methods don't appear.
jnthn pmichaud: The big problem with this is that all the methods in Cool would have to declare a more liberal invocant than Cool
pmichaud Sure, they'd define Any. 13:44
jnthn Otherwise the multi-dispatch is gonna fail because the invocant type won't match.
Right.
pmichaud I mean, they'd use Any as the invocant. I don't see that as a big deal.
jnthn That feels a tad odd to me, that's all.
Anyway, I think the built-in types should inherit from Cool.
pmichaud I totally agree with you/moritz that it makes sense to simply say that builtin types derive from Cool.
But then I'm wondering (1) why the spec doesn't explicitly say that, and (2) why the fallback?
jnthn And we defer worrying about the multi-dispatch fallback for a little bit. 13:45
I'm not sure.
pmichaud Thus, my request for clarification in pm.txt :-)
jnthn I'm not sure that I like the fallback idea entirely, but I don't dislike it enough (yet) to freak either. :-)
colomon That reminds me (was thinking about this the other day), Cool does Real?
jnthn ooh, Slovak class time!
back later
pmichaud colomon: I wouldn't expect that.
moritz_ colomon: no
maybe Real is Cool or so :) 13:46
pmichaud Real is just a role, iiuc.
Num does Real, Rat does Real
colomon That's more or less how Any works now, it has all the functions that Real would have.
pmichaud colomon: well, it also has a lot of the function that Str would have 13:47
colomon and they're intended to work magically.
pmichaud and that List would have
with equal amounts of magic
colomon yes, I would also expect that Cool does Str or Stringy or whatever that role is.
pmichaud colomon: no, we don't want Num ~~ Stringy, I think. 13:48
colomon I thought the point of Cool was that numbers can be used like strings, and strings like numbers, where appropriate. 13:49
moritz_ colomon: yes, but it doesn't work the way you think it does
pmichaud that is the point of Cool. But we don't have to tie it to all of the roles
moritz_ colomon: currently this works by putting the method sin() into Any 13:50
pmichaud our definitions will tend to look like "class Num is Cool does Numeric"
or, more likely
our definitions will tend to look like "class Num is Cool does Numeric does Real"
moritz_ colomon: in the future that will work by putting it into Cool instead of Any
colomon: and since Str ~~ Cool, "23".sin works
pmichaud the methods go in Cool, while Numeric/Real allow us to distinguish the object capabilities 13:51
Numeric, Stringy, Real, etc are more for type constraints than method composition, I think.
smash_ hello 13:52
colomon but doesn't that lead to massive code duplication? I mean, you'll have to have Cool.sin { self.Num.sin } as well as Real.sin { self.Num.sin }.
repeated for every numeric function on reals.
pmichaud not at all
colomon oh, wait, that's wrong.
errr, no, it isn't. 13:53
pmichaud I think we'd just have Cool.sin and Num.sin
colomon I guess that would work, but it feels very very very wrong to me.... 13:54
pmichaud I suppose it could also be Cool.sin and Real.sin
anyway, code duplication of single-line delegations isn't something I worry about too much :) 13:55
takadonet smash: hello 13:56
colomon Maybe it's the idea "abstract role" that's tripping up my thinking? 14:05
pmichaud maybe. Maybe it's just that builtin types are weird because we want so many of them to be able to act like others :)
colomon Does that mean the role has no attributes, or that it is just an interface specification, with no function implementations? 14:05
moritz_ ng: say 1 14:06
p6eval ng d5a7de: 1␤
pmichaud colomon: not sure yet.
colomon I've been imagining that if your class does Real, all you need to provide is .Num and it will provide implementations of all the appropriate real number functions for you.
pmichaud the question is along the lines of "What do we expect class XYZ does Real { ... } to accomplish?"
moritz_ colomon: it sounds like you really want to inherit from Num for such a class 14:07
if you want all its arithmetic to go through .Num
colomon moritz_: but you DON'T want that, because you don't want to be carrying a extra floating point value around with you. 14:08
pmichaud moritz_: sure, but then you also get all of Num's .... what colomon++ said
colomon Think of Rat.
k23z__ have you considered making the compiler play some nice music while compiling ?
it would be way cool :)
something like "hey, hold on I'm compiling, listen to some music..."
pmichaud afk a bit 14:09
colomon There are a huge set of functions on Rat which amount to method X { self.Num.X }
those functions exactly correspond to what Real should be capable of.
moritz_ k23z__: I hate every program that plays music (unless its primary concern is to be a music or video player)
k23z__ you also hate keygens ? 14:10
I'm asking because they have this extremely cool music called chiptunes
colomon Furthermore, those functions are all covered in Real.
moritz_ k23z__: yes
k23z__ but moritz_ , the music in the keygens , it has that air of familirity 14:12
moritz_ k23z__: nope.
pmichaud huh? We have a src/cheats/parrot/misc.txt that isn't used at all? 14:32
pmichaud er, misc.pir 14:33
that's... weird, wonder where that file came from
pmichaud I guess it's left over 14:34
ash_ so, i figured out whats wrong with a pointy block in a pointy block, now to see if i can find why 15:31
colomon so what's wrong with it?
pmichaud argggh, getting lists and arrays to work is being endless FAIL for me :-| 15:32
something is fundamentally wrong here.
mathw :( 15:33
dalek kudo/ng: d5a8d9c | pmichaud++ | src/cheats/parrot/ (4 files):
Move some obsolete files out of the active build directories.
ash_ i looked at the generated pir code for (-> $a { -> $b { $a + $b } })(4)(4);
jnthn ash_++ # looking at that problem
ash_ the outer block isn't returning the block inside, its executing it 15:34
jnthn Oh
OK, some odd code-gen issue then. :-/
pmichaud it must think it's an immediate block
jnthn Aye.
Curious why it does that for nested ones.
ash_ its like 2 lines, its doing capture_lex $P3 \n $P4 = $P3() \n .return ($P4) 15:35
pmichaud perhaps it does it for non-nested one also
ash_ just 1 line needs to change in the genrated code
pmichaud pmichaud@orange:~/ng$ ./perl6
> -> { say 'hello' }
hello
I'm guessing it does it for all pointy blocks
ash_ ng: say (-> $a { 'hi' })(4); 15:36
p6eval ng d5a7de: hi␤
pmichaud that's not a bare block :-)
ng: -> $a { say 'hi' }
p6eval ng d5a7de: Not enough positional parameters passed; got 0 but expected 1␤current instr.: '_block22' pc 86 (EVAL_1:45)␤
pmichaud ng: -> { say 'hi' }
p6eval ng d5a7de: hi␤
ash_ ah
frettled
pmichaud I wonder if a pointy block is always a declaration -- i.e., not executed immediately (unless the other construct requires it) 15:37
moritz_ would make sense 15:38
pmichaud I'll try that. 15:39
ash_ for reference, anon sub's work fine if you do the same thing 15:43
ng: say (sub ($a) { sub ($b) { $a + $b } })(4)(4);
p6eval ng d5a7de: 8␤
ash_ may or may not mean anything though
pmichaud yes, because 'sub' forces the blocktype to be set to declaration
pmichaud I've just patched -> to do the same (I think, spectesting now) 15:43
pmichaud > say (-> $a { -> $b { $a + $b } })(4)(4); 15:44
8
ash_ pmichaud++ woot, want to try t/spec/S02-builtin_data_types/anon_block.rakudo 15:46
ash_ its the test i was trying to get working 15:46
pmichaud All tests successful.
pushed fix to github
jnthn \o/ 15:47
pmichaud ash_: thanks for finding that and giving such a good diagnosis -- made it easy to fix :) 15:47
ash_ no worries, if i find more i'll let someone know
pmichaud is the specific example you gave in the test file? perhaps it should be? 15:48
frettled pmichaud++ - excellent
pmichaud ah, I see it -- test #18
tests++
pmichaud laziness sure makes list assignment a lot more interesting 15:50
dalek kudo/ng: ee71f1e | pmichaud++ | src/Perl6/Actions.pm:
Force bare pointy subs to be treated as declarations instead of
15:51
pmichaud ($a, @b) = (@c, $a) # example
frettled o_O
pmichaud we can't just take the first element of @c, put it in $a, and then copy the rest of the rhs into @b, because @b should get the value of $a before the assignment 15:53
colomon yow 15:54
pmichaud we can't just iterate the rhs and make copies of everything before doing the assignment, because @c could be infinit
*e
(or otherwise lazy)
anyway, I think I have that problem worked out for now... but it's still bizarrely interesting to deal with 15:55
pmichaud right now I can't even get simple arrays to work properly. 15:55
ng: my $a = 5; my $b = [$a]; $a++; say $b.perl; # wrong
p6eval ng ee71f1: [6]␤
pmichaud I know what the bug is in the code, but all of the fixes I'm trying break things horribly
looks like I'll have to rethink the current implementation of map, list, and array 15:56
mathw Who wanted laziness? :) 15:57
It is cool, but it'd be a lot easier if we didn't have it
pmichaud oh, I suspect it's waterbed theory
pmichaud we can make the implementation easier without it, but we then push the complexity to the users 15:57
which is the wrong approach :)
PerlJam it's star trek: the needs of the many (users) out weigh the needs of the one (pmichaud) :-) 15:58
colomon is just glad he didn't tackle list assignment himself over the weekend... 16:00
frettled :) 16:02
pmichaud ng: my $a = (3,(4,5),6); say $a.perl 16:03
p6eval ng ee71f1: (3, 4, 5, 6)␤
pmichaud ng: my $a = List.new(3,(4,5),6); say $a.perl 16:04
p6eval ng ee71f1: (3, 4, 5, 6)␤
pmichaud ng: my @a = List.new(3,4); say @a.perl
p6eval ng ee71f1: [(3, 4)]␤
pmichaud ng: my @a = List.new(3,4); say @a.elems
p6eval ng ee71f1: 1␤
pmichaud ng: my @a = (3,4).list; say @a.elems 16:05
p6eval ng ee71f1: 2␤
ash_ ng: my @a = List.new(1, 2, 3).list; say @a.perl; 16:06
p6eval ng ee71f1: [(1, 2, 3)]␤
ash_ .list relies on @ context, which i don't think is functioning the way its supposed to
pmichaud I think List.new is bogus 16:07
colomon in concept or execution?
pmichaud execution
why isn't it just: method new(*@args) { @args } 16:08
ash_ my fault, i didn't know it could be that simple...
pmichaud oh, I know why
because that would return an Array
colomon because when you do that it fails miserably.
it's worse than that, it didn't actually ever get called.
pmichaud well, the problem with the current implementation is that it's not evaluating args in list context 16:09
er, that's not it. hrm.
ash_ ng: class Foo {}; augment class Foo { method new(*@args) { say 'hi' } }; my $a = Foo.new(1, 2); 16:10
p6eval ng ee71f1: ( no output )
ash_ is why i didn't augment List with a new method
for some reason, when you augment the class, it didn't get the new new
thats why i went with a .pir version in builtin/List.pir 16:11
pmichaud okay... reworking
ash_ as for the exact implementation, i was trying to do it the way you normally do, i didn't know i could return the @args
pmichaud well you can, but as I mentioned, @args would probably end up being an Array
and we want a List
ash_ trying to use bless and the like, since it gets inherited into Array, so i wanted to make sure it works with Array and List 16:12
ash_ btw, was pmichaud should augment be able to add a 'new' method? I don't see why not... if so, then i think augment may not be functioning the way you'd expect it to 16:13
pmichaud ash_: I agree that looks like a bug. Although you might want 'new' to be a multi there. 16:14
ash_ ng: class Foo {}; augment class Foo { multi method new(*@args) { say 'hi' } }; my $a = Foo.new(1, 2);
p6eval ng ee71f1: ( no output )
pmichaud ng: class Foo {}; augment class Foo { multi method bar(*@args) { say 'hi' } }; Foo.bar(1,2);
p6eval ng ee71f1: hi␤
pmichaud ng: class Foo {}; augment class Foo { multi method new(*@args) { say 'hi' } }; Foo.new(1,2); 16:15
p6eval ng ee71f1: ( no output )
pmichaud I'm guessing there's a method cache problem on 'new' there.
jnthn Method cache? :-/ 16:16
There's a problem of some kind though.
ash_ the default new does *@args, *%kwargs
pmichaud I did say it was a guess :-)
ash_ ng: class Foo {}; augment class Foo { method new(*@args, *%kwargs) { say 'hi' } }; my $a = Foo.new(1, 2);
p6eval ng ee71f1: ( no output )
jnthn pmichaud: Heh. I didn't realize there was a method cache. ;-) 16:16
pmichaud there might not be one. But didn't we have some sort of multidispatch cache somewhere?
jnthn Yeah, but adding a new method is meant to invalidate it. 16:17
ash_ ng: class Foo {}; augment class Foo { method new(*@args, *%kwargs) { say 'hi' } }; my $a = Foo.new(1, 2, :b<a>);
p6eval ng ee71f1: sh: ./perl6: No such file or directory␤
ash_ locally that still has no output
pmichaud right, so I'm guessing the multidispatch cache isn't being invalidated then
ash_ so... i never really figured out what was wrong, but i just thought i'd let someone that knows more about ng know
jnthn pmichaud: I'll try and hunt it down. 16:18
pmichaud > my @a = List.new(1,2); say @a.perl; 16:20
[1, 2]
better.
jnthn :-) 16:21
dalek kudo/ng: 57a8065 | pmichaud++ | src/builtins/List.pir:
Refactor List.new a bit; set 'flatten' flag so that lists created
16:25
pmichaud jnthn: I'm toying again with the idea of having all containers (including things held in arrays) as being Perl6Scalar, instead of the value type directly. 16:26
jnthn pmichaud: hm 16:28
jnthn pmichaud: We can haz extra GC overhead, that's the only issue... 16:28
pmichaud well, there's a dereferencing cost also
jnthn pmichaud: Rationale?
pmichaud well, the copy approach has its own GC overhead cost as well 16:29
because we end up making temporary clones that get thrown away
jnthn pmichaud: That is true, plus the copy costs.
frettled More powerful computers will take care of this within 1 femtillion years.
pmichaud we also incur the cost of asking each object "what is your value type"
jnthn pmichaud: It may well work out the same.
frettled Or was that pentillion? I forget.
jnthn Or perhaps better. 16:29
pmichaud if we can avoid the "value type" request, that might be a huge win 16:30
frettled jnthn: isn't it a bitch how doing things _properly_ almost always has a performance overhead? :)
jnthn :-P
pmichaud: There may well be.
pmichaud: I guess the forwarder PMC ain't too heavy either
And if the Parrot folks ever do generational GC, then we'd not end up scanning them all for long-lived aggregates so often. 16:31
frettled On a more serious note, it could perhaps be alleviated a bit by (ab)using multithreading a bit more, but I'm not _quite_ sure how to solve that technically. 16:31
frettled GC in a different thread is possible, but what about the other stuff, hmm. 16:31
pmichaud I'll think about it more over lunch 16:32
I just know that having the two different types of objects feels icky, and I *know* there's a performance overhead from asking objects about their value types when copying 16:33
jnthn pmichaud: Aye, there is. 16:36
[particle] is back. where should i start?
jnthn pmichaud: Anyway, no objections.
ash_ jnthn, any other test files giving errors that you know of that should be passing? 16:40
jnthn ash_: There's one test failing in S14-role/parameterized-basic.t 16:41
ash_: But I fear it may be trixky.
ash_: That one test is the only thing keeping us from a full pass though.
ash_ i can at least look at it 16:42
jnthn (in that test file)
ash_: IIRC it's to do with type parameters being used in siggies.
The answer may be that we need to clone the signature so it captures the correct type thunk closure. 16:43
That's my first guess anyway.
oh
you can clone the signature forming routine instead perhaps 16:44
jnthn Anyway, it may be something like that. It's my first guess, and knowing if it's what the actual problem is helpful, and a patch is even better. :-) 16:44
TimToady blurs into existence, in a Schrödinger's Catly way. 16:47
ash_ changing class rooms & 16:48
frettled TimToady: We're grateful that you blurred _into_ existence. 16:51
jnthn afk, krcma 17:08
pmichaud afk, lunch 17:21
pugs_svn r29571 | lwall++ | [S03,S07] bring list assignment descriptions into better alignment for pmichaud++ 17:25
ash_ ng: role F[::T] { method x(T $a) { say $a.WHAT; } }; class Foo does F[Int] { }; Foo.new.x(1); Foo.new.x('str'); 17:32
p6eval ng 57a806: Int()␤Nominal type check failed for parameter '$a'; expected { ... } but got Str instead␤current instr.: 'perl6;F[::T];x' pc 409 (EVAL_1:156)␤
Tene ng: class Foo {}; augment class Foo { method new(Int $n) { say 'lol' } }; Foo.new(5); 17:39
p6eval ng 57a806: ( no output )
Tene ng: class Foo {}; augment class Foo { multi method new(Int $n) { say 'lol' } }; Foo.new(5);
p6eval ng 57a806: ( no output )
ash_ wow, crazy bug jnthn, look at this: 17:43
ng: role F[::T] { method x(T $a) { return 'T was ' ~ T ~ ' and ' ~ $a.WHAT; } }; class Foo does F[Int] { }; class Bar does F[Str] { }; say Foo.new.x(10); say Bar.new.x('str'); say Foo.new.x('str');
p6eval ng 57a806: T was Int() and Int()␤T was Str() and Str()␤T was Int() and Str()␤
ash_ If you use a parametric type 2 times, it changed the definition of 1 of them after you use it, like, the Bar.new.x('str') changed Foo.new from Int to Str for some reason 17:44
well, to accept Str instead of enforcing to Int only
but it only seems to do it if you use the role twice 17:45
Tene ng: role F[::T] { method x(T $a) { return 'T was ' ~ T ~ ' and ~ $a.WHAT; } }; class Foo does F[Int] { }; say Foo.new.x('lol'); 17:47
p6eval ng 57a806: sh: ./perl6: No such file or directory␤
Tene ng: role F[::T] { method x(T $a) { return 'T was ' ~ T ~ ' and ~ $a.WHAT; } }; class Foo does F[Int] { }; say Foo.new.x('lol');
p6eval ng 57a806: sh: ./perl6: No such file or directory␤
Tene ng: role F[::T] { method x(T $a) { return 'T was ' ~ T ~ ' and ~ $a.WHAT; } }; class Foo does F[Int] { }; say Foo.new.x('lol'); 17:48
p6eval ng 57a806: sh: ./perl6: No such file or directory␤
Tene ng: role F[::T] { method x(T $a) { return 'T was ' ~ T ~ ' and ~ $a.WHAT; } }; class Foo does F[Int] { }; say Foo.new.x('lol'); 17:49
p6eval ng 57a806: sh: ./perl6: No such file or directory␤
ash_ ng: role F[::T] { method x(T $a) { return 'T was ' ~ T ~ ' and ' ~ $a.WHAT; } }; class Foo does F[Int] { }; say Foo.new.x('lol');
p6eval ng 57a806: sh: ./perl6: No such file or directory␤
Tene *sigh*
ash_ err, well Tene i think you are missing a ' after and
it runs locally if you add a ' after and
> role F[::T] { method x(T $a) { return 'T was ' ~ T ~ ' and ' ~ $a.WHAT; } }; class Foo does F[Int] { }; say Foo.new.x('lol');
Nominal type check failed for parameter '$a'; expected { ... } but got Str instead
Tene ng: role F[::T] { method x(T $a) { return 'T was ' ~ T ~ ' and ' ~ $a.WHAT; } }; class Foo does F[Int] { }; say Foo.new.x('lol'); 17:50
p6eval ng 57a806: Nominal type check failed for parameter '$a'; expected { ... } but got Str instead␤current instr.: 'perl6;F[::T];x' pc 393 (EVAL_1:152)␤
Tene ng: role F[::T] { method x(T $a) { return 'T was ' ~ T ~ ' and ' ~ $a.WHAT; } }; class Foo does F[Int] { }; say Foo.new.x(5); say Foo.new.x('lol');
p6eval ng 57a806: T was Int() and Int()␤Nominal type check failed for parameter '$a'; expected { ... } but got Str instead␤current instr.: 'perl6;F[::T];x' pc 431 (EVAL_1:158)␤
pugs_svn r29572 | lwall++ | [misc/pm.txt] some vaguely authoritative answers to recent pmichaud++ questions 17:51
PerlJam that error message is LTA too "expected { ... } but got Str instead" 18:03
pmichaud goes to read spec updates (TimToady++) 18:29
From r29571: When copying into an array destination, the list assignment is 18:33
+"mostly eager"; it requests the list to evaluate its leading iterators
+(and values) to the extent that they are known to be finite, and
+then suspend, returning the known values.
This seems at odds with the "mostly eager" definition in S07: Obtain all items, but does not try to eagerly evaluate when known to
be infinite.
"known to be infinite" != "not known to be finite" 18:34
so, do we suspend when we know something to be infinite, or when we can't prove it's finite? 18:35
or, to avoid the double negatives -- do we suspend as soon as we can't determine that something is finite, or when we can positively determine that something is infinite 18:36
(to me, "mostly eager" would imply the latter -- i.e., we iterate until we know something is infinite.) 18:37
frettled . o O (Oooh, I love semantics.) 18:40
pmichaud: perhaps we should separate between: lazy, mostly lazy, somewhat eager, mostly eager, and eager? :D 18:42
pmichaud frettled: only if assignment is in fact "somewhat eager"
frettled "somewhat eager" could be "indifferent", of course
pmichaud if assignment is "mostly eager" in the sense of "assign values until reaching a known infinite", then I don't know that we need the additional distinction 18:43
or, if "mostly eager" is in fact "obtain all items until reaching something that isn't known to be finite", then we don't need the additional distinction
frettled yep
it seems to me that there is a potential use for the distinction, that a programmer might sometimes want one behaviour over the other 18:44
pmichaud well, we have some additional operators for that :-)
frettled :)
pmichaud my question is more about "what does array assignment do" :-)
frettled I think that in most cases, we want it to be the second meaning 18:45
It ought to be more predictable as well.
pmichaud second meaning being...?
frettled "obtain all items until reaching something that isn't known to be finite" 18:46
pmichaud ah
so, in that case
my @a = $file.lines();
would not consume the entire file
because it would stop at the first sign of the iterator
pmichaud (unless the iterator itself can somehow determine that the file is of finite length) 18:46
ash_ how would you eagerly load the file lines then? just curious 18:47
PerlJam ash_: my @a = eager $file.lines();
pmichaud ash_: I suspect: my @a = eager $files.lines()
frettled pmichaud: hmm, yes...
ash_ gotya
so... can a List be infinite? or are infinite containers always arrays or a special container? 18:48
pmichaud Lists can be infinite, yes.
[particle] what's @a's length after my @a = $file.lines(); ?
pmichaud ENOLENGTHINPERL6
[particle] yes, i know
but i forget the proper term
elements?
ash_ +@a
pmichaud but if you mean @a.elems, then that would cause the file to be consumed at that point
ash_ or @a.elems
[particle] perfect
pmichaud which could then hang at that point if the file was in fact infinite :-) 18:49
[particle] so 'my @a = $file.lines()' is lazy
frettled heh
PerlJam [particle]: maybe
ash_ my @a = $socket.lines(); say +@a; # timeout :P
[particle] laziness is a virtue
pmichaud my @a = $files.lines() being lazy would surprise P5 programmers, yes.
frettled I like it. 18:50
pmichaud we would also end up with weird things like
PerlJam frettled: you like surprising programmers?
pmichaud my @a = ($files.lines(), $b*2)
frettled PerlJam: :)
pmichaud oh, wait
my @a = ($files.lines(), $b)
when does $b get evaluated?
[particle] i prefer that the computer procrastinates, just like i do. it's what i expect.
PerlJam [particle]++ :) 18:51
frettled heh
[particle] pmichaud: hopefully there's a way to warn about that, and suggest 'eager'
pmichaud my $b = 5; my @a = ($file.lines(), $b); $b = $b + 1; say @a[*-1]; # 5 or 6?
frettled In the case of file parsing, I think that programmers will expect there to be an easy, concise way of saying that you want to slurp it all without knowing the length in advance.
pmichaud frettled: that was .lines, iirc :-) 18:52
frettled pmichaud: yep
ash_ ng: my $a = (1, 2, 3); for @($a) { say $_; }
p6eval ng 57a806: 1 2 3␤
ash_ ng: my $a = (1, 2, 3); for @($a) { say $_.perl; }
p6eval ng 57a806: (1, 2, 3)␤
pmichaud ng: my $a = (1,2,3); for $a.list { say $_.perl; } 18:53
p6eval ng 57a806: 1␤2␤3␤
pmichaud ng: my $a = (1,2,3); say $a.WHAT; 18:54
p6eval ng 57a806: List()␤
frettled pmichaud: seriously, though, I'm of two minds; in the general case, I think it would be less surprising if we had a "somewhat eager" behaviour, but in some special cases -- such as processing input -- it's more convenient that it's different. But I don't like special cases, so, er. :)
ash_ sweet, didn't realize that worked
.list that is
pmichaud that's supposedly what @(...) does
ash_ well, then i'd call @(...) a liar :P 18:55
pmichaud although S03:2116 says otherwise :-( 18:56
pmichaud according to S03:2116, @(...) is the same as "list (...)" 18:56
or "list ..."
ash_ well shouldn't the list prefix cause .list? 18:57
pmichaud no
list prefix simply evaluates its arguments in list context
and $a in list context never flattens
ash_ well, i'll just have to remember to use .list on scalars sigil's then 18:58
pmichaud well, @$a should be the same as $a.list
but nyi
ash_ ah, whats different between @$a and @($a) then? i mean, i kinda thought list context of something would make it sorta iterate-able (is that a word?) 19:00
pmichaud @$a tells $a "return yourself as a list" 19:02
while "list $a" says "evaluate yourself in list context"
(and currently the spec indicates that @($a) is the same as "list $a"
jonasbn pmichaud: ping me when you have some time to discuss the Copenhagen hackathon
pmichaud jonasbn: will you be around tomorrow?
jonasbn yes
pmichaud that might be better for me
jonasbn super 19:03
I might have more details settled by then
pmichaud excellent
ash_: so, given my $a = [1,2,3]
(list $a).elems == 1
(@$a).elems == 3
ash_ i guess i didn't understand what list context meant 19:05
pmichaud yes, it's a difficult distinction (took me a long time to understand the difference, and even today I sometimes pick the wrong one) 19:06
frettled oh! 19:09
I think I get it; in list context, you look at it as one thing, not at individual elements.
pmichaud in list context, you flatten it if it's a flattening object 19:10
and scalar variables never flatten by default
my $a = (1,2,3); say (list $a); # 1
my @b = (1,2,3); say (list @b); # 3
oops 19:11
forgot the .elems
my $a = (1,2,3); say (list $a).elems; # 1
my @b = (1,2,3); say (list @b).elems; # 3
frettled So, hmm, my @b = (1,(2,3),4); say (list @b).elems; # 4?
pmichaud sure, but @b.elems would be 4 also :-) 19:12
frettled d'oh :)
[particle] my $a = (2,3); my @b = (1,$a,4); say (list @b).elems; #3
pmichaud [particle]: correct 19:13
frettled but with my @a = (2,3); ..., it would be 4?
[particle] aye
frettled Then I think I may have understood flattening a bit.
pmichaud but in these last two cases, it's because the assignment to @b is doing the flattening 19:14
ash_ so really list and @() are for flatteningthings ?
pmichaud for flattening things that flatten in list context
frettled :)
pmichaud (I'm still not entirely certain about @() yet)
ash_ the spec says list and @() are funcitonally the same except @() takes $/ as a default parameter 19:15
PerlJam Lists and Arrays are very fundamental. It seems a shame that the semantics surrounding them haven't been nailed down so that they can be explained to a newbie
pmichaud sorry, I meant @(...) 19:16
@() means $/.list
PerlJam why have the exception though?
ash_ spec: S03 regarding list: Forces the subsequent expression to be evaluated in list context. A list of Captures will be transformed into a flat list. Equivalent to @(...) (except that empty @() means @($/), while empty list() means an empty list). 19:17
PerlJam thinks the @() exception should go away
pugs_svn r29573 | pmichaud++ | [pm.txt]: A confirmation request for TimToady++ / others. 19:18
r29573 |
r29573 | Pm-18: (Confirmation request) S03:2111 indicates that the C< @(...) >
r29573 | sigil contextualizer is the same as the C<list> listop. Is this correct?
r29573 | In particular, given C< my $a = [1,2,3]; >, then C< @($a) > is 1 and
r29573 | C< @$a > is 3 ? (For some reason I had been thinking that @($a) would
r29573 | act more like $a.list than list($a) .)
pmichaud ugh, forgot .elems or + again 19:19
afk, errand
pugs_svn r29574 | pmichaud++ | [pm.txt]: Typo correction in question. 19:20
ash_ coming from a complete newb in this respect. list context, in plain english, makes me think it takes the object and converts it to a list, so i was expecting @($a) to do something like wrapper the .List function or .list, in short, i expected, saying $a = 1, 2, 3; for @($a) { say $_ } to iterate through 1, 2, 3 19:21
frettled When I read "list context", I understand it as "treat the thing as if it was a list". I don't expect conversion until I assign it. 19:23
That is, if I have an RHS (right hand side) of an expression that's in list context, I ought to use a list thingy on the LHS. 19:24
and vice versa, of course
ash_ well, if list context returned the object it was given in list form, then when you use it in a for loop, i thought it would iterate the list form, again, i think i am misunderstanding list context though 19:25
PerlJam ash_: I don't think so. 19:28
ash_ rakudo: my $a = 1, 2, 3; for @($a) { say $_ } 19:33
p6eval rakudo 1d4928: 1␤2␤3␤
ash_ ng: my $a = 1, 2, 3; for @($a) { say $_ }
p6eval ng 57a806: 1 2 3␤
ash_ also contributed to my view of @()
pmichaud rakudo has it wrong (per the spec) there. 19:35
ash_: perhaps it makes more sense to think of @(...) in the sense of @($a, 3)
i.e., we expect @($a, 3) to have two elements, even if $a is itself a list
ash_ ng: my $a = 1, 2; for @($a, 3) { say $_.perl } 19:36
p6eval ng 57a806: (1, 2)␤3␤
ash_ so, like that, right?
pmichaud according to the current spec, yes. 19:37
ash_ yeah, i see that now, that makes sense
pmichaud I'd prefer that we wait for confirmation of the meaning of @(...) and stick to @$a, list($a), and/or $a.list
frettled :)
pmichaud in the case of something like for @($a) { say $_.perl } the @(...) is redundant 19:38
(per the current spec)
frettled aha
ash_ well, list(List.new(1, 2, 3)) is wrong then, so you know
frettled Would this make any sense:
ash_ ng: for list(List.new(1, 2, 3)) { say $_.perl }
p6eval ng 57a806: (1, 2, 3)␤
frettled $a = (1, 2); $b = (4, 5); for @($a, 3, $b) { say $_.perl } 19:39
pmichaud you're correct, list() has that wrong.
ash_ my fault on that one then 19:40
ash_ err, wait, i didn't write list, never mind, woot, not my fault :P i only did List.new 19:42
which was also wrong :-\
ash_ do any of the loop constructs have a specific method they use? like 'for' for instance? 19:46
pmichaud 'for' is really 'map' 19:47
for ... { block } is really the same as list(...).map({block})
(it's not that way yet in rakudo/ng, but it will be.)
ash_ so, if you had an object that implemented a .map function, and you did for $my_obj { } it would reference the .map? 19:48
pmichaud no
because it does the .map on list($my_obj)
i.e., $my_obj is first evaluated in list context 19:49
which will create a list containing $my_obj
ash_ so... making your own iterator using gather is probably the 'right way' of doing something like that then? (ie: $my_obj.each({ }); 19:50
where each is using a gather construct or something
pmichaud well, you can still create your own .map -- it just isn't used by default with "for"
or you can define how $my_obj.list() works 19:52
(i.e., it can return an iterator that 'for' then uses)
ash_ then you'd call it like: for $m_obj.list() { }
or @$ i suppose 19:53
pmichaud yes, or for @$m_obj { ... }
exactly
Tene or: for $obj.magic_iter_lol() { ... }
ash_ hm, is there something that functions like the with operator in python? just curious 19:54
pmichaud given?
given $expr { ... }
oh, that's a bit different 19:55
ash_ but, you can override a function callback, is what i mean, so if you have a thread condition for instance, and you use with my_obj: it aquires the lock, then releases it at the end of the block
or any of the other various uses of with
dalek kudo/ng: 839da4d | pmichaud++ | src/builtins/List.pir:
Make sure that list() returns a List that is fully initialized and
19:56
pmichaud I don't know if there's any exact analogue in Perl 6. 19:57
ash_ it wouldn't be hard to make something like that if i wanted to use one in my own code, i was just wondering if there was something along those lines built in 19:57
Tene ash_: can you post an example? 19:59
ash_ of? 20:00
Tene I'm not familiar with python's 'with'
ash_ sure, one sec 20:02
ash_ well, docs.activestate.com/activepython/3...w/2.6.html has some good examples see the section titled: PEP 343: The ‘with’ statement 20:02
they use it with a file at one point, with open('/etc/passwd', 'r') as f: it automatically opens and closes the file when it first enters and later exits the with block, or the lock example acquires and releases the conditional 20:03
its really just sugar 20:04
but sometimes that means i get to write 2 less lines of code here or there
another nice use of it i have seen is in a ORM the use it for transactions, so it starts the transaction when you enter the with statement, and applies it if you make it to the end of the statement 20:08
pugs_svn r29575 | pmichaud++ | [pm.txt] Followup question to Pm-16 answer (see diff for details). 20:12
pmichaud given $f = open('/etc/passwd') { LEAVE { $f.close }; ... } 20:13
or, even
given open('/etc/passwd') { ...; LEAVE { .close } } 20:14
and the opened file is in $_
ash_ yeah, like i said, i can do the same thing or, extend the grammar if need be, i was more just curious since i haven't come across something that behaves like that
pmichaud if open('/etc/passwd') -> $f { ...; LEAVE { .close } } 20:15
er
if open('/etc/passwd') -> $f { ...; LEAVE { $f.close } }
and the else clause handles the case of the file not opening successfully :-)
pmichaud given open('/etc/passwd') { for .lines { .... }; LEAVE { .close } } 20:16
pmichaud given open('/etc/passwd') || die "open fail" { for .lines { .... }; LEAVE { .close } } 20:17
something like those :-) 20:18
ash_ see the only difference from that and python's with is any object can register a callback function for when you use it (its __enter__ and __exit__ ) 20:18
jnthn ash_: Yes, the "crazy bug" that we're hunting is exactly that. :-)
ash_: It's not so crazy - we just use closure semantics to make it work.
ash_: But we're missing some cloning to keep the right static chain attached somewhere. 20:19
ash_ jnthn i think its in role compose or classhow compose btw
jnthn ash_: Doubt it.
jnthn ash_: Or at least, you maybe could fix it there, but it'd be the wrong place. 20:19
pmichaud ng: for list(List.new(1,2,3)) { say $_.perl }
p6eval ng 57a806: sh: ./perl6: No such file or directory␤
jnthn ash_: We call .clone on the Method objects which should be enough... 20:20
but apparently it's not
pmichaud ng: for list(List.new(1,2,3)) { say $_.perl }
p6eval ng 839da4: 1␤2␤3␤
pmichaud \o/
jnthn pmichaud: Yay!
pmichaud that might also have been the bug that was plaguing me last night/earlier today with list assignment 20:21
I'll have to go back and try again
ash_ jnthn, what about in !select in the role then? 20:22
thats when it applies the Int in Foo[Int]
well, it does postcircumfix:<[ ]> which calls self.!select
jnthn ash_: Right, but the .clone is emitted in src/Perl6/Compiler/Role.pm 20:25
ash_: The select is what gets us to the role body.
ash_: Note that we end up running the body of a role Foo[::T] { } once for each type parameterization that is used.
ash_ is there a reason the --target=pir would have a sub with 2 :anon's? its apparently not an error, just seems odd 20:27
pmichaud it may be that rakudo is adding an :anon flag, and then PAST is adding another 20:29
jnthn Does seem odd. 20:30
jnthn gotta go again now - back later
pmichaud afk, errand 20:31
ash_ perl6 --target=pir -e "role Foo { }" then find the definition of Foo[] it consistantly has 2 :anon, not a bug just an oddity
dalek kudo/ng: c36717d | pmichaud++ | src/builtins/Array.pir:
Fix circumfix:<[ ]> to properly copy (STORE) values in an Array,
23:40
kudo/ng: 47ef21b | pmichaud++ | src/builtins/ (3 files):
Adjust List!generate to always (lazily) flatten RPAs and Parcels

them. This fixes empty [] to create an empty Array, as well as reduce the number of places that we need to set the 'flatten' flag.
kudo/ng: 89fb627 | pmichaud++ | src/builtins/ (2 files):
Enable basic list assignment. Doesn't seem to work yet with
pmichaud jnthn: we seem to be FAIL on list declarations... any clues? 23:44
ng: my ($a, $b);
p6eval ng 839da4: Redeclaration of symbol $a at line 1, near ";"␤current instr.: 'perl6;HLL;Grammar;panic' pc 500 (src/stage0/HLL-s0.pir:328)␤
pmichaud I may be able to take a look at it a bit later.
Tene pmichaud: Out of curiosity, what was the main desire for tt389 (keep methods out of namespaces)? 23:45
I've got it down to 3 test failures. 23:46
The p6object one is awkward to debug, though. :( 23:47