»ö« | perl6-projects.org/ | nopaste: paste.lisp.org/new/perl6 | evalbot: perl6: say 3;' | irclog: irc.pugscode.org/ | UTF-8 is our friend!
Set by moritz_ on 27 June 2009.
cbk_ tann, yah TimToady is really good and knows allot of perl 00:00
TimToady #perl6 is the land of seeing accurately, and sometimes that makes one feel like crap
tann cbk_: of course, he does! ;)
TimToady included
cbk_ rakudo: %petList($pet).kv -> $key, $value; 00:02
p6eval rakudo 02d0ed: OUTPUT«Statement not terminated properly at line 2, near "-> $key, $"␤in Main (src/gen_setting.pm:3340)␤»
cbk_ I just can't find a way or a good example on how to set a the value of a particular key 00:03
tann $pet_list{$pet} = "parrot";
oops
%pet_list{'parrot'} = 'miago';
rakudo: my %pet_list; %pet_list{parrot} = 'miago'; say %pet_list.perl; 00:04
p6eval rakudo 02d0ed: OUTPUT«Could not find non-existent sub parrot␤»
tann rakudo: my %pet_list; %pet_list{'parrot'} = 'miago'; say %pet_list.perl;
p6eval rakudo 02d0ed: OUTPUT«{"parrot" => "miago"}␤» 00:05
cbk_ I was getting an error like that earlier
TimToady do autoquoting with <parrot> instead of {parrot} in p6
tann so p6 no longer stringifies hash keys 00:05
s/no longer/does not/
like p5
TimToady well, that's an odd way to say it
by default, hash keys still are strings
but the autoquoting rules are revised 00:06
eternaleye tann: <stuff> is like qw/stuff/, and <<stuff>> is like qqw/stuff/
(not sure about the last)
TimToady you still get autoquoting on =>, as in parrot => 'miago'
but not inside {}
we use separate syntax for string keys now %pet_list<parrot>
eternaleye (in anycase, <<stuff>> is doublequoted splits-on-whitespace)
TimToady <stuff> splits on whitespace too 00:07
<<stuff>> also allows shell-style quoting and interpolation
tann rakudo: my %list<parrot dog mouse> = <miago pluto micky>; say %list.perl; 00:08
p6eval rakudo 02d0ed: OUTPUT«Could not find non-existent sub mouse␤»
eternaleye TimToady: Hence my originally saying it was like qw//, I was making the distinction between <stuff> and <<stuff>> as being singlequoting : doublequoting
TimToady yes, to the first approximation
but << foo "bar baz" "$x" >> will certain have exactly three elements 00:09
regardless of how many words are in $x
cbk_ well how do handle something like where the value is a number and you want to increment that value? Like $value = $value + 1
eternaleye Nice, I wasn't aware of that!
TimToady well, that would work
cbk_ the key is the name of the pet and the value is the number of votes 00:10
TimToady but often people use autoincrement
which is $value++
eternaleye cbk_: see also $v += 1 and $v++ and ++$v
TimToady all of which work as in C
rakudo: my $value = 0; say ++$value 00:11
p6eval rakudo 02d0ed: OUTPUT«1␤»
tann rakudo: my $x = "aaa"; say ++$x;
p6eval rakudo 02d0ed: OUTPUT«aab␤»
TimToady showoff :) 00:12
cbk_ %pet_list; %pet_list{'parrot'} = 'miago'; this sets the key but I want find the key then do a $value++
on that key
tann %pet_list<parrot>++;
TimToady which ends up with 'miagp' :)
cbk_ TimToady, I was hoping it woud be that easy :( 00:13
TimToady or do you want miago to have a number that you increment?
tann rakudo: my %list = (parrot => 0); %list<parrot>; say %list<parrot>
p6eval rakudo 02d0ed: OUTPUT«0␤»
TimToady %pet_list<parrot><miago>++
tann rakudo: my %list = (parrot => 0); %list<parrot>++; say %list<parrot> 00:14
p6eval rakudo 02d0ed: OUTPUT«1␤»
cbk_ what does OUTPUT <<1>> mean from p6eval?
TimToady it means that's the current value of %list<parrot> 00:15
tann melikes <> .. qw() just urgg...timtoady's thing
TimToady as seen by the 'say' command
timbunce What's the rakudo equivalent of perl5's -I option to add directories to the search path? I can't seem to find one.
TimToady it's possible it pays attention to PERL6LIB
tann cbk_: <<1>> is just the output format of p6eval...rakudo evaluates the code .. and in this case, it sees %list<parrot> has a value of 1 00:16
timbunce I see PERL6LIB in src/builtins/globals.pir - great. That'll do for now. Thanks 00:17
TimToady if it works :)
cbk_ ok
tann if it doesn, try again..rakudo is known to be very disagreeable as pmichaud said
tann i'm getting all excited..looks like tim is hacking on dbi 2.0 for p6 00:19
timbunce If someone could add line number info to the "Use of type object as value" error I'd be grateful. 00:20
eternaleye rakudo: ( '!edHllo owr,l'.comb Z ( 12, 1, 11, 0, 2, 3, 4, 6, 8, 7, 9, 5, 10 ) ).map( {; $^b => $^a } ).sort.map( *.value ).say 00:21
p6eval rakudo 02d0ed: ( no output ) 00:21
eternaleye rakudo: ( '!edHllo owr,l'.comb Z ( 12, 1, 11, 0, 2, 3, 4, 6, 8, 7, 9, 5, 10 ) ).map( {; $^b => $^a } ).sort.map( *.value ).say
p6eval rakudo 02d0ed: OUTPUT«Hello, world!␤»
cbk_ eternaleye: nice! 00:22
tann moritz_: tim is calling you out
cbk_ TimToady, yes miago was really just going to be a number not a word, and that way I want to add to it. this hash represents the number of votes a pet gets. like dog would be the key and 1 would be the value. and then we also have bird with a value of 2 00:32
would I have to pull out the key/values out first then find the matching key and then ++ the value? 00:34
TimToady what are you imagining when you say "pull out"? 00:35
TimToady the whole point of associative arrays is to avoid dealing with all the elements 00:35
cbk_ like using a for loop to find the matching key and then use kv to put values into $key and $value then just use $key and $value to update the %hash ? 00:36
TimToady rakudo: my %votes; my $pet = 'parrot'; %votes{$pet}++; %votes{$pet}++; say %votes.perl 00:37
p6eval rakudo 02d0ed: ( no output )
TimToady rakudo: my %votes; my $pet = 'parrot'; %votes{$pet}++; %votes{$pet}++; say %votes.perl
p6eval rakudo 02d0ed: ( no output )
TimToady hmm, probably recompiling
but yes, any time you find yourself iterating over the keys of a hash to find a particular entry, you're misusing hashes 00:38
it would be like looking at all the indexes of an array to see which one is 5 when you already know you want @array[5] directly 00:39
cbk_ TimToady, this is what I was trying to do before I knew I could do something like this %petList<dog>++ (I know this only changes the key)
TimToady it changest the value corresponding to the key
*changes
it doesn't change the key, which is still 'dog'
that is how we prefer to say it 00:40
TimToady rakudo: my %votes; my $pet = 'parrot'; %votes{$pet}++; %votes{$pet}++; say %votes.perl 00:42
p6eval rakudo 02d0ed: OUTPUT«{"parrot" => 2}␤»
cbk_ well i was going to do something like this: get the key/value for pet in question then do %petList<$value><$key>++
TimToady which won't work at all 00:43
because <> *quotes*
use {} for normal subscripting with a variable
cbk_ ok
TimToady but I don't understand why you're trying to subscript using $value anyway 00:44
what do you think it refers to?
and why are you using a value as a key? 00:45
cbk_ well I was just trying to solve my increment the value problem any way I could
TimToady you need to think about these things clearly; you can't just type random code and hope it works
the value is the destination, it's not the path to the destination 00:46
all you have to do to find the destination is talk about the path to the destination
the value will automatically be there at the end of the path 00:47
cbk_ It seams like most of the perl 6 examples on the net don't work because they are out of date :( thats why I was trying other things
TimToady so %votes{$pet} is all you need to get to the number of votes for that particular key
cbk_ oh! 00:48
TimToady rakudo: my %votes; for <parrot dog fish dog cat dog parrot> -> $pet { %votes{$pet}++; }; say %votes.perl
p6eval rakudo 02d0ed: OUTPUT«{"parrot" => 2, "dog" => 3, "fish" => 1, "cat" => 1}␤»
TimToady rakudo: my %votes; for <parrot dog fish dog cat dog parrot> -> $pet { %votes{$pet}++; }; say %votes<dog> 00:49
p6eval rakudo 02d0ed: OUTPUT«3␤»
TimToady rakudo: my %votes; for <parrot dog fish dog cat dog parrot> -> $pet { %votes{$pet}++; }; say %votes{'dog'} # same thing 00:50
p6eval rakudo 02d0ed: OUTPUT«3␤»
cbk_ that looks like it works. let me digest it for about a hour. :) 00:51
TimToady have the appropriate amount of fun :)
cbk_ TimToady, by the way I'm only working on perl 6 programs like this because the lack of them on the net. will post all my perl 6 examples to my website: independentcomputing.biz/ 00:53
watch out I have a html 5 <video> which has a auto plays there and is quite annoying 00:54
sorry
literal there's also a perl6-examples repository on github which you might want to contribute to 00:56
github.com/perl6/perl6-examples/tree/master 00:57
cbk_ well I wanted to at least get some working examples there first. I have been using the gethub example page for most of my perl 6 examples
by the way, When wizard.pl was the reason I started all this. I would like to get that to work in perl 6! 00:59
looks like fun!
tann cbk_: you might wanna format your code within html tags such as <code> ... </code> or <pre>...</pre> so the indentation doesn't get all messed up 01:01
cbk_ tann, thats a drupl thing :( I 01:02
i'm using a out of the box theme and have not the time to fix it
tann cbk_: doesn't it give you the option to do html tags? it shoud 01:03
no
cbk_ the code is in fact in side <code> tags
tann in the editor, there should be an option to switch to raw html
cbk_ yes it does all my post are made as full html 01:04
tann replace code by pre
cbk_ with code inside <code></code> tags
tann and see if it properly formats your code
cbk_ ok
cbk_ tann, that worked! thanks much. (Now I have to set my tab size to like 2 or 3 spaces) 01:08
tann cbk_: what's petReq for? 01:11
cbk_ pet request list. ( a pet has to be requested 3 times before it get on the available list. 01:12
I know it's kinda of a useless example but I think it will help others learn perl 6 and show some more completed things 01:13
tann rakudo: my %h = (a => 1, b => 2); my $v = %h.delete('a'); say $v; say %h.perl; 01:14
p6eval rakudo 02d0ed: OUTPUT«1␤{"b" => 2}␤»
cbk_ I have a non OO version that does work and now the OO version is kicking my butt
please don use the code thats on my site now. It was a early version and was not really complete. I need to update that. (After dinner) brb 01:16
tann rakudo: class PetList { my %petList; method checkList(Int $petID) { if ++%petList{$petID} > 2 { say "you can have this pet $petID" } else { say "not yet: $petID" } } }; 01:21
p6eval rakudo 02d0ed: ( no output )
tann cbk_: ^^^ along those lines 01:22
eternaleye rakudo: class PetList( has %.petlist; method checkList( Str $petType ) { ++%petList{$petType} > 2 ?? say "Sure, you can have a $petType!" !! say "You're the fifth person I've told today, we don't stock that as there's no call for it!"; } }; my $list = PetList.new; for <dog cat budgie parakeet dog elephant dog> -> $pet { $list.checkList( $pet) }; 01:29
p6eval rakudo 02d0ed: OUTPUT«Unable to parse class definition at line 2, near "( has %.pe"␤in Main (src/gen_setting.pm:1490)␤»
eternaleye rakudo: class PetList { has %.petlist; method checkList( Str $petType ) { ++%petList{$petType} > 2 ?? say "Sure, you can have a $petType!" !! say "You're the fifth person I've told today, we don't stock that as there's no call for it!"; } }; my $list = PetList.new; for <dog cat budgie parakeet dog elephant dog> -> $pet { $list.checkList( $pet) };
p6eval rakudo 02d0ed: OUTPUT«Symbol '%petList' not predeclared in checkList (/tmp/x8hcNK1R1P:2)␤in Main (src/gen_setting.pm:3340)␤»
eternaleye rakudo: class PetList { has %.petList; method checkList( Str $petType ) { ++%petList{$petType} > 2 ?? say "Sure, you can have a $petType!" !! say "You're the fifth person I've told today, we don't stock that as there's no call for it!"; } }; my $list = PetList.new; for <dog cat budgie parakeet dog elephant dog> -> $pet { $list.checkList( $pet) };
p6eval rakudo 02d0ed: OUTPUT«Symbol '%petList' not predeclared in checkList (/tmp/W7dc5ARxJt:2)␤in Main (src/gen_setting.pm:3340)␤»
eternaleye rakudo: class PetList { has %.petList; method checkList( Str $petType ) { ++%.petList{$petType} > 2 ?? say "Sure, you can have a $petType!" !! say "You're the fifth person I've told today, we don't stock that as there's no call for it!"; } }; my $list = PetList.new; for <dog cat budgie parakeet dog elephant dog> -> $pet { $list.checkList( $pet) };
p6eval rakudo 02d0ed: OUTPUT«You're the fifth person I've told today, we don't stock that as there's no call for it!␤You're the fifth person I've told today, we don't stock that as there's no call for it!␤You're the fifth person I've told today, we don't stock that as there's no call for it!␤You're the
..fifth p…
eternaleye Drat, too many
rakudo: class PetList { has %.petList; method checkList( Str $petType ) { ++%.petList{$petType} > 2 ?? say "Sure, you can have a $petType!" !! say "You're the fifth person I've told today, we don't stock that as there's no call for it!"; } }; my $list = PetList.new; for <dog cat dog elephant dog> -> $pet { $list.checkList( $pet) }; 01:30
p6eval rakudo 02d0ed: OUTPUT«You're the fifth person I've told today, we don't stock that as there's no call for it!␤You're the fifth person I've told today, we don't stock that as there's no call for it!␤You're the fifth person I've told today, we don't stock that as there's no call for it!␤You're the
..fifth p…
eternaleye rakudo: class PetList { has %.petList; method checkList( Str $petType ) { ++%.petList{$petType} > 2 ?? say "Sure, you can have a $petType!" !! say "We don't have any $petType."; } }; my $list = PetList.new; for <dog cat dog elephant dog> -> $pet { $list.checkList( $pet) };
p6eval rakudo 02d0ed: OUTPUT«We don't have any dog.␤We don't have any cat.␤We don't have any dog.␤We don't have any elephant.␤Sure, you can have a dog!␤»
eternaleye cbk_: tann: ^^^ 01:31
cbk_ eternaleye, I'm looking at now....
cbk_ eternaleye, I REALLY like how you did that checkList method! I was trying to keep %petList inside the class though to keep the data private. but it looks like this is the easiest way 01:39
eternaleye cbk_: It is inside the class - in a class, 'my' declares a static variable and 'has' declares an instance variable IIRC 01:41
rakudo: class PetList { has %.petList; method checkList( Str $petType ) { ++%.petList{$petType} > 2 ?? say "Sure, you can have a $petType!" !! say "We don't have any $petType."; } }; say %.petList 01:42
p6eval rakudo 02d0ed: OUTPUT«Lexical 'self' not found␤»
eternaleye rakudo: class PetList { has %.petList; method checkList( Str $petType ) { ++%.petList{$petType} > 2 ?? say "Sure, you can have a $petType!" !! say "We don't have any $petType."; } }; say %petList
p6eval rakudo 02d0ed: OUTPUT«Symbol '%petList' not predeclared in <anonymous> (/tmp/aCcLp0D1rl:2)␤in Main (src/gen_setting.pm:3340)␤»
cbk_ eternaleye, oh sorry would help if i was viewing the whole thing.
eternaleye What's more, it autogenerates an accessor
rakudo: class PetList { has %.petList; method checkList( Str $petType ) { ++%.petList{$petType} > 2 ?? say "Sure, you can have a $petType!" !! say "We don't have any $petType."; } }; PetList.new.petList.say 01:43
p6eval rakudo 02d0ed: OUTPUT«␤»
eternaleye rakudo: class PetList { has %.petList; method checkList( Str $petType ) { ++%.petList{$petType} > 2 ?? say "Sure, you can have a $petType!" !! say "We don't have any $petType."; } }; my $list = PetList.new; $list.checkList( 'dog' ); list.checkList( 'cat' ); $list.petList.perl.say 01:44
p6eval rakudo 02d0ed: OUTPUT«We don't have any dog.␤Method 'checkList' not found for invocant of class 'List'␤»
eternaleye rakudo: class PetList { has %.petList; method checkList( Str $petType ) { ++%.petList{$petType} > 2 ?? say "Sure, you can have a $petType!" !! say "We don't have any $petType."; } }; my $list = PetList.new; $list.checkList( 'dog' ); list.checklist( 'cat' ); $list.petList.perl.say
p6eval rakudo 02d0ed: OUTPUT«We don't have any dog.␤Method 'checklist' not found for invocant of class 'List'␤»
eternaleye rakudo: class PetList { has %.petList; method checkList( Str $petType ) { ++%.petList{$petType} > 2 ?? say "Sure, you can have a $petType!" !! say "We don't have any $petType."; } }; my $list = PetList.new; $list.checkList( 'dog' ); $list.checkList( 'cat' ); $list.petList.perl.say
p6eval rakudo 02d0ed: OUTPUT«We don't have any dog.␤We don't have any cat.␤{"dog" => 1, "cat" => 1}␤»
eternaleye 'has' is kind of a special declarator: $.variable is an attribute with an accessor, 'is rw' adds a mutator, and $!variable is a private attribute. 01:45
Although... It might be that it's not 'has' that does the magic, and it would work for static attributes too. I'm not sure; I'll go read the spec 01:47
cbk_: so you could change %.petList to %!petList if you wanted it to be a private attribute 01:48
cbk_ eternaleye, yah I had that in one of my first try's but removed them because errors. but now that I know it does I will put it back in.
azawawi good morning 03:52
TimToady howdy 03:59
azawawi std: =$fh 04:04
p6eval std 27503: OUTPUT«##### PARSE FAILED #####␤Illegal pod directive at /tmp/VufZL1LYU2 line 1:␤------> =$fh␤ expecting pod_comment␤FAILED 00:02 35m␤»
azawawi std: =$fh =end 04:05
p6eval std 27503: OUTPUT«##### PARSE FAILED #####␤Illegal pod directive at /tmp/HzQXUiMsbe line 1:␤------> =$fh =end␤ expecting pod_comment␤FAILED 00:02 35m␤»
azawawi std: =begin =$fh =end 04:06
p6eval std 27503: OUTPUT«##### PARSE FAILED #####␤Unrecognized token after =begin at /tmp/lOth4SDpQ9 line 1:␤------> =begin =$fh =end␤FAILED 00:02 35m␤»
azawawi TimToady: how can i get trigger the error "Obsolete pod format, please use =begin/=end instead" for =$fh
TimToady std: =head1 Foo␤␤stuff␤␤=cut 04:08
p6eval std 27503: OUTPUT«##### PARSE FAILED #####␤Obsolete pod format, please use =begin/=end instead at /tmp/ofNHJzP69w line 1:␤------> =head1 Foo␤ expecting pod_comment␤FAILED 00:02 35m␤»
azawawi TimToady: thx 04:10
eternaleye std: ␠=$fh 04:16
p6eval std 27503: OUTPUT«##### PARSE FAILED #####␤Can't understand next input--giving up at /tmp/GkwZsx3Btm line 1:␤------> ␠=$fh␤ expecting any of:␤ prefix or noun␤ statement end␤ statement list␤ whitespace␤FAILED 00:02 36m␤»
eternaleye std: ␠say "hello"; 04:17
p6eval std 27503: OUTPUT«##### PARSE FAILED #####␤Can't understand next input--giving up at /tmp/ku4OQBBYoZ line 1:␤------> ␠say "hello";␤ expecting any of:␤ prefix or noun␤ statement end␤ statement list␤ whitespace␤FAILED 00:02 36m␤»
azawawi TimToady: what's the purpose of STASH.pm ?
eternaleye Hm. It seems there is nothing similart to the newline escaping going on for spaces. That makes it kinda difficult to avoid embedded comments in the first column and 'ancient iteration' being parsed as Pod 04:18
TimToady sorry, had to go out and watch the ISS fly over :) 04:21
azawawi have fun
TimToady STASH is the object representing a symbol table 04:22
either lexical or package
azawawi TimToady: while trying to make S:H:P6 use the latest STD, I stumbled across this scoping problem: gist.github.com/145079 04:58
tann rakudo: my Int @a = [1, 2]; say @a.perl; 05:31
p6eval rakudo 02d0ed: OUTPUT«Array assignment type check failed; expected Int, but got Array␤in Main (/tmp/KTJRaXx1bU:2)␤»
tann std: my Int @a = [1]; 05:32
p6eval std 27503: OUTPUT«ok 00:02 37m␤»
literal rakudo: my Int @a = 1, 2; say @a.perl; 06:17
p6eval rakudo 02d0ed: OUTPUT«[1, 2]␤»
literal rakudo: my Array @a = [1, 2]; say @a.perl;
p6eval rakudo 02d0ed: OUTPUT«[[1, 2]]␤»
tann rakudo: my Int $x = (1..6).pick 06:18
p6eval rakudo 02d0ed: OUTPUT«Assignment type check failed; expected Int, but got Array␤in Main (/tmp/4GC7XjQvbN:2)␤»
tann rakudo: my $x = (1..6).pick; say $x; 06:21
p6eval rakudo 02d0ed: OUTPUT«2␤»
masak morning, PIR-camels! 06:25
masak std: Statbuf 06:32
p6eval std 27503: OUTPUT«Undeclared name:␤ Statbuf used at 1 ␤ok 00:02 36m␤»
masak TimToady: ^
tann std: my Int $x = (1..6).pick; 06:36
p6eval std 27503: OUTPUT«ok 00:02 37m␤»
masak std: my Int $x = 'bulbous bouffant'; 06:37
p6eval std 27503: OUTPUT«ok 00:02 37m␤»
masak cackles
tann uh oh
masak tann: note that STD.pm only performs _syntactic_ checks 06:38
tann masak: why my Int $x = 0, 1; ok but not my Int $x = [0, 1]; nor my Int $x = (1..5).pick ? 06:39
s/$x/@x/
and pick was a wrong example 06:40
masak because in the second case, you try to assign an Array to an Int.
masak the third case might not work for similar reasons. 06:42
I tend to write .pick[0] just to be sure.
Su-Shee hi 06:42
tann ah
tricky here
masak Su-Shee: \o
tann: as soon as you introduce types, things get very precise :) 06:43
tann so with my Int @x = [0, 1]; @x[0] <= [0, 1]
?
masak tann: oh, you had a @ sigil in that example too? 06:44
well, that changes things.
tann so for typed arrays, lists are mandatory?
masak now you're trying to assign an Array to the first place of an Array[Int], which will also fail.
tann rakudo: my Int @x = [0, 1];
p6eval rakudo 02d0ed: OUTPUT«Array assignment type check failed; expected Int, but got Array␤in Main (/tmp/H2cQUCTggF:2)␤»
masak rakudo: my Int @x = 0, 1;
p6eval rakudo 02d0ed: ( no output ) 06:44
masak tann: that's how you do it. 06:45
tann oh man
masak tann: calm down, it'll settle soon. :)
tann methinks, novices will get confused
masak tann: it sure confused me.
but mainly 'cause I have Perl 5 baggage.
tann i'm afraid it's sorta the same syndrome as my @x; $x[0] = 'urg'; in p5 06:46
masak uj, gotta go. see y'all later.
tann: no, I don't agree. 06:47
tann rakudo: sub foo { return 1, 2, 3; }; my @a = foo(); say @a.perl 07:11
p6eval rakudo 02d0ed: OUTPUT«too many arguments passed (3) - at most 1 param expected␤in sub foo (/tmp/KHAVWHkT8z:2)␤called from Main (/tmp/KHAVWHkT8z:2)␤»
tann rakudo: sub foo { return list 1, 2, 3 }; my @a = foo(); say @a.perl; 07:16
p6eval rakudo 02d0ed: OUTPUT«[1, 2, 3]␤»
tann rakudo: my @a; say @a ~~ [] ?? 'void' !! 'filled'; 07:19
p6eval rakudo 02d0ed: OUTPUT«void␤»
tann rakudo: my @evens = (1..10).grep: { $_ % 2 == 0 }; say @evens.perl 07:28
p6eval rakudo 02d0ed: OUTPUT«[2, 4, 6, 8, 10]␤»
tann rakudo: my @evens = 0, 2 ... 100 [+]; 07:30
p6eval rakudo 02d0ed: OUTPUT«Statement not terminated properly at line 2, near "[+];"␤in Main (src/gen_setting.pm:3340)␤»
eternaleye tann: THe syntax for that is my @evens = 0, 2 ... &[+]; but we don't do laziness yet 07:31
the & 'noun-ifies' the + operator, but as-is you have to return an empty list eventually in the closure or it runs forever 07:32
tann my @a = 1..3.grep: { $_ % 2 }; say @a.perl;
eternaleye tann: But even that doesn't do what you want
Since it would give 0, 2, 2, 4, 6, 10, etc 07:33
tann eternaleye: yes..i noticed that :)
eternaleye Although, .. supports a :by adverb 07:34
2 .. 10 :by(2)
tann does rakudo support that now?
eternaleye Not sure
tann last time i checked it didn't
eternaleye rakudo: .say for 2 .. 10 :by(2);
p6eval rakudo 02d0ed: OUTPUT«Statement not terminated properly at line 2, near ":by(2);"␤in Main (src/gen_setting.pm:3340)␤»
eternaleye pugs: .say for 2 .. 10 :by(2);
p6eval pugs: OUTPUT«*** ␤ Unexpected ":by"␤ expecting operator␤ at /tmp/w8x3PgIvDK line 1, column 18␤»
tann what's a readable way of checking if a list/array is empty? @a ~~ [] vs @a vs @a.elems == 0 etc.. 07:36
eternaleye rakudo: my @a = 1,2,3; my @b = (); say @a.empty; say @b.empty
p6eval rakudo 02d0ed: OUTPUT«Method 'empty' not found for invocant of class 'Perl6Array'␤»
eternaleye tann: Actually, just an 'if' on .elems works, since 0 ~~ Bool::False 07:37
tann s32 mentions elems for arrays
eternaleye rakudo: my @a = 1,2,3; my @b = (); say @a.elems; say @b.elems
p6eval rakudo 02d0ed: OUTPUT«3␤0␤»
tann eternaleye: i am inspired by scala's and erlang's quicksort showoff in wikipedia 07:38
so, i hacked out a working quicksort (abeit extremely naive) for p6 07:39
scalar and erlang checks for empty list are quite intuitive
such as if list is [] 07:40
or list is Nil etc...
so i was wondering what the most readable way of checking empty list in p6
eternaleye rakudo: my @a = 1,2,3; my @b = (); say @a ~~ Nil; say @b ~~ Nil
p6eval rakudo 02d0ed: OUTPUT«0␤0␤»
eternaleye (Nil is real in Perl 6, but it 'becomes' undef, the empty list, etc. as necessary 07:41
tann ya know i wanna sell p6 to novices so cryptic stuff like return @list unless @list is avoided :)
eternaleye tann: return @list if +@list? one more character, and it makes it clear that you're looking at it numerically
tann i think that would scare novices even more :) 07:42
eternaleye s/if/unless/
tann i wanna convert php people to p6!!!
eternaleye tann: return @list unless ?@list - forces boolean context
Su-Shee tann: "uhoh" :) 07:43
tann return @list unless @list.elems;
something like that
ya know
:)
Matt-W well you can do that, sure
eternaleye tann: TIMTOWTDI
tann yes, but there's also PBP :) 07:44
eternaleye ?
tann damian's bible perl best practices
eternaleye AH
lisppaste3 tann pasted "naive quicksort" at paste.lisp.org/display/83406 07:45
Matt-W perl best practices in perl 6 will be different 07:46
tann i wanna put a naive quicksort in wikipedia to counter those of scalar and erlang
eternaleye For instance, use strict is the default
tann unlike the examples of scalar and erlang, this actually works :P 07:47
Matt-W that's always a good start 07:48
eternaleye Hmm, eight more days untill the anniversary of the Perl 6 design process being announced
*until
Matt-W it doesn't matter! all that matters is the date of christmas 07:49
tann agree with matt-w :)
Su-Shee well I still take p6 even if it's released on easter. ;) 07:52
Matt-W except of course we don't know that date yet, so... 07:53
Su-Shee I don't think that the release date this or next year is really what's important for the success of p6.
Matt-W what's really important is that when we say 'here is Perl 6.0.0', it's really really good 07:54
Su-Shee well it has to be adopted by people. and after some discussions yesterday I get the impression, that many non-perl-people seem to be very interested. 07:55
I always thought p6 would be the next-generation language for p5 people.. 07:56
Matt-W p5 people can be very stubborn 07:57
personally I can't wait to migrate, but...
of course it'd help a lot if we ever manage to get a perl5-on-parrot to help migration
Su-Shee I put very much hope on the parrot-rakudo duo and the extensibility.
put hope in? anyway. if perl6 is smooth and easy to use and has great bindings, people will buy it. :) 07:59
tann perl gods, please end my misery with an early christmas
Matt-W Patches please the Perl gods
Su-Shee :) 08:00
tann rakudo: my @a = 1..5; @a.pick(1, :repl); say @a.perl; 08:01
p6eval rakudo 02d0ed: OUTPUT«[1, 2, 3, 4, 5]␤»
tann rakudo: my @a = 1..5, @a.pick(*, :repl); say @a.perl;
p6eval rakudo 02d0ed: OUTPUT«Infinite lazy pick not implemented␤in Main (/tmp/NtBnaNWWwD:2)␤» 08:02
tann rakudo: my @a = 1..5.pick(2, :repl); say @a.perl; 08:03
p6eval rakudo 02d0ed: OUTPUT«[1, 2]␤»
eternaleye Matt-W: It does matter, it means we get to bake a cake for Camelia! 08:08
eternaleye Also, regarding p5-on-Parrot, ISTR TimToady working on something called MAD[props]? in the existing p5 compiler that spit out the internal state in what is essentially an annotated XML AST for p5 08:11
tann rakudo: my @a = 1..5; say @a.delete(3); say @a.perl; 08:29
p6eval rakudo 02d0ed: OUTPUT«4␤Null PMC access in isa()␤in method Any::map (src/gen_setting.pm:191)␤called from method List::perl (src/gen_setting.pm:921)␤called from Main (/tmp/f9nhzVveZa:2)␤»
tann rakudo: my @a = 1..5; say delete @a[3]; say @a.perl; 08:30
p6eval rakudo 02d0ed: OUTPUT«No applicable candidates found to dispatch to for 'delete'␤in Main (/tmp/dKQPXRuvTm:2)␤»
finanalyst rakudo: my @a = 1..5; say @a[3].delete; say @a.perl 08:43
p6eval rakudo 02d0ed: OUTPUT«Method 'delete' not found for invocant of class 'Int'␤»
jauaor :) 08:53
davef Hi - why does 'method getGlobalTransactionId( --> Array of Int ) { ... } ' (within a role) - warn of 'Use of type object as value'? 10:19
masak rakudo: my @a = 0..1; @a.delete(0); say @a.perl 10:55
p6eval rakudo 02d0ed: OUTPUT«Null PMC access in isa()␤in method Any::map (src/gen_setting.pm:191)␤called from method List::perl (src/gen_setting.pm:921)␤called from Main (/tmp/tFTw79p6Cl:2)␤»
masak submits rakudobug
rakudo: my @a = 0..1; @a[0] = undef; say @a.perl 10:57
p6eval rakudo 02d0ed: OUTPUT«[undef, 1]␤»
masak my bet is that .delete does something naughty.
mberends masak: \o 10:59
masak mberends: ahoj!
mberends: I have now used up the first box of diverse condiments you gave me. thank you. 11:00
mberends had some for breakfast :)
masak mberends: casting a glance at the second box, I noticed that it says 'stamped little mice' on it. I was first alarmed, then amused. 11:01
let's see if I get it right from memory: 'gestampte muisjes', yes?
mberends exactly :) nl.wikipedia.org/wiki/Gestampte_muisjes 11:03
masak 'broodbeleg' :)
Su-Shee ok, I know some dutch, but I better check on gestampte muisjes.. :)
mberends bread confectionery 11:04
masak apparently they have been crushed for the benefit of certain young ladies. 11:05
(...who thought that the original mice were a bit hard on the teeth) 11:06
mberends the aniseed grains were apparently too coarse for _older_ ladies, hence the idea of crushing them.
masak oh. right.
'oudere'.
Google Translate, this is your final warning.
mberends masak: did you book travel and accommodation for Lisbon yet? 11:07
masak travel -- yes; accomodation -- still holding out for some Esperanto contacts who might want to host me. 11:08
mberends If hostel rates are affordable, I'm considering a slightly longer stay 11:09
masak aye.
me too.
masak is staying 30th to 8th
mberends going by the yapc website, www.alfaiataria.org/goodnight/ looks good 11:13
masak guess it's high season now, eh? 11:14
mberends yes, no question about that 11:15
Su-Shee interesting conference travel choices this year.. desktop summit on gran canaria.. yapc in lisbon... :) 11:22
masak hm, let's see. things I could hack on today: Web.pm, proto, November, u4x. 11:39
pugs_svn r27504 | kyle++ | [t/spec] Test for RT #67446 12:25
KyleHa perl6: my @a=0..1;@a.delete(0);map { .say }, @a; 12:30
p6eval rakudo 02d0ed: OUTPUT«No applicable candidates found to dispatch to for 'map'␤in Main (/tmp/vsy9Okbh9k:2)␤»
..elf 27504: OUTPUT«Use of uninitialized value in concatenation (.) or string at ./elf_h line 5105.␤syntax error at (eval 125) line 5, near "{->say"␤ at ./elf_h line 5881␤»
..pugs: OUTPUT«␤1␤»
jauaor nopaste.info/72f3e0dd92.html 12:43
:D
masak forthwards, comrades! 12:45
jauaor haha 12:46
this is a small language i am writing
it is actually more inspired in J
:D
KyleHa rakudo: my @a=0..1;@a.delete(0);map { .say }, @a; 12:48
p6eval rakudo 02d0ed: OUTPUT«No applicable candidates found to dispatch to for 'map'␤in Main (/tmp/d19scfkNtM:2)␤»
KyleHa What should that do? Output '1', right?
masak thinks so
there's something fishy going on with that .delete function 12:49
rakudo: my @a=0..1; map { .say }, @a;
p6eval rakudo 02d0ed: OUTPUT«0␤1␤»
pugs_svn r27505 | kyle++ | [t/spec] .delete causes a problem for map too 12:55
pugs_svn r27506 | kyle++ | r32436@livetext-laptop: kyle | 2009-07-10 15:41:17 -0500 13:08
r27506 | kyle++ | [t/spec] A few tests for fff operator (more needed)
KyleHa That there svk is pertnear nifty, I reckon. 13:09
masak it is. 13:13
git-svn, too.
KyleHa I suppose I ought to go the git-svn route, since svk is going all eol. 13:18
finanalyst rakudo: my @x=1,2,3,undef,3,2;say ?(all(@x) ~~ .defined) 13:19
p6eval rakudo 02d0ed: OUTPUT«1␤»
finanalyst should this be 0? 13:20
s/shouldnt/should/
masak finanalyst: well, a junction is defined. 13:22
finanalyst yes but i was trying to test the elements of the array 13:23
masak yes, I see.
finanalyst rakudo: my @x=1,2,3,4; say ?(all(@x) < 3.5)
p6eval rakudo 02d0ed: OUTPUT«0␤»
finanalyst voila 13:24
masak rakudo: my @a = 1,2,3,undef,3,2; say [&&] @a>>.defined
p6eval rakudo 02d0ed: OUTPUT«say requires an argument at line 2, near " [&&] @a>>"␤in Main (src/gen_setting.pm:2444)␤»
masak hm, [&&] NYI?
finanalyst rakudo: my @x=1,2,3,undefined,4; say (@x>>.defined).perl 13:26
p6eval rakudo 02d0ed: OUTPUT«Could not find non-existent sub undefined␤»
finanalyst rakudo: my @x=1,2,3,undef,4; say (@x>>.defined).perl
p6eval rakudo 02d0ed: OUTPUT«[Bool::True, Bool::True, Bool::True, Bool::False, Bool::True]␤»
finanalyst rakudo: my @x=1,2,3,undef,4; say (@x >>.defined).perl 13:28
p6eval rakudo 02d0ed: OUTPUT«Statement not terminated properly at line 2, near ">>.defined"␤in Main (src/gen_setting.pm:3340)␤»
finanalyst no whitespace permitted before >> ? 13:29
my @x=1,2,3,4; my @z; for @x { @z[*] = $_ }; say @z.perl 13:36
rakudo:my @x=1,2,3,4; my @z; for @x { @z[*] = $_ }; say @z.perl 13:37
rakudo: my @x=1,2,3,4; my @z; for @x { @z[*] = $_ }; say @z.perl
p6eval rakudo 02d0ed: OUTPUT«[]␤»
finanalyst i was expecting [1,2,3,4] 13:38
finanalyst akudo: my @x=1,2,3,4; my @z; for @x { @z[+@z] = $_ }; say @z.perl 13:49
rakudo: my @x=1,2,3,4; my @z; for @x { @z[+@z] = $_ }; say @z.perl
p6eval rakudo 02d0ed: OUTPUT«[1, 2, 3, 4]␤»
finanalyst am i wrong in thinking @a[*] should act in the same way as @a[+@a] ? 13:50
masak finanalyst: yes, I think you are. 13:53
finanalyst ok, i will post a bug
masak finanalyst: you'd want @a[+*].
finanalyst: why? I just said that I think you're wrong.
finanalyst sorry. no post bug 13:54
rakudo: my @x=1,2,3,4; my @z; for @x { @z[+*] = $_ }; say @z.perl
p6eval rakudo 02d0ed: OUTPUT«[4]␤»
masak now _that_ might very well be wrong.
finanalyst shall i post a bug? 13:55
masak .[+*] should mean 'first element after the end of the array'
finanalyst: please do.
masak rakudo: $*IN.get.words.pick.say 14:39
p6eval rakudo 02d0ed: OUTPUT«Strome,␤»
masak :)
davef rakudo: role x { method y( --> Array of Int) {...} } 14:43
p6eval rakudo 02d0ed: OUTPUT«Use of type object as value␤»
davef std: role x { method y( --> Array of Int) {...} }
p6eval std 27506: OUTPUT«ok 00:02 37m␤»
masak rakudo: $*IN.lines.words.sort(*.chars)[*-1].say
p6eval rakudo 02d0ed: OUTPUT«hoffnungsreich.␤»
masak rakudo: $*IN.lines.words.sort(*.chars)[*-1].uc.say 14:45
p6eval rakudo 02d0ed: OUTPUT«HOFFNUNGSREICH.␤»
masak :)
davef Hi - does the fact that std shows something as OK and rakudo warns 'Use of type object as value' mean that rakudo doesn't yet implement this?
masak davef: not in general, no. but in this case, I think that's the case.
I've also been seeing that warning in silly situations lately.
davef is there a workaround?
masak davef: dunno. what is it you're aiming to do? 14:46
davef trying to translate JDBC API to P6 as a starter for the new DBI. Working my way through the errors/warnings trying to get a clean run for Tim. 14:47
masak rakudo: role R { method y(--> Array) {} }
p6eval rakudo 02d0ed: ( no output )
masak rakudo: role R { method y(--> Array of Int) {} }
p6eval rakudo 02d0ed: OUTPUT«Use of type object as value␤»
masak there you go. it's the 'of Int' part that's NYI.
davef I have a whole bunch of java:: return types - I guess I'll just have to ignore for now, maybe emit them as comments. 14:49
Do you know if there's a P6 equivalent of the Java 'throws' associated with interface definitions? 14:51
masak davef: no, does not seem like it. 14:55
davef thanks - thought I might have just missed it. Is there another way of encapsulating this information?
masak I was just thinking about that. 14:56
so what you want to express is that this particular method throws a set of exception types, and only those?
davef yes - I'm not sure how it's going to be used as this will be the basis for DBDI developers to generate drivers for different vendor DBs. 14:58
masak it's a noble goal, but I can see no mechanism that will do this easily for you. 14:59
it's a kind of declaration that I don't usually associate with Perl, but with Java. 15:00
TimToady I think it's a sign of overreliance on exceptions as an API control mechanism
we're trying to go the other direction, and make exceptions *more* exceptional
because they mess up implicit threading badly
you can't hyperize an operator that randomly throws exceptions on one of its elements 15:01
it blows all the other parallel calculations out of the water unnecessarily
so we're moving more toward inband failure propagation via "unthrown" exceptions 15:02
but those should not generally be used as normal values either in a good API, especially to indicate "no more data" 15:03
</end_of_diatribe> 15:05
davef Most of the JDBC stuff seems to throw 'SQLExceptions', I guess they're formatting and passing on the vendors exceptions. 15:07
I'll emit comments and defer the design decision until either I know more or someone who knows what they're doing has a suggestion :) 15:08
pmurias davef: a dynamicly checked throws declaration is hardly usefull isn't it? 15:16
masak pmurias: why would it be dynamically checked? 15:18
TimToady well, this was one of the reasons the Javafolk didn't want to add an instruction that could call a method they didn't know the name of in advance 15:19
dynamic languages are so, well, dynamic...
Limbic_Region TimToady - but if Eclipse can actually make Java a succesful language, there is a lot to be said for statically typed languages that can predict behavior at compile time ;-) 15:20
TimToady there's also a lot to be said for not reinventing an existing language :)
pmurias masak: it's hard to check anything statically in Perl6
TimToady which is why we at least insist that the candidate list for multiple dispatch is static 15:21
Limbic_Region yeah - it would just be really nice if there was an IDE for perl 6 that really worked good given the amount of OO being baked in
masak pmurias: oh, you're right of course. I've come to thing of an 'under usual circumstances' condition being needed.
davef If Std is the standard grammar, if something passes uder std, but fails under rakudo, does that generally mean it's an implementation issue? 15:38
TimToady STD is pretty much only checking syntax, not semantics, so it could also be a semantic error that rakudo is just giving a dumb message for 15:40
but currently the best bet is usually a rakudobug or parrotbug :) 15:42
davef thanks
masak std: Statbuf 15:53
p6eval std 27506: OUTPUT«Undeclared name:␤ Statbuf used at 1 ␤ok 00:02 36m␤»
TimToady I don't particularaly like that name anyway 15:57
especially now that we have buf types that aren't related
masak nod. 15:58
TimToady likely to turn into Stat, or some such
but that seems like it could interfere with statistics 15:59
Fstat is too specific, maybe Rstat 16:00
masak "R" standing for...? 16:03
TimToady resource
masak yeuch.
TimToady or maybe we should unify with IO more that way ingy originally used IO
s1n TimToady: there's R, the statistics based programming environment :/
TimToady er, oops
I guess the fundamental question is how lazy IO('filename') is 16:04
and how hard to we work to prevent race conditions
pmichaud Good morning, #perl6
TimToady *do
s1n pmichaud: good morning
TimToady o/ 16:05
s1n fetches fresh coffee
masak morning, pm.
TimToady I've got some DP in my outdoor fridge...
funny how I think of the garage as outdoors
TimToady well, out one door, anyway 16:06
TimToady I think I'm just gonna delete Statbuf and hope the IO role is sufficient for now 16:11
masak +1 16:12
pugs_svn r27507 | lwall++ | [S03] kill Statbuf type, unify with IO role/class somehow 16:17
araujo playing around with rakudo 17:47
lambdabot araujo: You have 1 new message. '/msg lambdabot @messages' to read it.
araujo mmm....
pmichaud reads backscroll 18:01
araujo rakudo: my %h = { 'foo' => 'bar' }; for %h.keys -> $k { say "$k => %h{$k}"; } 19:32
p6eval rakudo 02d0ed: OUTPUT«foo => %hfoo␤»
araujo :(
tann rakudo: my @a = 1,2; @a[0]:delete; say @a.perl; 19:59
p6eval rakudo 02d0ed: OUTPUT«Statement not terminated properly at line 2, near ":delete; s"␤in Main (src/gen_setting.pm:3340)␤»
tann rakudo: my @a = 1,2; @a[0].delete; say @a.perl;
p6eval rakudo 02d0ed: OUTPUT«Method 'delete' not found for invocant of class 'Int'␤»
tann rakudo: my @a = 1,2; @a.delete(0); say @a.perl; 20:00
p6eval rakudo 02d0ed: OUTPUT«Null PMC access in isa()␤in method Any::map (src/gen_setting.pm:191)␤called from method List::perl (src/gen_setting.pm:921)␤called from Main (/tmp/sBPHXZmDJA:2)␤»
tann std: my @a = 1,2; @a.delete(0); 20:03
p6eval std 27507: OUTPUT«ok 00:02 38m␤»
tann my @a = <a b c d e f>; @a.delete(2..4); say @a.perl; 20:06
rakudo: my @a = <a b c d e f>; @a.delete(2..4); say @a.perl;
p6eval rakudo 02d0ed: OUTPUT«Null PMC access in isa()␤in method Any::map (src/gen_setting.pm:191)␤called from method List::perl (src/gen_setting.pm:921)␤called from Main (/tmp/PvU9uofjsD:2)␤»
funky hello 20:07
can anyone help me with this installation? pastebin.com/m27c668a
tann funky: try #perl5 20:08
funky ok 20:10
I already tried though
tann funky: try to install Data::JavaScripdt::Anon first and pull the other again 20:15
funky I tried it too 20:16
tann did it install?
funky no 20:17
tann what was the error? 20:18
funky pastebin.com/m13a05cbf
I was reproducing it
not very helpful though 20:19
tann that was lame
try to download the package onto your machine 20:20
funky I got it
tann untar it
funky how can I install it by hand ?
tann and then run perl Makefile.PL
then make && make test && make install
wget the package
funky ok 20:21
tann go to this search.cpan.org/~adamk/Data-JavaScr...Anon-1.03/
click on download
or just hover your mouse over it and look at the url 20:22
then wget onto the box you want
funky yup yup 20:23
I already got it
no need for that exact detail 20:24
thank you anyway :)
I'm upgrading from squeeze to testing before
funky solved! 20:39
thank you very much tann
tann funky: np
rakudo: my @a = 1,2; @a[0,1] = @a[1,0]; say @a.perl; 20:41
p6eval rakudo 02d0ed: OUTPUT«[2, 1]␤»
tann rakudo: my @a = 1, 2, 3, 4; @a[0, 3] = @a[3, 0]; say @a.perl; 20:42
p6eval rakudo 02d0ed: OUTPUT«[4, 2, 3, 1]␤»
tann rakudo: my @a = 1..4; @@a[0, 3] = @@a[3, 0]; say @a.perl; 20:43
p6eval rakudo 02d0ed: OUTPUT«Syntax error at line 2, near "@@a[0, 3] "␤in Main (src/gen_setting.pm:3340)␤»
tann rakudo my @a; say @a == Nil ?? 'nil' !! 'fill'; 20:48
rakudo: my @a; say @a == Nil ?? 'nil' !! 'fill';
p6eval rakudo 02d0ed: OUTPUT«Use of type object as value␤nil␤»
StephenPollei rakudo: my @a; say @a ~~ Nil ?? 'nil' !! 'fill'; 20:49
p6eval rakudo 02d0ed: OUTPUT«fill␤»
tann rakudo: my @a; say @a ~~ Nil ?? 'nil' !! 'fill';
p6eval rakudo 02d0ed: OUTPUT«fill␤»
davef hi, is there any way to run std or rakudo in the irc without it being visible by everyone on the session?
StephenPollei /privmsg p6eval
davef is that for rakudo? what about std? 20:50
StephenPollei the bot does both and elf and I forget what all
davef so is it /privmsg p6eval std: ... 20:51
StephenPollei /privmsg p6eval std: my @a; say @a ~~ Nil ?? 'nil' !! 'fill'; 20:52
davef thanks
StephenPollei yes pretty much and then if your irc client is like mine you can just type directly to it 20:53
tann rakudo: my @a = 1..4; say @a[3,0].perl 21:00
p6eval rakudo 02d0ed: OUTPUT«[4, 1]␤»
tann_ rakudo: sub foo(@a, $s) { say @a.perl; say $s }; my @a = 1..5; foo(@a, @a.pick); 21:16
p6eval rakudo 02d0ed: OUTPUT«[1, 2, 3, 4, 5]␤4␤»
tann_ rakudo: sub foo(@a, $s) { say @a.perl; say $s }; foo(1..5, 1..5.pick); 21:17
p6eval rakudo 02d0ed: OUTPUT«[1, 2, 3, 4, 5]␤1␤»
tann_ rakudo: sub foo(@a, $s) { say @a.perl; say $s }; foo(1, 2, 3, 4, 5, 1..5.pick);
p6eval rakudo 02d0ed: OUTPUT«too many arguments passed (6) - 2 params expected␤in sub foo (/tmp/UbyU8Cnyoz:1)␤called from Main (/tmp/UbyU8Cnyoz:2)␤»
pmichaud Rakudo day tomorrow. 23:02