»ö« Welcome to Perl 6! | perl6.org/ | evalbot usage: 'perl6: say 3;' or rakudo:, niecza:, std:, or /msg camelia perl6: ... | irclog: irc.perl6.org | UTF-8 is our friend!
Set by sorear on 25 June 2013.
dalek kudo-star-daily: af07b0e | coke++ | log/ (5 files):
today (automated commit)
01:45
rl6-roast-data: 0f29ebf | coke++ | / (5 files):
today (automated commit)
[Coke] moar: 73.40% 01:47
raiph perlmonks.org/?node_id=1068630 # of interest to timotimo? 01:55
timotimo meh :) 02:05
lue looking at S05, I'm wondering about "5) Declaration with least number of 'uses' wins" 02:16
Does 'use' mean something specific (e.g. the use statement), or is just referring generally to the number of times a declaration is used in some fashion? 02:17
timotimo i seem to recall having learnt about this once
diakopter lue: it's got to be the latter 02:18
lue so /<alpha> <alpha>/ would be using "alpha" twice, and (I'm guessing) /(<alpha>)+/ would be using it once. 02:19
diakopter I think it means overlapping uses in that stem prefix 02:20
lue
.oO('Use' is too generic a verb for this methinks)
02:21
timotimo agreed.
even if it's in scare quotes
lue The fact that you'll never encounter the tie-breaker unless you do MONKEY_PATCHING type things doesn't help one's understanding :) 02:22
timotimo right
"you'll never see this! why are we even explaining it to you?!"
diakopter "stop reading this!" 02:23
lue r: $/ = 5; say $/;
camelia rakudo-parrot e5268b, rakudo-jvm e5268b: OUTPUT«5␤»
lue That should've stopped me and made me wish for a no warnings :perl5 thing :) 02:24
timotimo should it give a warning instead?
lue $/ = $x; # "Unsupported use of $/ variable as input record separator" 02:25
so says the spec
diakopter heh, oh
timotimo r: $/ = "hi"; say $/; 02:26
camelia rakudo-parrot e5268b, rakudo-jvm e5268b: OUTPUT«hi␤»
timotimo i saw that warning once before somewhere
lue n: $/ = 5; say $/;
camelia niecza v24-109-g48a8de3: OUTPUT«(timeout)[auto-compiling setting]␤»
lue agrees with rakudo's current behavior though :) 02:29
moritz 02:52
timotimo
moritz not alone sleepless in .de 02:53
timotimo is watching a talk from the 30c3
(recht auf remix)
lue I just discovered the :c adverb, and I get the strangest feeling it would've come in handy a few times before :) 03:05
timotimo closure interpolation? 03:08
lue timotimo: I was thinking rx:c, not Q:c 03:09
timotimo oh?
i don't know what that does, to be honest
oooooh, continue
that's cute!
lue r: "foo123" ~~ m/<alpha>+/ && m:c/<digit>+/; 03:10
camelia rakudo-jvm e5268b: OUTPUT«Cannot call 'match'; none of these signatures match:␤:(Cool:D : $target, *%adverbs)␤ in any at gen/jvm/BOOTSTRAP.nqp:1201␤␤»
..rakudo-parrot e5268b: OUTPUT«Cannot call 'match'; none of these signatures match:␤:(Cool:D : $target, *%adverbs)␤ in any at gen/parrot/BOOTSTRAP.nqp:1218␤ in any at gen/parrot/BOOTSTRAP.nqp:1209␤ in method match at gen/parrot/CORE.setting:3487␤ in block at /tmp/TgDu…»
lue r: "foo123" ~~ m/<alpha>+/; say m:c/<digit>+/; 03:11
camelia rakudo-jvm e5268b: OUTPUT«Cannot call 'match'; none of these signatures match:␤:(Cool:D : $target, *%adverbs)␤ in any at gen/jvm/BOOTSTRAP.nqp:1201␤␤»
..rakudo-parrot e5268b: OUTPUT«Cannot call 'match'; none of these signatures match:␤:(Cool:D : $target, *%adverbs)␤ in any at gen/parrot/BOOTSTRAP.nqp:1218␤ in any at gen/parrot/BOOTSTRAP.nqp:1209␤ in method match at gen/parrot/CORE.setting:3487␤ in block at /tmp/arMa…»
lue What the hell is @() supposed to mean? 03:13
timotimo in what context?
isn't it a shorthand for @($/)?
lue is it?
r: say @().perl if "abracadabra" ~~ m:ov/a (.*) a/; 03:14
camelia ( no output )
lue r: say @().perl if "abracadabra" ~~ m/a (.*) a/;
camelia rakudo-parrot e5268b: OUTPUT«(Match.new(orig => "abracadabra", from => 1, to => 10, ast => Any, list => ().list, hash => EnumMap.new()),).list␤»
..rakudo-jvm e5268b: OUTPUT«(Match.new(to => 10, hash => EnumMap.new(), ast => Any, list => ().list, orig => "abracadabra", from => 1),).list␤»
timotimo it may be a shorthand to extract the .ast if it exists 03:15
lue also isn't too clear on what exactly the difference between :ov and :ex are. 03:16
timotimo easy
"the first match from every position is returned" vs "every match is returned 03:17
let me demonstrate
r: say "aaaaaa" ~~ m:ov/a+/
camelia rakudo-parrot e5268b, rakudo-jvm e5268b: OUTPUT«False␤»
timotimo ... er ...
r: say "aaaaaa" ~~ rx:ov/a+/
camelia rakudo-jvm e5268b: OUTPUT«===SORRY!=== Error while compiling /tmp/pgEcbiYhM7␤Adverb ov not allowed on rx␤at /tmp/pgEcbiYhM7:1␤------> say "aaaaaa" ~~ rx:ov/a+/⏏<EOL>␤»
..rakudo-parrot e5268b: OUTPUT«===SORRY!=== Error while compiling /tmp/ZZsWOdj0jW␤Adverb ov not allowed on rx␤at /tmp/ZZsWOdj0jW:1␤------> say "aaaaaa" ~~ rx:ov/a+/⏏<EOL>␤»
timotimo r: say "aaaaaa" ~~ m:overlap/ a+ /
camelia rakudo-parrot e5268b, rakudo-jvm e5268b: OUTPUT«False␤»
timotimo ... why?!
lue Oh, I'm currently reading S05, in case you can't tell :) . Trying to see how difficult that ol' libp6regex idea would be. 03:18
timotimo yes, i'm on S05 as well
but why does that give false?
r: say "aaaaaa" ~~ m/ a+ /
camelia rakudo-parrot e5268b, rakudo-jvm e5268b: OUTPUT«「aaaaaa」␤␤»
timotimo r: say "aaaaaa" ~~ m:ex/ a+ /
camelia rakudo-parrot e5268b, rakudo-jvm e5268b: OUTPUT«False␤»
timotimo ... wat ...
lue r: say "abaccadddaaea" ~~ m:ov/ a <-[a]>* a /
camelia rakudo-parrot e5268b, rakudo-jvm e5268b: OUTPUT«False␤»
timotimo are those just b0rken? 03:20
if i could have demonstrated, you would have seen the following results:
with overlapping: aaaaaa, aaaaa, aaaa, aaa, aa, a 03:21
with exhaustive: aaaaaa, aaaaa, aaaa, aaa, aa, a, aaaaa, aaaa, aaa, aa, a, aaaa, aaa, aa, a, aaa, aa, a, aa, a
lue timotimo: I wouldn't be surprised if they are broken. 03:21
timotimo :(
lue Ah, so ov it's "one match per spot", and ex is "every match per spot". 03:22
timotimo yup
"first match per spot" even
lue (incidentally your specific example looks like a permutations/combinations demonstration :P) 03:23
timotimo :D
lue or at least is reminiscent of one.
lue r: say "a" ~~ / <alpha> & <alnum> / 03:38
camelia rakudo-jvm e5268b: OUTPUT«「a」␤ alnum => 「a」␤ alpha => 「a」␤␤»
..rakudo-parrot e5268b: OUTPUT«「a」␤ alpha => 「a」␤ alnum => 「a」␤␤»
timotimo yup, the & is really nifty 03:40
i also love that you can capture inside the right-hand-side of the % operator
and with that, i go to bed 03:41
lue timotimo o/
TimToady we have no decent way of printing Rats with consistent number of fractional digits; see rosettacode.org/wiki/Currency#Perl_6 03:46
lue What's $¢.pos nowadays?
TimToady maybe we need an optional argument to .base
well, it's still $¢.pos in STD... 03:47
$/.CURSOR.pos or some such, iirc 03:48
lue I almost want to bring back ¢, just so the artifacts in the spec stop popping up all the time :)
TimToady $¢ has nothing to do with the old ¢ sigil 03:49
lue r: say "abc" ~~ / <alpha> {say $¢.pos} <alpha>+ / 03:50
camelia rakudo-jvm e5268b: OUTPUT«===SORRY!=== Error while compiling /tmp/iACnz6bVBb␤Unsupported use of $¢ variable␤at /tmp/iACnz6bVBb:1␤------> say "abc" ~~ / <alpha> {say ⏏$¢.pos} <alpha>+ /␤ expecting any of:␤ argument list␤ …»
..rakudo-parrot e5268b: OUTPUT«===SORRY!=== Error while compiling /tmp/YKMsAzljIa␤Unsupported use of $¢ variable␤at /tmp/YKMsAzljIa:1␤------> say "abc" ~~ / <alpha> {say ⏏$¢.pos} <alpha>+ /␤ expecting any of:␤ argument list…»
lue TimToady: I know, I just keep thinking ¢ looks cool. I think my feelings on ¢ in P6 are similar to ß in German :P (In particular Swiß German, what with its removal of the letter) 03:51
lue TimToady: "f a floating-point number, in fixed decimal notation" Is that not what you could use for currency, or am I misreading that? 03:56
lue is not a printf expert
TimToady unfortunately that attempts to translate to floating-point first, and overflows 04:00
TimToady p: printf("%0.2f", 12345123451234512345) 04:01
camelia rakudo-parrot e5268b: OUTPUT«12345123451234512896.00»
TimToady note the inaccuracy
lue Ah. Maybe we could introduce %r for Rat then, and %R for FatRat perhaps :)
(though there's a problem of if that %r would print a fraction or decimal.) 04:02
TimToady I suspect the 'f' is supposed to mean 'fixed point' 04:03
so maybe we should just make that work
lue Yeah, I wouldn't be surprised if the "floating-point" bit in the original printf was an issue of C's capabilities, rather than the preferred way to get to fixed point. 04:05
(just for %f that is)
Mouq "This example is incorrect. It does not accomplish the given task. Please fix the code and remove this message. " rosettacode.org/wiki/Parametric_pol...ism#Perl_6 04:08
TimToady maybe the task changed? 04:11
Grondilu marked it incorrect
colomon TimToady: fixing that has been on my to-do list for a while now. no time, though…. 04:12
(the %f thing, not the rosettacode thing) 04:13
TimToady hates to put workarounds into rosettacode...
but whenever...
Mouq It's strange; this seems like the logical golf: 04:14
r: role A[::T] {method test(T $t) {say $t}}; class B does A[Int] {}; B.test(4)
camelia rakudo-parrot e5268b, rakudo-jvm e5268b: OUTPUT«4␤»
Mouq But it works?
TimToady sorry, family doings (The Third Noël, or so), so distracted... 04:16
not to mention having driven from Seattle to SoCal in the last two days... 04:18
Mouq r: role A[::T] {has T $.n; method assign(T \t) {$.n = t;}}; my $golf = (class B does A[Int] {}).new; $golf.assign(4); say $golf.n 04:20
camelia rakudo-parrot e5268b: OUTPUT«No such method 'item' for invocant of type 'T'␤ in method assign at /tmp/ecZVQz7Sqv:1␤ in block at /tmp/ecZVQz7Sqv:1␤␤»
..rakudo-jvm e5268b: OUTPUT«No such method 'item' for invocant of type 'T'␤ in method assign at /tmp/C0iVA9deQD:1␤␤»
TimToady lue: it means how deep in 'use Module' nesting the declaration is; a module that is used directly counts as closer than a module that is used by a module that you use 04:54
lue Those scare quotes should say 'use's then :) 04:55
(I had a feeling it was something like that.) so does 'use MONKEY_TYPING' count, or is that simply what can cause tiebreaker #5 to be reached most easily? 04:56
TimToady MONKEY_TYPING has nothing to do with #5, unless the declaration in question was pulled in somehow by 'use MONKEY_TYPING;', which I sincerely doubt 04:57
lue so you're saying MONKEY_TYPING pulling in a module would require some serious... MONKEY_BUSINESS then? 04:58
TimToady Mouq: yeah, definitely looks like a rakudobug of some sort 05:15
TimToady gist.github.com/TimToady/8264706 <-- this works 05:18
changed 'has $!value;' to use . instead 05:19
and changed the .?'s to use 'if defined' instead
so maybe the T !=== Int is a red herring of some sort
TimToady p: say '言' ~~ /<alpha>/ 05:44
camelia rakudo-parrot e5268b: OUTPUT«「言」␤ alpha => 「言」␤␤»
TimToady p: say 'º' ~~ /<alpha>/ 05:48
camelia rakudo-parrot e5268b: OUTPUT«「º」␤ alpha => 「º」␤␤»
TimToady p: say '°' ~~ /<alpha>/ 05:49
camelia rakudo-parrot e5268b: OUTPUT«Nil␤»
TimToady keeps wondering why people use º for degrees when it's just as easy to get to °
lue TimToady: me too 05:50
TimToady easier, in fact, with a compose key, since it's just compose-o-o
TimToady of course, then there's why people use °F when there's a precomposed ℉ 05:50
lue r: say ord("℉") 05:51
camelia rakudo-parrot e5268b, rakudo-jvm e5268b: OUTPUT«8457␤»
TimToady p: say ord('℉').base(16) 05:52
camelia rakudo-parrot e5268b: OUTPUT«2109␤»
TimToady also doesn't understand why people use decimals for unicode codepoints :)
lue I was just too lazy to type the .base(16) part :P 05:54
lue doesn't understand why ord doesn't produce a hex string, as that's what people tend to be going for anyway in Unicode-land :)
TimToady well, we could return an IntStr, I guess... 05:56
but it seems like a low-lux feature
lue use radix :16th could be another solution :)
my $a = 2A; and such 05:57
lue half-proposes that 0d123 change to 0i123, as that's the first letter in "decimal" that doesn't show up in hex. 05:58
raydiak is there any reason ":!$foo" couldn't be used to mean ":foo(!$foo)"? 06:20
TimToady
.oO(This means the opposite of what you think it means...)
06:43
raydiak it'd be useful when you have recursive routines that tend to toggle flags before passing them to the next level, which seems to emerge in my designs from time to time; is it just me? 06:49
TimToady I really don't see a reason to encourage people to flip the polarity of "foo" like that; it's a design smell most of the time, and not worth huffmanizing the rest of the time, methinks 06:50
and in the cases where you'd want it, toggle => !$toggle would be much clearer
raydiak all true...keep the more frightening things more difficult to type, I suppose 06:52
lue I have to say, I've always felt a bit weird that :adv/:!adv was some sort of weird trinary thing by default, except that you need to check two things for that trinariness.
TimToady also, :!$ is just a bit too much punctuation in a row for most sane people :) 06:53
bad enough we can have :$^foo and such 06:54
or even :$:foo :)
raydiak does :$!foo work? 06:55
TimToady should
lue raydiak: sure, that's :foo($!foo)
.oO( :!$@!attr )
TimToady "What is that, swearing?" --Heidi 06:56
Appearances to the contrary notwithstanding, we are not optimizing Perl 6 for golf. :) 06:57
raydiak haha. I really should avoid using line noise syntax, whther it's valid or not...obsessive compulsions die hard I suppose 07:00
masak "It was dishonest to call it Python." -- news.ycombinator.com/item?id=7013438 08:52
(just as some people want Perl 6 to have been called something else.)
'morning, #perl6
raydiak \o good morning masak 08:55
tadzik wow, imagine Perl 5 users saying "booo, 5.10 is not Perl anymore, dishonest!" 09:02
but maybe that's the point here; it's not different enough to justify the migration hassle 09:04
xfix Is there max() function that returns lvalue? 09:11
It would be nice for codegolf.stackexchange.com/questio...m-in-array
raydiak japhb: since you were trying to use it, thought you'd want to know that deintersection not only runs without errors, but also now actually functions :) 09:30
moritz \o 10:55
virtualsue greets 10:58
moritz hello virtualsue
masak tadzik: the Perl community tried a Big Upgrade. it took several years, and people got tired of waiting and started advocating forgetting Perl 6 and sticking with Perl 5. 12:43
tadzik: the Python community tried a Small, Limited Upgrade. it took several years, and people got tired of waiting and started advocating forgetting Python 3.x and sticking with Python 2.7.
masak maybe the lesson simply is "however you do it, some people will lose patience and/or advocate sticking with $?OLD_VERSION" 12:59
nwc10 there is at least one difference. Python 3 has declared itself "production ready" for about 5 years (while Perl 6 hasn't), but the end user Python upgrade plan always assumed a flag day change. (effectively) 13:02
we've not yet seen what will pan out once Larry (and @Larry) says "Perl 6 is ready"
masak troo. 13:11
in practice, I doubt there will be much migration of Perl 5 projects to Perl 6, whatever time scale you choose to look on. 13:12
nwc10 my assumption also. Not much working Perl 5 code is going to get re-written as Perl 6. 13:21
The trick is to make it easier to run a hetrogeneous Perl 5/Perl 6 environment than a hetrogeneous Perl 5/$other
masak aye. 13:22
nwc10 although, another significant difference betwen 2 and 3 vs 5 and 6 is that 3 doesn't really have many exciting features over and above 2. Particularly, it still has a GIL. Whereas 6 offers at least one obvious relevant feature - less insane concurrency 13:23
Python 2 is already too damn good
masak yeah, that's what I meant by "Big Upgrade" vs "Small, Limited Upgrade". 13:24
timotimo o/ 14:44
masak \o 14:46
FROGGS o/ 14:49
timotimo how can perl6's concurrency be anything other than insane if it doesn't have a GIL? :) 15:10
arnsholt Well, it's going to be concurrent. Which probably guarantees a certain amount of insanity^Whilarity =) 15:49
masak well, if anything is to ensue, it might as well be hilarity. 16:20
thundergnat r: say (max map {.chars => $_},<juicypacakes sweetchickeneggs tastycheezezzz yourmomzez countchoclatez>).value~'izwhatzforzbrekfatz'; 16:27
preflex thundergnat: you have 1 new message. '/msg preflex messages' to read it.
camelia rakudo-parrot e5268b, rakudo-jvm e5268b: OUTPUT«sweetchickeneggsizwhatzforzbrekfatz␤»
thundergnat xfix: ^^ not exactly what you were looking for... but close. 16:28
timotimo max-rw and min-rw does sound really convenient 16:48
(no matter if it's to replace max or be a separate operator) 16:49
dalek kudo-star-daily: 65ed5eb | coke++ | log/ (5 files):
today (automated commit)
16:58
FROGGS p: my role Hurz; 1 does Hurz; # masak, a bug for you :o) 17:03
camelia rakudo-parrot e5268b: OUTPUT«(signal KILL)»
timotimo [...]None of the parametric role variants for 'Hurz' matched the arguments supplied. 17:07
maximum recursion depth exceeded
o_O
there aren't even parameters for that role >_<
FROGGS adding the role's body helps :o)
timotimo oh! 17:08
of course
it's a semicolon definition of the role
like class Foobar;
arnsholt r: my class Foo; my Foo $foo .= new; 17:13
camelia ( no output )
timotimo r: class Test { say "oh my" }; 17:26
camelia rakudo-parrot e5268b, rakudo-jvm e5268b: OUTPUT«oh my␤»
timotimo what time does that run?
colomon r: class Test { say "oh my" }; BEGIN { say "begin"; }; say "end?"; 17:32
camelia rakudo-parrot e5268b, rakudo-jvm e5268b: OUTPUT«begin␤oh my␤end?␤»
colomon r: say "sackbut"; class Test { say "oh my" }; BEGIN { say "begin"; }; say "end?"; 17:33
camelia rakudo-parrot e5268b, rakudo-jvm e5268b: OUTPUT«begin␤sackbut␤oh my␤end?␤»
timotimo so ... compose time? 17:36
oh, just run time i guess
colomon class creation time, I think, which is regular run time, right? 17:37
timotimo may be 17:38
timotimo can we please spec something that makes the "highwater" stuff available in arbitrary grammars? :\ 18:27
getting a partial parse tree, for exmaple
FROGGS +1, since that question comes often from various ppl 18:41
clsn__ How would I refer to a method as code, as opposed to calling it? That is, sub foo {...} can later be referred to as &foo, but what about class A { method bar {...} } ? 18:46
arnsholt There's a call find_method in the MOP, IIRC 18:47
clsn__ I can do A.^methods[0] I think, or other tricks like that, but that seems sort of roundabout. 18:48
arnsholt r: class A { method foo { say "foo" } }; my A $a .= new; my $m = $a.^find_method("foo"); $m($a); # clsn__
camelia rakudo-parrot e5268b, rakudo-jvm e5268b: OUTPUT«foo␤»
clsn__ Thanks.
Can't find private methods that way I think. Hm. 18:53
moritz sure; they are private :-)
if you could find them, you could call them
clsn__ I mean, you can't even find them from inside the class that way. 18:54
moritz r:my $n = 1e2; my @methods := $n.^can('sqrt'); say @methods[0]($n)
p: my $n = 1e2; my @methods := $n.^can('sqrt'); say @methods[0]($n)
camelia rakudo-parrot e5268b: OUTPUT«10␤»
moritz clsn__: there's a find_private_method 18:55
clsn__ orly? I didn't know.
moritz I just found by looking into src/Perl6/Metamodel/PrivateMethodContainer.nqp
clsn__ not sure it's working... lessee... 18:56
clsn__ Aha, no, it works. 18:56
moritz p: class A { method !foo { say 42 } }; A.^find_private_method('foo')(A) 18:56
camelia rakudo-parrot e5268b: OUTPUT«42␤»
clsn__ Mm, that shouldn't work from outside the class though. Makes the private public. 18:58
moritz there are no access restrictions when going meta
just like you can inspect private attributes and all that 18:59
because in the end, everything builds on the MOP
in the end, it's still "we're all adults around here"
Perl 6 goes a step further to make access to foreign private stuff more inconvenient 19:00
clsn__ I guess.
moritz but it doesn't really treat it as hard barrier
just like C++ for example (where you can still grab a pointer to private methods if you do enough black magic)
[Coke] r: say 22311 - 20883 ; # moar improvement
camelia rakudo-parrot e5268b, rakudo-jvm e5268b: OUTPUT«1428␤»
[Coke] (based on today's waiting-for-the-jvm-to-finish daily run) 19:01
FROGGS very nice! 19:03
timotimo clsn__ o/ 19:06
clsn__ o/
clsn__ Rix: class D { has Int $.x; has &!setter=method ($self: $v) { $!x=$v; }; method val is rw { Proxy.new(FETCH=>method {$.x*10}, STORE=>method ($s: $f) {&!setter($f-10)}) } }; my $a=D.new; $a.val 19:11
Argh.
r: class D { has Int $.x; has &!setter=method ($self: $v) { $!x=$v; }; method val is rw { Proxy.new(FETCH=>method {$.x*10}, STORE=>method ($s: $f) {&!setter($f-10)}) } }; my $a=D.new; $a.val 19:12
camelia rakudo-jvm e5268b: OUTPUT«Unhandled exception: java.lang.StackOverflowError␤ in <anon> (/tmp/G1HSkE_rWe)␤ in (gen/jvm/BOOTSTRAP.nqp:300)␤ in <anon> (/tmp/G1HSkE_rWe)␤ in (gen/jvm/BOOTSTRAP.nqp:300)␤ in <anon> (/tmp/G1HSkE_rWe)␤ in (gen/jvm/BOOTSTRAP.nqp:300)␤ …»
..rakudo-parrot e5268b: OUTPUT«(signal SEGV)»
clsn__ (auto nick completion)
woo, segv.
Mouq clsn__: what are you trying to do? method != sub 19:20
or... wait :P 19:22
clsn__ well,simpler cases cause the problem; I think there mighgt be some infinite regress using $.x in FETCH. 19:23
But look, all this is various attempts to do something that ought to be simple.
Let's say I have a class temperature. It stores its value internally as kelvins. There's a method .celcius that gives me the celcius equivalent. I'd like to make .celcius rw, so I could set it to a celcius temp, and it would do the conversion internally. 19:24
Mouq you can do that
clsn__ This is really tough with a proxy object, since the proxy obj doesn't have access to the private attributes.
So I was thinking about passing in a setter closure to the proxy obj etc... 19:25
Mouq we don't have methods that are... first class(???) like that, I'm pretty sure. You can do that, I think, but methods only exist in the first level of the class/role/grammar's body AFAIK 19:27
clsn__ Yeah, that's why I started trying stuff like "has &!setter" instead of "method setter". How would you do it? 19:27
Mouq I'm not actually sure what Proxy does. :P I'm just saying that using method anywhere other than at the statement level of class Whatev { ... } is gonna cause trouble :PP 19:30
clsn__ heh. ok. 19:31
Mouq You might be able to get away with making closures out of 'sub's and/or '->'s that capture self somehow, though I wouldn't be surprised if you run into bugs 19:31
Mouq r: class D { has Int $.x; has &!setter=sub ($v) { $!x=$v; }; method val is rw { Proxy.new(FETCH=>sub {$.x*10}, STORE=>sub ($f) {&!setter($f-10)}) } }; my $a=D.new; $a.val 19:32
camelia rakudo-jvm e5268b: OUTPUT«Unhandled exception: Too many positional parameters passed; got 1 but expected 0␤ in (/tmp/GkK7EmC85X)␤ in (gen/jvm/BOOTSTRAP.nqp:300)␤ in MAIN (gen/jvm/main.nqp:46)␤ in (gen/jvm/main.nqp:41)␤ in (gen/jvm/main.nqp)␤␤»
..rakudo-parrot e5268b: OUTPUT«Too many positional parameters passed; got 1 but expected 0␤current instr.: '' pc 355 ((file unknown):206) (/tmp/qzxm0nxOH7:1)␤called from Sub '' pc 14044 (src/gen/perl6-bootstrap.pir:3858) (gen/parrot/BOOTSTRAP.nqp:315)␤called from Sub 'MAIN' pc 3…»
Mouq r: class D { has Int $.x; method export-setter { sub ($v) { $!x=$v; } }; }; my $a=D.new; my $b = $a.export-setter; $b(5); say $a.x 19:33
camelia rakudo-parrot e5268b, rakudo-jvm e5268b: OUTPUT«5␤»
Mouq \o/
That's pretty awesome
clsn__ Now to shoehorn that into a Proxy somehow... 19:34
Mouq r: class D { has Int $.x; method val is rw { Proxy.new(FETCH=> ->{$.x*10}, STORE=> ->$f{$!x=$f-10}) } }; my $a=D.new; $a.val 19:35
camelia rakudo-jvm e5268b: OUTPUT«Unhandled exception: Too many positional parameters passed; got 1 but expected 0␤ in (/tmp/FUQEXDc21K)␤ in (gen/jvm/BOOTSTRAP.nqp:300)␤ in MAIN (gen/jvm/main.nqp:46)␤ in (gen/jvm/main.nqp:41)␤ in (gen/jvm/main.nqp)␤␤»
..rakudo-parrot e5268b: OUTPUT«Too many positional parameters passed; got 1 but expected 0␤current instr.: '' pc 277 ((file unknown):159) (/tmp/a11f63PJK_:1)␤called from Sub '' pc 14044 (src/gen/perl6-bootstrap.pir:3858) (gen/parrot/BOOTSTRAP.nqp:315)␤called from Sub 'MAIN' pc 3…»
Mouq hmm
BenGoldberg I wish Proxy were better documented :(
Mouq I wish Proxy were better documented and threw better errors :/ 19:36
clsn__ Yeah. I'm not sure it's powerful enough to do all that we ask of it. 19:37
Mouq r: class D { has Int $.x; method val is rw { Proxy.new(FETCH=> ->{$x*10}, STORE=> ->$f{$!x=$f-10}) } }; my $a=D.new; $a.val
camelia rakudo-parrot e5268b: OUTPUT«===SORRY!=== Error while compiling /tmp/agHOmwzH6e␤Variable '$x' is not declared␤at /tmp/agHOmwzH6e:1␤------> thod val is rw { Proxy.new(FETCH=> ->{$x⏏*10}, STORE=> ->$f{$!x=$f-10}) } }; my $␤ expecting a…»
..rakudo-jvm e5268b: OUTPUT«===SORRY!=== Error while compiling /tmp/6b4tSNqvHn␤Variable '$x' is not declared␤at /tmp/6b4tSNqvHn:1␤------> thod val is rw { Proxy.new(FETCH=> ->{$x⏏*10}, STORE=> ->$f{$!x=$f-10}) } }; my $␤ expecting any …»
Mouq oops
r: class D { has Int $.x; method val is rw { Proxy.new(FETCH=> ->{$!x*10}, STORE=> ->$f{$!x=$f-10}) } }; my $a=D.new; $a.val
camelia rakudo-jvm e5268b: OUTPUT«Unhandled exception: Too many positional parameters passed; got 1 but expected 0␤ in (/tmp/3pwDe3BOgl)␤ in (gen/jvm/BOOTSTRAP.nqp:300)␤ in MAIN (gen/jvm/main.nqp:46)␤ in (gen/jvm/main.nqp:41)␤ in (gen/jvm/main.nqp)␤␤»
..rakudo-parrot e5268b: OUTPUT«Too many positional parameters passed; got 1 but expected 0␤current instr.: '' pc 277 ((file unknown):195980479) (/tmp/jRxRDXVYfF:1)␤called from Sub '' pc 14044 (src/gen/perl6-bootstrap.pir:3858) (gen/parrot/BOOTSTRAP.nqp:315)␤called from Sub 'MAIN…»
clsn__ Adding some slurpy *@_ params here and there would at least suppress that error message. 19:40
Mouq r: class D { has Int $.x = 0; method val is rw { my $n := $.x; Proxy.new(FETCH=> sub {@_;$n*10}, STORE=> sub {$n=@_[0]-10}) } }; my $a=D.new; $a.val 19:41
camelia ( no output )
Mouq It should really be easier than that, but that's the simplest I got it 19:43
clsn__ class E { has Int $.x; method !export-setter { sub ($v) { $!x=$v; } }; method val($self:) is rw { Proxy.new(FETCH=>sub (*@_) {$self.x*10;},STORE=>sub ($s,$v) { ($self!export-setter)($v-10) }) } }; my $a=E.new(x=>10); $a.val
r: class E { has Int $.x; method !export-setter { sub ($v) { $!x=$v; } }; method val($self:) is rw { Proxy.new(FETCH=>sub (*@_) {$self.x*10;},STORE=>sub ($s,$v) { ($self!export-setter)($v-10) }) } }; my $a=E.new(x=>10); $a.val
camelia ( no output )
clsn__ huh, that worked for me... 19:44
r: class E { has Int $.x; method !export-setter { sub ($v) { $!x=$v; } }; method val($self:) is rw { Proxy.new(FETCH=>sub (*@_) {$self.x*10;},STORE=>sub ($s,$v) { ($self!export-setter)($v-10) }) } }; my $a=E.new(x=>10); $a.val=8
camelia ( no output )
clsn__ r: class E { has Int $.x; method !export-setter { sub ($v) { $!x=$v; } }; method val($self:) is rw { Proxy.new(FETCH=>sub (*@_) {$self.x*10;},STORE=>sub ($s,$v) { ($self!export-setter)($v-10) }) } }; my $a=E.new(x=>10); say $a.val
camelia rakudo-parrot e5268b, rakudo-jvm e5268b: OUTPUT«100␤»
clsn__ r: class E { has Int $.x; method !export-setter { sub ($v) { $!x=$v; } }; method val($self:) is rw { Proxy.new(FETCH=>sub (*@_) {$self.x*10;},STORE=>sub ($s,$v) { ($self!export-setter)($v-10) }) } }; my $a=E.new(x=>10); say $a.val=8
camelia rakudo-parrot e5268b, rakudo-jvm e5268b: OUTPUT«-20␤»
clsn__ There, that works.
Sprinkled *@_ around just to shut up error messages. 19:45
colomon r: say 2.log 20:18
camelia rakudo-jvm e5268b: OUTPUT«0.6931471805599453␤»
..rakudo-parrot e5268b: OUTPUT«0.693147180559945␤»
pmurias r: class E { has Int $.x; method val($self:) is rw { Proxy.new(FETCH=>sub (*@_) {$!x*10;},STORE=>sub ($s,$v) { $!x = $v-10 }) } }; my $a=E.new(x=>10); $a.val=8; say $a.val; 20:48
camelia rakudo-parrot e5268b, rakudo-jvm e5268b: OUTPUT«-20␤»
pmurias clsn__: ^^ you don't need to define helper setter methods
FROGGS r: class E { has Int $.x; method val($self:) { Proxy.new(FETCH=>sub (*@_) {$!x*10;},STORE=>sub ($s,$v) { $!x = $v-10 }) } }; my $a=E.new(x=>10); $a.val=8; say $a.val; 20:50
camelia rakudo-parrot e5268b, rakudo-jvm e5268b: OUTPUT«-20␤»
FROGGS and no 'is rw'
clsn__ I thought the is rw was key. OK. 21:02
clsn__ Not clear what goes on in that *@_ slurpy param. When I try to print it out before returning the value, it never returns. When I return @_, I get an empty array. 21:15
lue clsn__: have you tried using something other than @_ for slurpy, see if that somehow is the issue? /me doesn't recall what, if any, weird stuff @_ does. 21:23
clsn__ Name doesn't matter; it looks like it contains the Proxy object, but printing that out causes things to thrash. I can print out +@_ or @_[0].WHAT. 21:41
pmurias FROGGS: re no 'is rw' isn't that a rakudo bug?
masak pmurias: no, $!x is always writable. 21:43
(because it's the underlying storage)
clsn__ But shouldn't the method have to be marked is rw?
FROGGS pmurias: I'm not sure... I tend to think that the proxy is always writeable if you make its STORE method that way...
pmurias r: my $foo; $foo = 1; sub foo { $foo };foo = 123;say $foo 21:44
camelia rakudo-jvm e5268b: OUTPUT«===SORRY!=== Error while compiling /tmp/jyTiriQKsZ␤Preceding context expects a term, but found infix = instead␤at /tmp/jyTiriQKsZ:1␤------> y $foo; $foo = 1; sub foo { $foo };foo =⏏ 123;say $foo␤»
..rakudo-parrot e5268b: OUTPUT«===SORRY!=== Error while compiling /tmp/4OPj_aUdI6␤Preceding context expects a term, but found infix = instead␤at /tmp/4OPj_aUdI6:1␤------> y $foo; $foo = 1; sub foo { $foo };foo =⏏ 123;say $foo␤»
pmurias r: my $foo; $foo = 1; sub foo { $foo };foo() = 123;say $foo
camelia rakudo-jvm e5268b: OUTPUT«Cannot assign to a readonly variable or a value␤␤»
..rakudo-parrot e5268b: OUTPUT«Cannot assign to a readonly variable or a value␤ in block at /tmp/JfWT0Csz0K:1␤␤»
pmurias r: my $foo; $foo = 1; sub foo is rw { $foo };foo() = 123;say $foo
camelia rakudo-parrot e5268b, rakudo-jvm e5268b: OUTPUT«123␤»
pmurias masak, FROGGS: is rw seems to be required 21:45
FROGGS you don't have a proxy there 21:46
clsn__ r: class A { has Int $.x; method val($self:) {Proxy.new(FETCH=>sub ($d) { $!x*10}, STORE=>sub ($a,$v) { $!x=$v-10})}}; my $a=A.new(:x(10)); say $a.val 21:46
camelia rakudo-parrot e5268b: OUTPUT«(signal SEGV)»
..rakudo-jvm e5268b: OUTPUT«100␤»
clsn__ Interesting! I only have rakudo-p, I kept getting segvs.
FROGGS the proxy is in charge to handle fetch and store, so why don't you let it handle it? 21:47
pmurias S06:535
synopsebot Link: perlcabal.org/syn/S06.html#line_535
clsn__ It's okay if the $d is *@d, but not $d.
pmurias r: class A { has Int $.x; method val($self:) is rw {Proxy.new(FETCH=>sub ($d) { $!x*10}, STORE=>sub ($a,$v) { $!x=$v-10})}}; my $a=A.new(:x(10)); say $a.val
camelia rakudo-parrot e5268b: OUTPUT«(signal SEGV)»
..rakudo-jvm e5268b: OUTPUT«100␤»
clsn__ It's the signature of the FETCH that it doesn't like somehow. 21:48
pmurias actually according to the spec Proxy takes methods
FROGGS r: class A { has Int $.x; method val($self:) is rw {Proxy.new(FETCH=>sub ($d) { $self.x*10}, STORE=>sub ($a,$v) { $!x=$v-10})}}; my $a=A.new(:x(10)); say $a.val
camelia rakudo-parrot e5268b: OUTPUT«(signal SEGV)»
..rakudo-jvm e5268b: OUTPUT«100␤»
FROGGS r: class A { has Int $.x; method val($self:) is rw {Proxy.new(FETCH=>sub ($d) { $self.x*10}, STORE=>sub ($a,$v) { $self.x=$v-10})}}; my $a=A.new(:x(10)); say $a.val 21:49
clsn__ Yeah, I'd been trying with methods on the proxy before but at least the subs worked.
camelia rakudo-parrot e5268b: OUTPUT«(signal SEGV)»
..rakudo-jvm e5268b: OUTPUT«100␤»
masak personally, I like "100" a lot better. 21:57
FROGGS depends... is "signal SEGV" a type object? 21:59
FROGGS p: Int.HOW.set_name(Int, "signal SEGV"); say my Int $x # /o\ 22:01
camelia rakudo-parrot e5268b: OUTPUT«(signal SEGV)␤»
lue FROGGS: no(t yet, perhaps)
( notice how your example has ␤ after the () )
FROGGS :P
we should invent a game: abuse the MOP 22:02
lue I forget if SIGSEGV is one of those uncatchable signals (I'm guessing no, but...)
geekosaur it's catchable, just dubious 22:10
since it's entirely likely that something is now too screwed up for you to be able to do anything
masak 'night, #perl6 22:32
jnthn is home from the Christmas/New Year travels :) 23:54
preflex jnthn: you have 1 new message. '/msg preflex messages' to read it.
timotimo oh hey jnthn :) 23:55
can you quickly sketch out what method bind_sig is supposed to do when it gets a BIND_RESULT_JUNCTION back from the binder? 23:56
it seems like all i have to do is call Junction.AUTOTHREAD($caller, $sig)
but if that was all, it wouldn't have been stubbed with a nqp::die that's about as many characters of code as the corresponding implementation 23:57
ah, no, that's not quite right 23:59
i think i have to keep the signature, but prepend the code to be called to it and invoke the method with that resulting signature perhaps?