pugscode.org/ planetsix.perl.org/ | nopaste: sial.org/pbot/perl6 | evalbot: perl6: say 3; (or rakudo:, pugs:, elf:, etc) | irclog: irc.pugscode.org/ | ~315 days 'til Xmas
Set by mncharity on 8 February 2009.
wayland I don't see why not 00:00
User757 hi!
s1n1 jnthn: i have a question or two about the setting
TimToady see S09:208
er
wayland multi prefix:<~>(...) or something :)
TimToady S13:208 rather
wayland User757: hi! :) 00:01
User757 I really don't know what I'm doing here 00:02
I
I'm looking for a tf2 pug and got here somehow
s1n1 TimToady: question: infix<~> uses the ACCEPTS method for Ranges, correct? 00:03
wayland User757: One implementation of perl6 is called "pugs". That's probably how you ended up here. I'm assuming that TF2 is "Team Fortress 2", but I don't know what a pug is in this context 00:04
TimToady s1n1: I have no idea what you're asking...
are you speaking of infix:<~~>? 00:05
s1n1 TimToady: yes
you beat me to the punch, sorry, infix<~~> use ACCEPTS...
TimToady except for special syntactic forms, ~~ always uses .ACCEPTS on whatever the righthand type is
00:06 User757 left
s1n1 so $a ~~ $b is the same as $a.ACCEPTS($b)? 00:06
TimToady no
$b.ACCEPTS($a)
s1n1 oh, okay
TimToady it's a backwards single dispatch, basically
the match depends primarily on the right side's type 00:07
s1n1 so (1..20) ~~ 4 is the same as 4.ACCEPTS(1..20)?
TimToady $b may or may not choose to pay attention to the type of $a
yes, which I would expect to be false
because in general a pattern should be more general than what it matches 00:08
s1n1 for Range, (1..5).ACCEPTS(1..5) is true though
i'm not sure i followed that last statement
TimToady matching two Ranges is not defined currently 00:09
it would try to match under the Any ~~ Range line, and I'm not sure what would happen 00:10
s1n1 hmmm
TimToady the spec is your friend, except where it's not... 00:11
s1n1 heh the spec definitely does not like me, well either that or my brain is incapable of navigating it
was it intentionally left out of the spec? 00:12
TimToady it might work out, since it's defined as [!after] $b.min, $a.min..$a.max, $b.max
so what it would tell you if the range on the left was a subset of the range on the right 00:13
s1n1 or if $b is not a range, it would be nice to know if it (ie Num) is in the range 00:14
00:14 Caelum left
TimToady I don't recall if we ever explictly thought about Range ~~ Range 00:14
no, we don't do it that way on purpose
s1n1 or Range ~~ Num 00:15
TimToady otherwise you can't optimize a numeric switch to a jump table
s1n1 that would be neat though :) maybe Num ~~ Range
00:16 Caelum joined
TimToady we don't autoreverse any .ACCEPTS semantics like the original smartmatching did (and which p5 unfortunately copied) 00:16
if you want a reversed match, you can write one explicitly with "when { 4 ~~ $_ }" 00:17
s1n1 rakudo: (1..10) when { 4 ~~ $_ } 00:18
p6eval rakudo 00e9db: OUTPUT«Parrot VM: Can't stat languages/rakudo/perl6.pbc, code 2.␤main: Packfile loading failed␤»
s1n1 uhoh, well, was that the right idea?
TimToady rakudo: given 1..10 { say "yes" when { 4 ~~ $_ } } 00:19
p6eval rakudo 00e9db: OUTPUT«Parrot VM: Can't stat languages/rakudo/perl6.pbc, code 2.␤main: Packfile loading failed␤»
TimToady pugs: given 1..10 { say "yes" when { 4 ~~ $_ } }
p6eval pugs: OUTPUT«*** ␤ Unexpected "when"␤ expecting operator, ":", "," or "}"␤ at /tmp/xkAJjLZoFf line 1, column 25␤»
TimToady std: given 1..10 { say "yes" when { 4 ~~ $_ } }
s1n1 wow, that's a crap ton of work to do what you mean by Range ~~ Num (or vice versa)
p6eval std 25451: OUTPUT«ok 00:04 34m␤»
TimToady if you want reversed smartmatching it probably means you need to refactor it 00:20
s1n1 well, i'd be cool to do something like (2..$max :by(2)) ~~ $odd 00:21
00:21 Avada joined
s1n1 without having to refactor, that seems dwim to me 00:21
00:22 shinobi-cl joined
TimToady if you want to put such a test into a switch statement it means you're unclear on what is generic and what is specific in your program 00:22
it makes it impossible to optimize 00:23
s1n1 why would i put that in a switch?
if i did that, maybe i just wanted to be lazy and not optimize
TimToady $value ~~ $pattern isn't long otherwise
s1n1 (btw, i'm too dense to understand why that's not optimizable) 00:24
by $pattern, what do you mean?
TimToady if you're that lazy then you should write your own operator :)
s1n1 i didn't want to write my own, just abuse smartmatching :)
TimToady something that defines a set of values
then smartmatching will outsmart you :)
re otimizable, suppose you have when 1 {...}; when 2 {...}; when 3 {...} like an ordinary C switch statement 00:25
C can just jump straight to the right bit of code without testing $_ == 1 || $_ == 2 || $_ == 3 00:26
but that only works if 4 always does a numeric comparison to something forced into numeric context
and +(1..5) is not going to return a range
if we have to wait to see what type of the thing on the left is, we don't know that till run time 00:27
instead, we promise Num.ACCEPTS that it can assume $b == +$a 00:28
s1n1 what does +(1..5) return, a List?
TimToady no, a number
that can be compared to $b
with ==
s1n1 oh, hmm
TimToady +(@numbers) == 4 will tell you if there are 4 elements in the list 00:29
s1n1 car is ready, going home&
00:29 s1n1 left
shinobi-cl pugs: say [~] [+] (1..5); 00:31
p6eval pugs: OUTPUT«15␤»
shinobi-cl pugs: say [+] (1..5); 00:32
p6eval pugs: OUTPUT«15␤»
TimToady stacking two reduce operators makes little sense
shinobi-cl but its nice to know that can be done :)
TimToady indeed 00:33
btw, you don't need those parens
shinobi-cl pugs: say [\+] (1..5);
p6eval pugs: OUTPUT«1361015␤»
shinobi-cl pugs: say [\+] [\-] (1..5); 00:35
p6eval pugs: OUTPUT«10-4-12-25␤»
TimToady O_o 00:36
shinobi-cl pugs: ([\+] [\-] (1..5)).perl.say; 00:38
p6eval pugs: OUTPUT«(1, 0, -4, -12, -25)␤»
00:38 skids joined
shinobi-cl pugs: [X] (1..5); 00:39
p6eval pugs: RESULT«((1, 2, 3, 4, 5),)» 00:40
00:41 nihiliad left
wayland rakudo: multi Str sub foo(Str $string) { print "hi $string"; } foo('everyone') 00:43
p6eval rakudo 00e9db: OUTPUT«Parrot VM: Can't stat languages/rakudo/perl6.pbc, code 2.␤main: Packfile loading failed␤»
wayland STD: multi Str sub foo(Str $string) { print "hi $string"; } foo('everyone')
perl6: multi Str sub foo(Str $string) { print "hi $string"; } foo('everyone')
p6eval rakudo 00e9db: OUTPUT«Parrot VM: Can't stat languages/rakudo/perl6.pbc, code 2.␤main: Packfile loading failed␤»
..pugs: OUTPUT«*** ␤ Unexpected "sub"␤ expecting "handles", "is", bare trait, subroutine parameters, trait or block␤ at /tmp/pBPuAQnTME line 1, column 11␤»
..elf 25451: OUTPUT«Parse error in: /tmp/5VqOmmed8v␤panic at line 1 column 0 (pos 0): Can't understand next input--giving up␤WHERE: multi Str sub foo(Str $string)␤WHERE:/\<-- HERE␤ STD_red/prelude.rb:99:in `panic'␤ STD_red/std.rb:76:in `scan_unitstopper'␤ STD_red/std.rb:224:in `comp_unit'␤
..STD_r...
00:46 meppl joined 00:49 wknight8111 left
shinobi-cl pugs: [&] [^] [4,3,2,1],[1,3] 00:52
p6eval pugs: RESULT«(((1, 3) ^ (4, 3, 2, 1)))»
shinobi-cl pugs: [X] [^] [4,3,2,1],[1,3]
p6eval pugs: RESULT«(((1,), (3,)) ^ ((4,), (3,), (2,), (1,)))»
shinobi-cl pugs: [^] [X] [4,3,2,1],[1,3] 00:53
p6eval pugs: RESULT«((1, 1) ^ ␤ (1, 3) ^ ␤ (2, 1) ^ ␤ (2, 3) ^ ␤ (3, 1) ^ ␤ (3, 3) ^ ␤ (4, 1) ^ ␤ (4, 3))»
shinobi-cl pugs: [^] [X] [4,3,2,1]X[1,3] 00:55
p6eval pugs: RESULT«(((1, 1), (1, 3)) ^ ␤ ((2, 1), (2, 3)) ^ ␤ ((3, 1), (3, 3)) ^ ␤ ((4, 1), (4, 3)))»
shinobi-cl pugs: [^] [X] [1,2,3,4]X[1,3]
p6eval pugs: RESULT«(((1, 1), (1, 3)) ^ ␤ ((2, 1), (2, 3)) ^ ␤ ((3, 1), (3, 3)) ^ ␤ ((4, 1), (4, 3)))»
shinobi-cl pugs: [^] [X] [1,2,3,4]X[3,1] 00:56
p6eval pugs: RESULT«(((1, 3), (1, 1)) ^ ␤ ((2, 3), (2, 1)) ^ ␤ ((3, 3), (3, 1)) ^ ␤ ((4, 3), (4, 1)))»
TimToady std: multi Str sub foo(Str $string) { print "hi $string"; } foo('everyone') 00:58
p6eval std 25451: OUTPUT«############# PARSE FAILED #############␤Malformed "multi" definition␤Malformed routine definition at /tmp/DsSowuGGAx line 1:␤------> multi Str sub foo(Str $string) { print "hi $string␤ expecting any of:␤ routine_def␤ trait␤FAILED 00:02 33m␤»
00:58 fridim_ left
TimToady std: my Str multi sub foo(Str $string) { print "hi $string"; } foo('everyone') 01:01
01:01 iblechbot left
p6eval std 25451: OUTPUT«############# PARSE FAILED #############␤Malformed "my" declaration␤Malformed "multi" definition␤Malformed routine definition␤Malformed routine definition at /tmp/4z0ZsucSXs line 1:␤------> my Str multi sub foo(Str $string) { print "hi $string"; ␤FAILED 00:02 33m␤» 01:01
TimToady std: my Str multi foo(Str $string) { print "hi $string"; } foo('everyone') 01:02
p6eval std 25451: OUTPUT«############# PARSE FAILED #############␤Malformed "my" declaration␤Malformed "multi" definition␤Malformed routine definition at /tmp/bQI0WGqFU5 line 1:␤------> my Str multi foo(Str $string) { print "hi $string"; }␤ expecting declarator␤FAILED 00:02 33m␤»
TimToady std: my Str multi foo(Str $string) { print "hi $string"; }; foo('everyone')
p6eval std 25451: OUTPUT«############# PARSE FAILED #############␤Malformed "my" declaration␤Malformed "multi" definition␤Malformed routine definition at /tmp/oc2D26DyA6 line 1:␤------> my Str multi foo(Str $string) { print "hi $string"; }␤ expecting declarator␤FAILED 00:02 33m␤» 01:03
TimToady hmm
01:04 alc joined
TimToady lex damage, I suspect 01:04
decommuting & 01:06
shinobi-cl pugs: [^] [X] [1,2,3,4]X[3,1].reverse 01:10
p6eval pugs: RESULT«(((1, 1), (1, 3)) ^ ␤ ((2, 1), (2, 3)) ^ ␤ ((3, 1), (3, 3)) ^ ␤ ((4, 1), (4, 3)))»
01:15 eternaleye joined
wayland @tell Matt-W Form.pm is also documented in Exegesis 7, as I presume you know :) 01:22
lambdabot Consider it noted.
shinobi-cl pugs: my @a=(1,2,3,4); my @b=(5,6,7,8); say @a Z @b;
p6eval pugs: OUTPUT«1234␤»
shinobi-cl pugs: my @a=(1,2,3,4); my @b=(5,6,7,8); @a Z @b; 01:23
p6eval pugs: RESULT«((1, 5), (2, 6), (3, 7), (4, 8))»
shinobi-cl rakudo: my @a=(1,2,3,4); my @b=(5,6,7,8); say @a Z @b;
p6eval rakudo 00e9db: OUTPUT«Parrot VM: Can't stat languages/rakudo/perl6.pbc, code 2.␤main: Packfile loading failed␤»
wayland @tell Matt-W Am I right in presuming that you're going to use a grammar for Form.pm? 01:36
lambdabot Consider it noted.
wayland Question for the people with perlcabal power; is there some way we can get the new S32 drafts to appear at perlcabal.org/syn/ ? 01:38
pugs_svn r25452 | wayland++ | Minor syntax fix 01:42
wayland karma lambdabot 01:49