Perl 6 - the future is here, just unevenly distributed

IRC log for #perl6, 2014-12-28

Perl 6 | Reference Documentation | Rakudo

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

All times shown according to UTC.

Time Nick Message
00:00 colomon oh, making automatic proxies.  yes, that sounds like MOP
00:00 psch where "stuck" means "not sure if that's the best way to solve it, but the only way i can think of"
00:01 psch (and "make" means "has the following observation attached" ...)
00:01 psch err, *"means" means
00:01 psch i'm getting tired i think :)
00:04 mickcy_ca kjs: mortiz sleeping
00:06 aborazmeh joined #perl6
00:17 mickcy_ca psch:  if you don't know if your tired ... who else could?
00:21 psch mickcy_ca: i'm not sure i quite follow
00:22 tinyblak joined #perl6
00:22 mickcy_ca You must be really tired then.
00:22 mickcy_ca ;)
00:33 psch well, g'night o/
00:35 Mso150_j_i joined #perl6
01:12 * raydiak wonders about the semantic differences between 'is pure' and 'is cached'
01:23 raydiak naively, it seems like they may ultimately be implying the same set of restrictions, or close to it
01:28 raydiak .oO( all these humans and their sleeping...such a tragic necessity )
01:56 timotimo o/
01:56 timotimo anything exciting happen while i was away?
01:57 raydiak yes!
01:57 raydiak https://github.com/masak/007 http://masak.github.io/007/
02:01 timotimo cute, i like
02:20 rmgk_ joined #perl6
02:22 mickcy_ca left #perl6
03:03 Mso150_j_i_h joined #perl6
03:13 aborazmeh joined #perl6
03:38 telex joined #perl6
03:43 xinming joined #perl6
03:47 noganex joined #perl6
04:07 aborazmeh joined #perl6
04:16 mickcy_ca joined #perl6
04:19 gfldex joined #perl6
04:21 mickcy_ca Another grammar question ... aside from the $/<> nomenclature for accessing the results, is there any other way to get to them, perhaps as a hash?
04:21 dj_goku joined #perl6
04:22 mickcy_ca For instance, I see a LOT online about how to make them ... but I have not seen an easy way to access the results.
04:32 Mso150_j_i_h joined #perl6
04:35 Timbus mickcy_ca, uh. that is accessing them as a hash..
04:36 mickcy_ca Timbus: ... just figured that one out ...
04:37 adu joined #perl6
04:41 mickcy_ca Is there a hash dumper for P6 that does something like Data::Dumper for P5?
04:43 jack_rabbit joined #perl6
04:43 skids .perl and .gist builtins.
04:52 mickcy_ca Now, my problem is accessing anything but the first two levels of my match object.  My gist is at http://pastebin.com/WnqHTPvV and gives the basic framework for my problem.  Accessing the parameter list, for instance, in a way that I can use it has proven to be a problem for me.
04:54 Timbus there was a rly good advent post about building objects from parse trees
04:55 Timbus no it was a.. presentation or something. hm
04:56 mickcy_ca OK ... I was wondering about that because I have been avidly reading the advent posts and didn't notice one on that particular topic.
04:57 Timbus http://www.jnthn.net/papers/​2014-fosdem-perl6-today.pdf
04:57 Timbus here ya go
04:57 mickcy_ca Thanks ... will go through it.
04:58 Timbus its pretty pertinent to what you're doing, youll probably have a eureka or two at the Actions class bit. but try to read it all (its not too long)
04:58 mickcy_ca Maybe not what I'm doing ... but what I'm attempting.
05:05 jack_rabbit joined #perl6
05:17 mickcy_ca Timbus:  Great read, lots of good information.  Is it true that MoarVM still does not integrate the concurrency capabilities of Rakudo, and that the only option for concurrency is running on the JVM?
05:17 Timbus no
05:17 Timbus but the jvm is more stable for sure
05:17 mickcy_ca OK.
05:18 Timbus light, simple use of threads generally doesnt cause a crash.
05:20 mickcy_ca That is good to know ... I will probably be using some of those features if this project actually gets off the ground.
05:37 jack_rabbit joined #perl6
05:45 mickcy_ca Timbus: do you know what the *% means in that pdf link you sent to me ... the line is
05:45 mickcy_ca submethod BUILD(:%info (:Name($!name), :Country($!country), *%), :@!data)
05:46 mickcy_ca Where :@ is : @
05:46 Timbus slurpy parameter with no name
05:47 Timbus to catch everything, i guess?
05:47 Timbus m: sub foo(*%) { 42 }; say foo(a => 'b')
05:47 camelia rakudo-moar ce1e74: OUTPUT«42␤»
05:47 mickcy_ca I figured that the array was for that ...
05:48 mickcy_ca I guess that was all it takes to compute the answer the life, the universe, and everything.
05:49 Timbus from what i can see, :@data is just a named parameter
05:50 mickcy_ca All it does is store the temperature information.
05:50 Timbus :%info (:Name($!name), :Country($!country), *%)   is unpacking the args into the %info hash
05:51 mickcy_ca That I understood ... what I don't understand is why a slurpy unamed parameter would need to be used in this case.
05:52 mickcy_ca As it appears that anything it got is thrown out anyway.
05:54 Timbus m: sub foo(%thing ( *% )){ say %thing.perl }; foo({foo => 'bar', asdf => 'fdsa'});
05:54 camelia rakudo-moar ce1e74: OUTPUT«("asdf" => "fdsa", "foo" => "bar").hash␤»
05:55 Timbus hes keepin it by letting it pass through
05:55 raydiak it makes the dispatch not fail when there are other named args passed to bless, like for instance inherited attributes
05:55 mickcy_ca Ah.
05:58 Timbus raydiak, that would be if the slurpy was outside of the unpack
05:59 raydiak Timbus: aren't we talking about the submethod BUILD in the pdf still?  I just went ^F*% and looked at the first result :)
06:00 raydiak sorry if I jumped in confused
06:01 Timbus well, yeah. but the *% isnt in the param list, its in  ( :%info ( *% ) )
06:01 raydiak oh! m)
06:01 raydiak I see it, my bad
06:02 raydiak so it makes dispatch not fail if there are other entries in the hash
06:02 Timbus yeah
06:03 Timbus sub-signature! thats the word for it. the sub-signature would fail if info had extra keys
06:05 Timbus m: sub foo(:%info (:Name($a), :Country($b)) { say %info }; foo(info => {asdf => 1, Name => 'wot'})
06:05 camelia rakudo-moar ce1e74: OUTPUT«[31m===[0mSORRY![31m===[0m Error while compiling /tmp/J0WXWiJFPP�Missing block�at /tmp/J0WXWiJFPP:1�------> [32mub foo(:%info (:Name($a), :Country($b)) [33m�[31m{ say %info }; foo(info => {asdf => 1, N[0m�»
06:05 Timbus m: sub foo(:%info (:Name($a), :Country($b))) { say %info }; foo(info => {asdf => 1, Name => 'wot'})
06:05 camelia rakudo-moar ce1e74: OUTPUT«Unexpected named parameter 'asdf' passed in sub-signature of parameter %info␤  in sub foo at /tmp/PA5r2HIT2b:1␤  in block <unit> at /tmp/PA5r2HIT2b:1␤␤»
06:05 Timbus that
06:05 Timbus m: sub foo(:%info (:Name($a), :Country($b), *%)) { say %info }; foo(info => {asdf => 1, Name => 'wot'})
06:05 camelia rakudo-moar ce1e74: OUTPUT«"Name" => "wot", "asdf" => 1␤»
06:06 Timbus should cover it
06:07 Timbus and possibly just as important to note is $a and $b will be available in the sub
06:09 [Sno] joined #perl6
06:11 raydiak oh right there is a *% implicitly added to your BUILD, that's what I was thinking of
06:12 raydiak m: class{ ( submethod BUILD () {} ).signature.say }
06:12 camelia rakudo-moar ce1e74: OUTPUT«:(<anon>: *%_)␤»
06:13 skids r: use Pod::To::Text; class MyPod does Pod::To::Text { } # any guesses as to why it is not composable?
06:13 camelia rakudo-{parrot,moar} ce1e74: OUTPUT«[31m===[0mSORRY![31m===[0m Error while compiling /tmp/tmpfile�Pod::To::Text is not composable, so MyPod cannot compose it�at /tmp/tmpfile:1�------> �»
06:14 raydiak is it a class instead of a role?
06:14 skids yes.
06:14 skids doh.
06:14 raydiak I knew we could use roles as classes...didn't know we could go the other way
06:15 skids no you're right.
06:15 skids I'm just so used to using roles.
06:16 raydiak I've been wanting to use them more, I hear they make things much cleaner in a lot of ways
06:17 mickcy_ca Timbus: I saw $a and $b once and noted their importance ... but have since lost the reference.  Can you elucidate me on why they are so important?
06:18 Timbus no, not the names of them
06:18 raydiak afk
06:18 skids raydiak: Well, yes mostly. Except when you need to reference them without referring to a pun class.  Which I haven't figured out how to do in some cases.
06:18 Timbus its that the function has declared $a and $b as parameters along with %info
06:19 mickcy_ca Ah.
06:19 Timbus m: sub foo(:%info (:Name($z), :Country($x), *%)) { say $z }; foo(info => {asdf => 1, Name => 'wot'})
06:19 camelia rakudo-moar ce1e74: OUTPUT«wot␤»
06:20 mickcy_ca Didn't notice that ....
06:20 Timbus this is how BUILD is initializing the class attributes 'automatically'
06:22 mickcy_ca OK ... I am  curious why one would a hash ... would the same results of implicit assignment be achieved with only an ordered list of parameters?
06:23 mickcy_ca That is aside from nice notation on the call to new.
06:24 Timbus the hash is because we're passing two hashes in the fist place and need a way to separate them
06:24 mickcy_ca Ok.
06:24 Timbus in a simpler case you can (and do) use submethod BUILD(:$!attrib){}
06:27 Timbus this way merely pulls an attribute out of a hash that was passed, for convenience
06:27 mickcy_ca Looking for information on the make keyword.
06:30 mickcy_ca Found it ... very sparse but if anyone has a more verbose explanation than http://doc.perl6.org/routine/make I would like to see it.
06:31 Timbus thats basically all I know of it
06:31 Timbus make creates the data you later pull out with .ast
06:32 skids In other words it just sets the .ast member of the Match object, which is your scratchpad.
06:32 mickcy_ca With .ast, are we mucking around with internal structures?
06:32 Timbus basically turning your named match into node of data
06:32 mickcy_ca Thank you.  Very nice way to put it.
06:38 skids You have to build up the .ast tree as you see fit -- the individual .ast elements are not linked to each other unless you do it.  Which is why you see stuff like make $/<octet>>>.ast in action methods a lot.  So you get to regraft the tree to remove uneeded nodes.
06:47 mickcy_ca Alchohol and programming don't go well together.
06:49 skids mickcy_ca: http://xkcd.com/323/
06:50 mickcy_ca LOLOLOLOLOLOL
06:50 rindolf joined #perl6
06:53 mickcy_ca Good night #perl6
06:53 skids o/
06:54 mickcy_ca left #perl6
07:03 skids Well, I guess Pod::To::* stand currently as examples of how bunches of subs in a package don't lend themselves to tweaking.
07:10 raydiak yeah istr ::to::html feeling kinda crufty
07:15 skids I want to use the new .WHY stuff but having newlines in signatures makes Text not look very manpageish.
07:17 skids The DOC INIT stuff seems to actually work, though, so that's good.
07:20 raydiak where should I be reading to catch up to the new stuff you're talking about? :)
07:21 skids Specwise it's not new, just a lot of S26 was implemented.
07:23 * raydiak isn't sure where to read news like that w/o p6weekly
07:24 skids r: #| The sub does foobar␤sub f { }; &f.WHY.say
07:24 camelia rakudo-{parrot,moar} ce1e74: OUTPUT«The sub does foobar␤»
07:25 skids Yeah I just saw the IRC chat when it was being worked on.
07:25 raydiak oh I saw someone use that a few days ago...yeah that's gonna be neat stuff to use
07:32 raydiak I see what you meant...if you want to document each argument, you can't really read the signature as a whole very easily
07:33 raydiak s/argument/parameter/
07:37 skids Not sure parameters are things that can have a WHY.
07:38 raydiak was reading advent day 10, says you can now document arguments and attributes too
07:41 raydiak oh right, so the word parameter...was wrong
07:43 raydiak or maybe not, I was thinking of S06 where it says "In Perl 6 culture, we distinguish the terms parameter and argument; a parameter is the formal name that will attach to an incoming argument during the course of execution, while an argument is the actual value that will be bound to the formal parameter."
07:43 skids Right.
07:44 raydiak so an argument would be the value you pass in
07:44 raydiak if I read it right
07:44 skids signatures have parameters, invocations (capture I guess) have arguments
07:44 raydiak we're not talking about putting documentation inside the signature on each parameter?
07:45 skids No, just that To::Text puts newlines in there.  Which I guess makes sense when you have really long signatures but mostly makes a mess visually.
07:45 xfix joined #perl6
07:46 raydiak ah the output from the module...got it
07:47 skids It's kind of something that needs hand editing.  You may not want to doc each multi, for example.  So there will always be chafe between automation and what reads right.  Or layout versus emantic markup for that matter.
07:49 skids e.g. it's easier to say "sub foo($a)/nThis does foobar, $a can be Int|Str" rather than have two WHYs for multi sub foo(Int$a) and multi sub foo(Str $a)
07:49 xfix Isn't Int|Str pretty much Cool type?
07:50 raydiak yeah it'll always just have to make a dumb guess one way or the other
07:50 skids xfix: maybe not the best example.
07:51 xfix (although, I guess that Int|Str only applies to Int, not other numeric types)
07:52 skids So maybe better than everyone writing DOC INIT sections to clean those up an override for user-visible POD signature might be in order.
07:53 skids Or just a way to tell POD not to try to render the attached object, just render the WHY.
07:55 skids Anyway, I'm up way too late.
07:57 raydiak g'night skids
07:57 skids o/
08:08 virtualsue joined #perl6
08:10 xinming joined #perl6
08:16 darutoko joined #perl6
08:31 Timbus so i think i need to split 'bind' and 'listen' apart in moarvm. or perhaps allow a bind address to be passed to listen / connect
08:34 moritz \o
08:35 tinyblak joined #perl6
08:36 makapa joined #perl6
08:36 tinyblak joined #perl6
08:36 avalenn joined #perl6
08:39 makapa left #perl6
08:45 raydiak o/ moritz
08:46 tinyblak_ joined #perl6
08:52 kaare_ joined #perl6
08:59 virtualsue joined #perl6
09:01 denis_boyun_ joined #perl6
09:04 denis_boyun___ joined #perl6
09:10 rindolf joined #perl6
09:12 tinyblak joined #perl6
09:12 gfldex joined #perl6
09:32 raydiak good night #perl6
09:45 tinyblak joined #perl6
09:50 kjs_ joined #perl6
09:58 moritz offline for traveling&
10:11 rurban joined #perl6
10:36 mickcy_ca joined #perl6
10:40 spider-mario joined #perl6
10:46 denis_boyun_ joined #perl6
10:57 mickcy_ca I would like to process a string letter by letter ... How can I do this in Perl 6?
11:02 xfix for $string.comb { }
11:02 xfix mickcy_ca: ^
11:03 mickcy_ca .comb does by letter ... no matter what is processed?
11:03 xfix r: say 'abc'.comb
11:03 camelia rakudo-{parrot,moar} ce1e74: OUTPUT«a b c␤»
11:04 xfix mickcy_ca, well, without arguments, yes.
11:04 mickcy_ca OK ... will try.
11:04 xfix http://doc.perl6.org/type/Str#routine_comb
11:10 kjs_ joined #perl6
11:28 mickcy_ca left #perl6
11:40 tinyblak joined #perl6
12:04 tinyblak joined #perl6
12:06 tinyblak_ joined #perl6
12:11 zakharyas joined #perl6
12:37 mr-foobar joined #perl6
12:53 mvuets joined #perl6
12:56 mvuets hi #perl6
12:57 mvuets can Inf be coerces to Int?
13:03 FROGGS mvuets: Int can't store Inf yet, but it should according to the design docs
13:03 FROGGS Num can though
13:05 mvuets FROGGS: so it's TBI, cool, it answers my question. thanks!
13:06 FROGGS exactly :o)
13:07 FROGGS though, I dunno why we should actually do that, what's the benefit of storing Inf in Int instead of Num?
13:07 colomon just type clarity
13:07 colomon like you'd like to be able to say a sub returns Int but still allow it to return Inf
13:08 colomon there was another proposal that Inf and NaN should be distinct numeric types of their own, which still intrigues me
13:09 mvuets m: for 1 .. Inf { say $_.WHAT; last }
13:09 camelia rakudo-moar ce1e74: OUTPUT«(Int)␤»
13:09 mvuets m: Inf.Int
13:09 camelia rakudo-moar ce1e74: OUTPUT«Unhandled exception: Cannot coerce Inf or NaN to an Int␤   at <unknown>:1  (/home/camelia/rakudo-inst-2/languages/perl6/r​untime/CORE.setting.moarvm:throw:4294967295)␤ from src/gen/m-CORE.setting:13875  (/home/camelia/rakudo-inst​-2/languages/perl6/runti…»
13:10 mvuets kinda DWIM
13:12 mvuets but not when asked explicitly
13:13 mvuets m: my Int $i = Inf # also this; i guess the same issue what colomon said
13:13 camelia rakudo-moar ce1e74: OUTPUT«Type check failed in assignment to '$i'; expected 'Int' but got 'Num'␤  in block <unit> at /tmp/WmwaHFDCDn:1␤␤»
13:22 aborazmeh joined #perl6
13:22 aborazmeh joined #perl6
13:24 tinyblak joined #perl6
13:25 psch joined #perl6
13:25 psch hi #perl6 \o
13:29 dakkar joined #perl6
13:32 tinyblak_ joined #perl6
13:37 tinyblak joined #perl6
13:48 tinyblak_ joined #perl6
13:50 tinyblak_ joined #perl6
13:56 aborazmeh joined #perl6
13:59 tinyblak joined #perl6
14:00 dakkar what emacs mode do people use to edit p6 code?
14:02 BenGoldberg joined #perl6
14:06 psch hm, RoleHOW is gone? did it just get split up into Curried~, Parametric~, etc? advent post 2010-12-22 is rather old...
14:14 hekmek joined #perl6
14:23 kjs_ joined #perl6
14:26 rindolf joined #perl6
14:43 tinyblak joined #perl6
14:54 timotimo could very well be
14:58 psch i'm stuck with how to compose :/
14:58 psch oh, but i think i'm actually approaching this wrong
14:59 psch i already have a HOW for the classes, so i don't need to build a role that does the Proxy
15:02 psch but JavaHOW doesn't do any of the MethodHOWs...
15:05 bjz joined #perl6
15:16 rurban joined #perl6
15:17 ggoebel111111115 joined #perl6
15:25 dakkar grr. calling «sub foo(Str:D :$named)» as «foo()» results in an error… because not passing an argument is the same as passing some undef to it, apparently
15:26 TimToady then give it a default that works
15:27 TimToady or add a multi with :U
15:27 TimToady or just remove the :D
15:27 dakkar I removed the :D
15:27 TimToady :D
15:27 H2O1 joined #perl6
15:28 dakkar I'm porting from P5, where (via Type::Params) I can say "if you give me this parameter, it has to be a defined string"
15:28 H2O1 left #perl6
15:30 TimToady we usually use defaults for that sort of thing, I guess
15:31 spider-mario joined #perl6
15:31 dakkar vaguely related: (in rakudo) when a multi dispatch fails, it would be useful to know why each alternative failed
15:31 dakkar I had to de-multi my sub to figure out what the problem was…
15:31 Rounin joined #perl6
15:32 dakkar (is it obvious that this is the first time I write non-trivial code in p6?)
15:34 psch m: multi foo(Str:D :$n) { $n }; multi foo(Str:U :$n) { "undef" }; say foo :5n
15:34 camelia rakudo-moar ce1e74: OUTPUT«Cannot call 'foo'; none of these signatures match:␤:(Str:D :n($n))␤:(Str:U :n($n))␤  in sub foo at /tmp/LlMQE7Iq5f:1␤  in block <unit> at /tmp/LlMQE7Iq5f:1␤␤»
15:35 psch i suppose adding what the capture contained would be pretty neat
15:35 TimToady usually we split those into one missing the arg and one that requires the arg with !
15:35 psch i.e. "supplied capture of (Int $) doesn't match any of these signatures: {...}" or somewhat like that
15:36 psch TimToady: yeah, the snippet was from testing with camelia if it DWIMs like that, which i wanted to test :)
15:36 psch s/wanted to test/wasn't sure about/
15:39 dakkar psch:  I assure you, printing the capture is not helpful enough
15:40 psch dakkar: what else would have helped?
15:40 dakkar the error message that a non-multi failure prints, instead, contains exactly what I needed ("that parameter was passed a type object, but wanted a defined value")
15:45 psch dakkar: the information which signature wants a type object or a value is in the signatures
15:46 psch dakkar: giving the capture as well would tell whether the method was called with type objects or values
15:46 psch i fail to see how that's not the same information
15:47 psch m: sub test(|c) { say c.perl; say c ~~ :(Int:U) }; test Int; test 5
15:47 camelia rakudo-moar ce1e74: OUTPUT«Capture.new(list => (Int,))␤True␤Capture.new(list => (5,))␤False␤»
15:47 dakkar psch:  sub foo(Str:D :$arg) called as foo(); I didn't know that that was equivalent to calling as foo(Any)
15:47 dakkar hence the capture not having any 'arg' value looked correct to me
15:47 psch oh. i see
15:48 dakkar once I saw the error "arg wanted a defined Str, a type object was passed instead" the problem became obvious
15:48 psch that's because nameds are optional.  making the named required would've shown that as well
15:49 psch but i guess it strongly depends on context whether you want that
15:50 dakkar coming from p5, where named args are in hashes or hashrefs, and "defined" and "exists" are obviously different concepts, "not passing a named" or "passing it with undef as a value" look different to me
15:50 dakkar which is why it took me one hour to see what was going on
15:50 dakkar I got there in the end
15:50 xfix Type objects are undefined values.
15:51 psch m: multi foo (:$!) { say "this cand" }; multi foo () { say "other cand" }; foo # this is WAT :)
15:51 camelia rakudo-moar ce1e74: OUTPUT«this cand␤»
15:51 dakkar I'm not even sure the distinction between "argument not provided" and "argument provided as Any" is useful
15:51 dakkar psch:  ok, that's *weird*
15:52 xfix When most languages have single null, in Perl 6, there are many nulls that are type instance.
15:52 xfix If you define class Something { }, null is Something.
15:52 psch dakkar: MMD does have a few bumps left
15:52 psch err, SD i guess
15:52 psch sub dispatch
15:52 psch or MSD
15:53 psch x)
15:55 psch fwiw, i'd almost say anonymous named params are utterly insane, but i don't know if forbidding them should be the right reaction
15:56 psch m: sub f(:$($a)) { say $a }; f :("a") # too few positional
15:56 camelia rakudo-moar ce1e74: OUTPUT«Too few positionals passed; expected 1 argument but got 0 in sub-signature␤  in sub f at /tmp/iRPMSxhgPe:1␤  in block <unit> at /tmp/iRPMSxhgPe:1␤␤»
15:56 psch "well, make it optional!"
15:56 psch m: sub f(:$($a?)) { say $a }; f :("a") # too few positional
15:56 camelia rakudo-moar ce1e74: OUTPUT«Too many positionals passed; expected 0 arguments but got 1␤  in sub f at /tmp/JRzlvFotua:1␤  in block <unit> at /tmp/JRzlvFotua:1␤␤»
15:57 psch "too many...?"
15:57 psch there's probably a sensible reason for this behavior
15:58 psch i think "subsignatures and anon nameds don't play well together" is a decent start to look into this, although i haven't looked much at dispatch logic
15:58 psch ...and i actually wanted to fiddle around with the JavaHOW prototype
16:01 b2gills m: sub test ( --> Nil ){ Any }; test
16:01 camelia rakudo-moar ce1e74: OUTPUT«Type check failed for return value; expected 'Any' but got 'Any'␤  in any return_error at src/vm/moar/Perl6/Ops.nqp:649␤  in block <unit> at /tmp/NuED6ddbkM:1␤␤»
16:02 b2gills ^ Should have said `expected 'Nil' but got 'Any'`
16:16 xinming joined #perl6
16:53 dakkar «sub foo(Pair @a)»: how do I call this sub? foo([a=>1]) doesn't work
16:53 dakkar (expected Positional[Pair], got Array)
16:54 Ven joined #perl6
16:58 dakkar or, in other words, how do I say "this subroutine wants an array of pairs"?
16:58 Ven o/, #perl6.
16:58 * dakkar temporarily drops the type constraint, adds a comment
17:03 Ven nice, perl6weekly now redirects :P
17:05 xfix In theory List[Pair], but...
17:05 xfix Array*
17:05 xfix Type check failed in binding $a; expected 'Array[Pair]' but got 'Array'
17:06 xfix Array of Pair works, but the is no implicit cast from Array.
17:13 timotimo correct
17:13 timotimo you have to be specific
17:14 timotimo i mean, in declaring the array up front
17:15 Ven ... which is arguably something that should be fixed at some point in the future :)
17:15 timotimo because if you don't put a declaration "up front", you could append non-matching elements into the array, even from the outside after you've "type casted"
17:16 timotimo otherwise passing arrays by reference becomes impossible
17:26 telex joined #perl6
17:30 dakkar timotimo:  sorry, I don't follow…
17:30 timotimo imagine this:
17:31 timotimo sub frob(Array[Int] $a) { say $a; blubber; say $a }; my @foo = 1, 2, 3; frob(@foo); sub blubber { @foo.push: "ohai" }
17:32 Ven timotimo: what should happen is that – the type "outside" should be inferred to be Array[Int]
17:32 BenGoldberg joined #perl6
17:32 timotimo it should?
17:32 timotimo my @foobar = 1, 2, 3; @foobar.push: "hi" # so this will be incorrect?
17:33 dakkar timotimo:  ok, I see, passing by ref becomes a mess if you have to propagate type constraints all over the place
17:33 timotimo that's not the problem
17:33 dakkar so, how do I insure that my sub can only be called with an array of pairs?
17:33 timotimo if you pass an Array[Int] explicitly, no problem
17:33 Ven timotimo: if I try to use a List[?] as a List[Int], yes, i think it should be inferred to be a List[Int]
17:34 timotimo Ven: so how should my code behave
17:34 Ven timotimo: it should fail
17:34 timotimo the one that passes @foo to frob and pushes a string from inside frob
17:35 Ven timotimo: my @a = 1, 2; sub f(Array[Int] $a) {}; f(@a); # <- this marks the type of @a to be Array[Int]
17:36 Ven languages like scala will just infer the first time you declare it. ie: List(1, 2) will be inferred as List[Int]
17:36 Ven List(1, 2.0) wil l be List[Double]
17:36 Ven and List(1, "foo") will be List[Any]
17:36 timotimo why not List[Cool]?
17:37 Ven timotimo: which part? the sub? Because the subs needs it to be a list[Int]
17:38 Ven timotimo: really, you can go both ways. Either force you to explicitly declare it as the correct type everytime or infer it
17:38 Ven timotimo: but if you force it to be explicit, it's going to be really painful to return typed lists
17:39 skids You could use a type constraint for loose evaluation at the start of a function.  Just be real careful with async.
17:39 dakkar skids: ?
17:39 Ven (scala uses insanity in this case, as in – CanBuildFrom)
17:40 * dakkar is feeling very confused
17:40 dakkar I'm even getting confused by try blocks!
17:40 skids e.g. :@foo where { # check for all pairs }
17:40 dakkar skids: oh :/ also, why async?
17:40 Ven dakkar: two functions modifying the same array at the same time
17:40 skids Well, if anotherthread can alter your params while your sub is running.
17:41 skids I guess that's a more general async problem, though.
17:41 dakkar ah, of course, pass-by-ref, not copy
17:41 Ven I can't panda-install v5, apparently
17:43 Ven also, getting a "Unhandled exception: ctxlexpad needs an MVMContext" when trying to run the debugger
17:43 Ven (my rakudo is from yesterday)
17:43 timotimo right; the call to frob that requires @foo to be of Array[Int] would have to force @foo itself to get a different type constraint in its container
17:43 dakkar uh… what's the return value of a try block??
17:43 timotimo not sure if want
17:44 Ven m: say do try { 5 }; # dakkar
17:44 camelia rakudo-moar ce1e74: OUTPUT«5␤»
17:44 dakkar m: say do try { 5; CATCH { 0 } }
17:44 camelia rakudo-moar ce1e74: OUTPUT«Nil␤»
17:44 dakkar surprise!
17:44 dakkar m: say do try { die; CATCH { 0 } }
17:44 camelia rakudo-moar ce1e74: OUTPUT«Died␤  in block <unit> at /tmp/kIn0_vt26G:1␤␤»
17:44 dakkar also, wtf?
17:44 Ven you're not catching anything here.
17:45 timotimo dakkar: should be the last statement
17:45 Ven if you put a CATCH block, you need to catch stuff
17:45 dakkar m: say do try { die; CATCH { default { } }
17:45 camelia rakudo-moar ce1e74: OUTPUT«[31m===[0mSORRY![31m===[0m Error while compiling /tmp/1gdcC1c1yu�Unable to parse expression in block; couldn't find final '}' �at /tmp/1gdcC1c1yu:1�------> [32msay do try { die; CATCH { default { } }[33m�[31m<EOL>[0m�»
17:45 dakkar m: say do try { die; CATCH { default { 0 } } }
17:45 camelia rakudo-moar ce1e74: OUTPUT«Nil␤»
17:45 dakkar stil…
17:45 timotimo the return value of a CATCH block may be undefined
17:45 timotimo consider my $foo = CATCH { ... }
17:45 timotimo but i'm not sure
17:45 timotimo also, i'm quite tired and distracted
17:45 timotimo bbl :)
17:46 dakkar I was hoping to get the same behaviour as p5's Try::Tiny, but clearly p6 has different ideas :)
17:48 timotimo the CATCH block doesn't need to be in the last position in the block
17:49 dakkar true, but:
17:49 dakkar - depending on its position to get the correct result is fragile
17:50 dakkar - I can't get at the result of the CATCH anyway
17:50 timotimo its position inside a block doesn't matter
17:50 timotimo at least not to my knowledge
17:50 timotimo it gets called "as a PHASER" so to speak anyway
17:51 japhb Nativecall is failing tests on r-m: t/06-struct.t .......... Failed 14/19 subtests
17:51 dakkar m: say do try { 5; CATCH { 0 } }
17:51 camelia rakudo-moar ce1e74: OUTPUT«Nil␤»
17:51 japhb Is this known?
17:51 dakkar m: say do try { CATCH { 0 }; 5 }
17:51 camelia rakudo-moar ce1e74: OUTPUT«5␤»
17:51 dakkar the position of the CATCH *does* matter
17:51 timotimo in that sense, yes
17:51 timotimo but only for the "last statement in the block" thing
17:52 dakkar eh. so I can't use a p6 try block the same way as I would use a p5 Try::Tiny try/catch "block"
17:52 sirdancealot joined #perl6
17:54 * timotimo has no clue of perl5
17:54 dakkar fair enough :)
17:54 dakkar «my $x = try { 5 } catch { 0 };» would set $x to 5;
17:54 dakkar «my $x = try { die } catch { 0 };» would set $x to 0;
17:55 timotimo for something like that, i'd recommend "orelse"
17:55 timotimo m: say (die "oh no!" orelse 5);
17:55 camelia rakudo-moar ce1e74: OUTPUT«oh no!␤  in block <unit> at /tmp/p_hBLcPN98:1␤␤»
17:55 timotimo oh
17:55 timotimo m: say ((die "oh no!") orelse 5);
17:55 camelia rakudo-moar ce1e74: OUTPUT«oh no!␤  in block <unit> at /tmp/De31Rrn0jD:1␤␤»
17:55 timotimo that's obviously wrong
17:55 timotimo m: say ((try die "oh no!") orelse 5);
17:55 camelia rakudo-moar ce1e74: OUTPUT«5␤»
17:55 japhb timotimo: orelse is for fail, not die, no?
17:55 timotimo m: say ((try die "oh no!") // 5);
17:55 camelia rakudo-moar ce1e74: OUTPUT«5␤»
17:56 dakkar *almost* correct
17:56 timotimo you are right, ja
17:56 timotimo
17:56 timotimo japhb
17:56 japhb It worked both ways.  :-)
17:56 timotimo m: say (try die "oh no!" orelse 5);
17:56 camelia rakudo-moar ce1e74: OUTPUT«Nil␤»
17:56 dakkar unless my function can return a fail, or an undef…
17:56 timotimo that has different precedence
17:56 timotimo you usually want orelse between statements
17:56 dakkar anyway, I have now ported my partial p5 port of a js library to p6
17:56 timotimo er ... or something
17:56 timotimo gotta go find food :)
17:57 moritz \o
17:57 dakkar good plan!
17:57 japhb dakkar: Are you actually wanting to differentiate a block returning Failure and Exception and respond with fundamentally different actions?
17:57 japhb s/and/versus/
17:58 dakkar I don't know, it might make sense in some weird cases
17:59 japhb My gut reaction is that such a specialized differentiation deserves to be de-huffmanized.
18:00 japhb .oO( Man it feels good to be talking Perl 6 again.  Visitors are great, but boy do they get in the way of hacking. )
18:05 timotimo dakkar: i think orelse is exactly what you want to replace "catch" with
18:05 timotimo literally
18:06 dakkar so «$x = try { some_function_that_may_die() } orelse some_fallback_function()»
18:06 timotimo i think so, yes
18:07 timotimo in that case, // may also work just fine
18:07 dakkar https://github.com/dakkar/Net-Hawk ← the stuff I'm writing
18:11 dakkar I was going to write it in p5, but then I noticed that Digest::SHA and Digest::HMAC exist in p6 already, and I wanted to write something non-trivial in p6, so…
18:11 dakkar I should ask for a code review :)
18:15 dakkar I'll retire (from IRC) for the day, expect more perplexity (and perplexing code) in the coming days
18:15 skids r: role A [ :$a = 1, :$b = $a * 2] { method foo { say "$a $b" } }; role B does A[:a(1)] { }; role C does A[:a(2)] { }; B.new.foo; C.new.foo;
18:15 camelia rakudo-parrot ce1e74: OUTPUT«1 2␤2 4␤»
18:15 camelia ..rakudo-moar ce1e74: OUTPUT«1 2␤2 2␤»
18:15 skids r-p++
18:29 zby_home joined #perl6
18:39 b2gills Ven: The problem with v5 is `@*MODULES[-1]` should be written as `@*MODULES[*-1]` at https://github.com/rakudo-p5/v5/blob/​master/src/Perl5/ModuleLoader.pm#L87
18:39 denis_boyun_ joined #perl6
18:39 Ven ys
18:39 Ven good catch
18:44 virtualsue joined #perl6
18:50 * skids filed RT123511 for above role stuff.
18:53 sqirrel_ joined #perl6
18:54 b2gills m: my \b = *-*; my &b = *+*; my $b = * * *; say (b.(3,2), b(3,2), $b(3,2), $b.(3,2));
18:54 camelia rakudo-moar ce1e74: OUTPUT«1 5 6 6␤»
18:56 b2gills Unsigiled vars are more unique among other vars than their name would suggest
19:19 sergot hi o/
19:21 Ven joined #perl6
19:22 mvuets joined #perl6
19:24 japhb m: my \b = *-*; my &b = *+*; my $b = * * *; say (b.(3,2), b(3,2), &b(3,2), &b.(3,2), $b(3,2), $b.(3,2));
19:24 camelia rakudo-moar ce1e74: OUTPUT«1 5 5 5 6 6␤»
19:24 japhb b2gills: That's because the second form there is sugar for the third.
19:25 japhb (Not because unsigaled vars are special, but because sub call syntax is special.)
19:25 japhb *unsigiled
19:42 kaare_ joined #perl6
19:51 moritz m: my Int a
19:51 camelia rakudo-moar ce1e74: OUTPUT«[31m===[0mSORRY![31m===[0m�Type 'Int' is not declared. Did you mean 'int'?�at /tmp/2bS0K2J7Q8:1�------> [32mmy Int [33m�[31ma[0m�Malformed my�at /tmp/2bS0K2J7Q8:1�------> [32mmy Int [33m�[31ma[0m��»
19:51 moritz wtf? type Int is declared!
19:53 pmichaud good afternoon, #perl6
19:53 dalek doc: 26d8fec | moritz++ | lib/Type/X/Syntax/Malformed.pod:
19:53 dalek doc: document X::Syntax::Malformed
19:53 dalek doc: review: https://github.com/perl6/doc/commit/26d8fec31d
19:53 psch m: my Int a;
19:53 camelia rakudo-moar ce1e74: OUTPUT«[31m===[0mSORRY![31m===[0m Error while compiling /tmp/hip86ikiUM�Malformed my (did you mean to declare a sigilless \a or $a?)�at /tmp/hip86ikiUM:1�------> [32mmy Int a[33m�[31m;[0m�»
19:53 moritz good pm, pm
19:53 psch moritz: there's a ticket for that
19:54 moritz psch: good, then I don't have to open one
19:54 psch i looked at it a few hours ago, but i lost it
19:54 kjs_ moritz: ping
19:54 psch o/ pmichaud
19:54 moritz it's probably backtracking somewhere where it shouldn't
19:54 moritz kjs_: pong
19:54 kjs_ moritz: I’ve tried to send you an email, but it kept bouncing
19:55 moritz kjs_: use moritz.lenz@gmail.com instead
19:55 kjs_ okay.
19:55 moritz kjs_: sorry for the inconvenience
19:55 kjs_ no bother.
19:55 psch RT #120831 for reference
19:55 synopsebot Link: https://rt.perl.org/rt3//Publ​ic/Bug/Display.html?id=120831
19:55 pmichaud So, I'm unfamiliar with how perl6-community-modules works.  How do I submit an issue ticket for URI::Escape?
19:56 moritz psch++
19:56 pmichaud should it go back to colomon's original repo, or is p6-c-m now its official home?
19:56 nwc10 good UGT heresey, pmichaud
19:56 nwc10 (andIhave no idea about your question)
19:56 * pmichaud <-- heretic, no doubt
19:56 timotimo ohai mister michaud :)
19:56 colomon p6-c-m is now its official home
19:57 pmichaud oh, wait, now I see the issues link
19:57 moritz pmichaud: https://github.com/perl6-co​mmunity-modules/uri/issues
19:57 pmichaud I didn't see it earlier.
19:57 moritz pmichaud: I just enabled issues for that repo
19:57 moritz pmichaud: it seems that github disables issues for cloned repos by default
19:57 pmichaud moritz++
19:57 colomon and I did not originally write it, I just forked it because the original author seemed to have abadoned it.
19:57 colomon moritz++
19:58 moritz I guess I should go through the list of modules and enable issues for them all
20:05 xfix m: promptt
20:05 camelia rakudo-moar ce1e74: OUTPUT«[31m===[0mSORRY![31m===[0m Error while compiling /tmp/raoGEDZ5Qjâ�¤Undeclared routine:â�¤    promptt used at line 1. Did you mean 'prompt'?â�¤â�¤Â»
20:05 xfix p: promptt
20:05 camelia rakudo-parrot ce1e74: OUTPUT«===SORRY!===␤no ICU lib loaded␤»
20:05 xfix Hm...
20:05 colomon moritz++ # again
20:05 xfix p: prampt
20:05 camelia rakudo-parrot ce1e74: OUTPUT«[31m===[0mSORRY![31m===[0m Error while compiling /tmp/2aiGezg06Râ�¤Undeclared routine:â�¤    prampt used at line 1. Did you mean 'prompt'?â�¤â�¤Â»
20:05 xfix Any idea why promptt requires ICU, but prampt doesn't?
20:06 moritz xfix: no; but Perl 6 without Unicode support makes no sense whatsoever, so the question is kinda moot
20:07 xfix moritz, also, camelia should have Parrot Rakudo compiled with ICU.
20:07 moritz xfix: +1
20:07 moritz and rakudo should refuse to configure without ICU
20:09 xfix I agree. Perl 6 without Unicode support isn't Perl 6.
20:09 xfix https://github.com/rakudo/rakudo/bl​ob/29757fe46efb679da7037be93b9e6066​032abb7a/docs/announce/2014.10.md
20:09 xfix "This is last release of Rakudo to support parrot without ICU."
20:09 moritz seems time to make that threat come true
20:13 hoelzro o/ #perl6
20:13 dalek rakudo/nom: 7fca945 | moritz++ | Configure.pl:
20:13 dalek rakudo/nom: Require ICU support on the Parrot backend
20:13 dalek rakudo/nom:
20:13 dalek rakudo/nom: ... as announced in the 2014.10 release announcement.
20:13 dalek rakudo/nom: review: https://github.com/rakudo/rakudo/commit/7fca945678
20:13 pmichaud I do so like GitHub's issue trackers.  :)
20:13 pmichaud https://github.com/perl6-com​munity-modules/uri/issues/1
20:13 timotimo yeah, it's not bad
20:14 pmichaud I'd submit a fix and pull request, but I don't have panda etc installed on my machine at the moment
20:14 pmichaud and I'm not keen on submitting untested patches :)
20:14 moritz pmichaud: I'll give it a shot right now
20:15 zakharyas joined #perl6
20:16 pmichaud out of curiosity, do we want to require "icu support" or do we just want to test that the required Unicode operations are available?
20:16 moritz https://github.com/perl6-community-modul​es/uri/blob/master/lib/URI/Escape.pm#L11
20:16 moritz pmichaud: well, testing capabilities would be nicer, but also much more work
20:17 pmichaud I'm fine with testing for "icu support" for now.
20:17 pmichaud I agree it's probably not worth pumping a lot of time / energy into it.
20:18 colomon pmichaud++
20:20 hoelzro I found some interesting behavior when mixing sockets and threads: https://gist.github.com/ho​elzro/d7d7b8056016292639ef
20:20 hoelzro in short, I can't read from a socket if that socket was created in a thread other than the one I'm reading in
20:20 hoelzro I'm wondering if MoarVM has some sort of guard on its socket objects so that you have to use them from their creating thread
20:23 FROGGS joined #perl6
20:30 Ven joined #perl6
20:35 moritz hoelzro: if that's the case, it should certainly throw an exception, not simply return the empty string
20:37 sivoais joined #perl6
20:42 Rounin joined #perl6
20:52 hoelzro agreed
20:53 hoelzro I'm testing it on all backends, and will file a bug
20:57 Sqirrel joined #perl6
21:06 Mso150 joined #perl6
21:11 bjz_ joined #perl6
21:32 Ven joined #perl6
21:34 b2gills m: say (3 div 2, -3 div 2); # is div always supposed to round down?
21:34 camelia rakudo-moar ce1e74: OUTPUT«1 -2␤»
21:34 makapa joined #perl6
21:36 timotimo towards -inf, iirc
21:36 xfix It's floor division, not integer division.
21:37 xfix m: say -22 div 10
21:37 camelia rakudo-moar ce1e74: OUTPUT«-3␤»
21:38 xfix Anyway, the reason is that we want, i = (i div j) * j + (i mod j).
21:38 xfix m: say -190 mod 12
21:38 camelia rakudo-moar ce1e74: OUTPUT«2␤»
21:38 xfix We show 2 here, not -10, therefore division has to return -3.
21:39 xfix (the reason why we show 2 here is that it's generally more useful, for example, if you have a clock showing 10:00, and you are curious what it showed 200 hours ago, you want -190 % 12 == 2, not -190 % 12 == -10)
21:39 xfix s/We show/Perl 6 shows/
21:40 xfix s/that we want/that you probably want/
21:40 * psch is reminded of the discussion that brang forth "abstruncate"
21:45 hoelzro ok, bug filed: https://github.com/MoarVM/MoarVM/issues/165
21:50 b2gills I just wonder if there is a way to write Perl6 code which can be JITed to the DIV x86 instruction (which returns the whole number and the remainder) in a way that you don't have to call it twice if you want both
22:00 b2gills sub as-fraction ( Rational:D $ ( :$numerator, :$denominator ) --> Str ){ Int($numerator / $denominator) ~ ' + ' ~ abs($numerator) mod $denominator ~ '/' ~ $denominator }
22:09 jnthn evening, #perl6
22:09 yoleaux 27 Dec 2014 20:04Z <FROGGS> jnthn: can you please take a look at that gist? line 28 triggers the shows error (I want to make `do while` work): https://gist.github.com/FR​OGGS/98e1a97434c3753dc081
22:09 yoleaux 27 Dec 2014 21:14Z <lizmat> jnthn: I don't see how those methods could not be public, unless you want to go all getattr ?
22:11 jnthn .tell FROGGS doing that at QAST level is absolutely wrong, I think. It will pessimize every loop that doesn't care for the rsults, and worse it'd be useless for Perl 6 which needs lazy execution. This ties into GLR's proposed LoopIter, and I think we likely want to leave it for that.
22:11 yoleaux jnthn: I'll pass your message to FROGGS.
22:12 jnthn b2gills: That sounds in the realm of something a VM with an optimizing JIT could do.
22:13 jnthn (Spot the fact we need both results, and do one operation to get them.)
22:14 b2gills Yeah but would the sub I just posted get JITed in that way
22:16 b2gills I would think it would be more likely to do so if I could write it in a way that it rounds towards 0 instead of -Inf since it works on unsigned ints ( at least according to the docs I printed in the 90s )
22:18 jnthn b2gills: Not with Int, I doubt, because that defaults to big integer semantics.
22:19 jnthn You'd have to be dealing with native integers.
22:27 b2gills Couldn't Rat be Rational[int,uint64], then it would be working with natives if you create a multi that deals only with Rat ( or the VM creates one that's possibly hidden from introspection )
22:30 jnthn I find it highly unlikely we'd make the default Rat type not have Int as its numerator.
22:30 jnthn Other instantiations should be possible with natives, though.
22:31 jnthn (Won't work out today, but should in the future.)
22:33 Ven jnthn: can you confirm that the debugger is broken, or does it happen to be me?
22:34 jnthn Ven: I've no clue.
22:34 Ven fair enough.
22:34 jnthn I'm on vacaitn, and not really interested in fixing things.
22:34 jnthn *vacation
22:34 jnthn Will have a look some other time.
22:35 Ven sorry! :)
22:35 jnthn np :)
22:35 Ven hope you have great holidays, and will be back with some awesome pictures.
22:36 jnthn Well, this is more "relax with family and catch up on a huge sleep deficit" :)
22:36 jnthn (Doing OK on both. :))
22:36 jnthn Just dropping by here now and then in case I can quickly answer things that unblock others while I'm getting some rest
22:37 rurban joined #perl6
22:46 japhb jnthn: Did you see my question about NativeCall failing tests on r-m?
22:46 jnthn japhb: Yes, only thing I could guess is version skew if you're not building master of All The Things.
22:47 jnthn japhb: That and I think there are still lingering 32-bit issues.
22:48 japhb I was building on 64-bit, and I usually build with versions at 'whatever rakudo's configure wants'
22:49 japhb So perhaps nqp and rakudo need a moar bump
22:49 jnthn Maybe, but I thought that happened since the last round of NativeCall changes.
22:49 jnthn 'cus it was quite a while ago
22:49 jnthn (Like, well over a week)
22:49 * japhb shrugs
22:50 japhb Build completed at 9:36 this morning my time
22:50 jnthn If it ain't either of those, no idea.
22:50 * japhb shakes his fist at errors
22:52 * jnthn wanders off to sleep some more
22:53 japhb Good sleeps
23:41 aborazmeh joined #perl6
23:42 skids r: my $i = 0; <package module class role>.map: {$i++; EVAL "$_ Foo{$i}" ~ q« { our sub foo { }}; say keys » ~ "Foo$i" ~ "::"}
23:42 camelia rakudo-{parrot,moar} ce1e74: OUTPUT«&foo␤&foo␤&foo␤␤»
23:51 sirdancealot joined #perl6

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

Perl 6 | Reference Documentation | Rakudo