Perl 6 - the future is here, just unevenly distributed

IRC log for #perl6, 2017-03-08

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:13 Cabanossi joined #perl6
00:20 BenGoldberg s: (use NativeCall, CArray[Str]), "Array", \();
00:20 SourceBaby BenGoldberg, Ehhh... I'm too scared to run that code.
00:20 BenGoldberg s: (use NativeCall, CArray[Str]), "Array", \()
00:20 SourceBaby BenGoldberg, Something's wrong: ␤ERR: ===SORRY!=== Error while compiling -e␤Confused␤at -e:6␤------>     put sourcery( (use NativeCall<HERE>, CArray[Str]), "Array", \() )[1];␤
00:20 BenGoldberg s: (use NativeCall, CArray[Str]), "Array"
00:20 SourceBaby BenGoldberg, Something's wrong: ␤ERR: ===SORRY!=== Error while compiling -e␤Confused␤at -e:6␤------>     put sourcery( (use NativeCall<HERE>, CArray[Str]), "Array" )[1];␤
00:20 BenGoldberg s: (use NativeCall, CArray), "Array"
00:20 SourceBaby BenGoldberg, Something's wrong: ␤ERR: ===SORRY!=== Error while compiling -e␤Confused␤at -e:6␤------>     put sourcery( (use NativeCall<HERE>, CArray), "Array" )[1];␤
00:20 BenGoldberg s: (use NativeCall, CArray)[1], "Array"
00:20 SourceBaby BenGoldberg, Something's wrong: ␤ERR: ===SORRY!=== Error while compiling -e␤Confused␤at -e:6␤------>     put sourcery( (use NativeCall<HERE>, CArray)[1], "Array" )[1];␤
00:20 BenGoldberg s: ((use NativeCall), CArray)[1], "Array"
00:20 SourceBaby BenGoldberg, Something's wrong: ␤ERR: Type check failed in binding to '&code'; expected Callable but got Method+{<anon|72771952>} (Method+{<anon|7277195...)␤  in sub do-sourcery at /home/zoffix/services/lib/CoreHackers-Sourcery/lib/CoreHackers/Sourcery.pm6 (CoreHackers::Sourcery) line 42␤  in sub sourcery at /home/zoffix/services/lib/CoreHackers-Sourcery/lib/CoreHackers/Sourcery.pm6 (CoreHackers::Sourcery) line 33␤  in block <unit> at
00:21 BenGoldberg s: ((use NativeCall), CArray[Str])[1], "Array", ()
00:21 SourceBaby BenGoldberg, Something's wrong: ␤ERR: Cannot resolve caller sourcery(NativeCall::Types::CArray[Str], Str, List); none of these signatures match:␤    ($thing, Str:D $method, Capture $c)␤    ($thing, Str:D $method)␤    (&code)␤    (&code, Capture $c)␤  in block <unit> at -e line 6␤␤
00:21 BenGoldberg s: ((use NativeCall), CArray[Str])[1], "Array", \()
00:21 SourceBaby BenGoldberg, Sauce is at https://github.com/rakudo/rakudo/blob/e2db7b8/src/core/Any.pm#L67
00:22 BenGoldberg huh.
00:22 BenGoldberg huggable, pull
00:22 huggable BenGoldberg, nothing found
00:22 BenGoldberg huggable, pullrequest
00:22 huggable BenGoldberg, nothing found
00:22 BenGoldberg huggable, pull request
00:22 huggable BenGoldberg, nothing found
00:22 timotimo huggable: source
00:22 huggable timotimo, See https://github.com/zoffixznet/huggable
00:23 mcmillhj joined #perl6
00:23 timotimo BenGoldberg: ^
00:23 BenGoldberg I know Huggable's just an info bot...
00:23 BenGoldberg I was hoping someone had told him about how someone would make a request
00:24 timotimo SourceBaby: source
00:24 SourceBaby timotimo, See: https://github.com/zoffixznet/perl6-sourceable
00:25 BenGoldberg SourceBaby's not wrong about where .Array is defined, I was really just hoping CArray had it's own definition :P
00:25 * BenGoldberg would like to do my CArray[Str] $foo = something_from_some_native_api(); my Str @bar = $foo.Array(:NULL-terminated);
00:28 SmokeMachine could, please, someone give a opinion? I am writing a dependency injector... https://github.com/FCO/Injector
00:28 BenGoldberg s: ((use NativeCall), CArray[Str])[1], "new", \()
00:28 SourceBaby BenGoldberg, Sauce is at https://github.com/rakudo/rakudo/blob/e2db7b8/ces/51E302443A2C8FF185ABC10CA1E5520EFEE885A1 (NativeCall::Types)#L173
00:28 mcmillhj joined #perl6
00:28 SmokeMachine Id like to know if its something usable...
00:28 zakharyas joined #perl6
00:28 SmokeMachine example https://www.irccloud.com/pastebin/CwftCbgi/
00:34 travis-ci joined #perl6
00:34 travis-ci Doc build errored. Brian Duggan 'nbsp in Perl 6'
00:34 travis-ci https://travis-ci.org/perl6/doc/builds/208703272 https://github.com/perl6/doc/compare/180e6c8ba0bc^...11d359d43389
00:34 travis-ci left #perl6
00:39 bjz joined #perl6
00:42 ZzZombo joined #perl6
00:43 ZzZombo joined #perl6
00:47 aborazmeh joined #perl6
00:47 aborazmeh joined #perl6
00:47 SmokeMachine Anyone?
00:49 BenGoldberg SmokeMachine, The real question is, would *you* use it?
00:50 BenGoldberg And, I should add, would you enjoy using it ;) cause code which is painful is painful.
00:51 SmokeMachine BenGoldberg: I think I would... I just didn't need that yet... but I already needed stuff like that in other languages...
00:52 SmokeMachine BenGoldberg: I really liked the way you use it... what did you think?
00:52 * BenGoldberg shrugs.
00:53 BenGoldberg Programming is kindof a hobby for me -- a fun hobby, but I don't do it full time.
00:53 MilkmanDan joined #perl6
00:57 Cabanossi joined #perl6
01:00 IOninja SmokeMachine: I don't get what the point is.
01:01 IOninja Well, other than job-security-by-making-your-code-unmaintainable.
01:01 mcmillhj joined #perl6
01:03 kyan joined #perl6
01:10 * IOninja is a bundle of joy for everyone asking for code opinions o/
01:11 IOninja You have a typo in method name: instanciate should be instantiate
01:16 SmokeMachine IOninja: thanks
01:17 SmokeMachine IOninja: why do you think it makes the code unmantainable?
01:18 user___ joined #perl6
01:18 user___ hi
01:22 IOninja SmokeMachine: because after staring it for over a minute, I'm still not 100% sure wtf it's doing. :)
01:22 IOninja user___: \0
01:23 mcmillhj joined #perl6
01:23 IOninja SmokeMachine: like the bind thing... it affects everything that has `is injected`? That's massive action at a distance that will prove a nightmare to hunt down a bug in :/
01:24 IOninja And I don't really get why havea separate bind thing instead of instantiating a class the way god that doesn't exist intended to?
01:26 user___ could i get some code examples for concurrency
01:26 ugexe lol
01:26 IOninja user___: sure. Anything specific?
01:26 IOninja user___: there's a bunch on : https://docs.perl6.org/language/concurrency
01:27 user___ nothing specific.am just a beginner
01:27 IOninja m: sleep 1 for ^4 .race: :batch; say now - INIT now; # 4 x 1 second sleeps; complete in 1 second.
01:27 camelia rakudo-moar e2db7b: OUTPUT: «1.0057828␤»
01:27 user___ i looked through the documentation.could i get any concrete examples
01:28 IOninja user___: another decent things are this lighting talk: https://perl6.party/post/Perl-6-What-Programming-In-The-Future-Is-Like
01:28 IOninja user___: this too: https://perl6.party/post/IRC-Client-Perl-6-Multi-Server-IRC-Module
01:28 user___ Thanks much
01:29 IOninja This harness is all concurrent, if you don't mind wading through classes and grammar: https://github.com/rakudo/rakudo/blob/nom/lib/TAP.pm6
01:30 mcmillhj joined #perl6
01:39 SmokeMachine IOninja: that makes it easy to change for tests, for example...
01:40 IOninja fair enough
01:42 skids joined #perl6
01:45 IOninja FWIW we also have http://examples.perl6.org/ never looked at it and unsure if it got any concurrency examples (that aren't bitrotten), but... there you go.
01:49 kyan joined #perl6
01:54 mr-foobar joined #perl6
02:01 SmokeMachine IOninja: I think the best way to explain whats my goal with the Injector is this: https://en.wikipedia.org/wiki/Dependency_injection
02:07 travis-ci joined #perl6
02:07 travis-ci Doc build errored. Zoffix Znet 'Revert "Make xt/space-after-commma.t report line numbers for failures"
02:07 travis-ci https://travis-ci.org/perl6/doc/builds/208704152 https://github.com/perl6/doc/compare/6434cce19d5c...2715812df4ac
02:07 travis-ci left #perl6
02:13 Cabanossi joined #perl6
02:48 ilbot3 joined #perl6
02:48 Topic for #perl6 is now »ö« Welcome to Perl 6! | https://perl6.org/ | evalbot usage: 'p6: say 3;' or rakudo:,  or /msg camelia p6: ... | irclog: http://irc.perl6.org or http://colabti.org/irclogger/irclogger_logs/perl6 | UTF-8 is our friend!
02:50 travis-ci joined #perl6
02:50 travis-ci Doc build errored. Brian Duggan 'Spacing, Perl 6 vs Perl 6 (nbsp)'
02:50 travis-ci https://travis-ci.org/perl6/doc/builds/208707448 https://github.com/perl6/doc/compare/11d359d43389...379e364dfdc0
02:50 travis-ci left #perl6
03:12 mr-foobar joined #perl6
03:12 noganex_ joined #perl6
03:18 BenGoldberg m: log( Numeric.new xx 2 );
03:18 camelia rakudo-moar 5b6e0f: OUTPUT: «WARNINGS for <tmp>:␤Useless use of "log( Numeric.new xx 2 )" in expression "log( Numeric.new xx 2 )" in sink context (line 1)␤»
03:18 BenGoldberg m: log( Numeric.new xx 2 ).say;
03:18 camelia rakudo-moar 5b6e0f: OUTPUT: «0.693147180559945␤»
03:18 BenGoldberg m: log( Numeric.new, Numeric.new ).say;
03:18 camelia rakudo-moar 5b6e0f: OUTPUT: «Cannot resolve caller log(Numeric: ); none of these signatures match:␤    (Numeric:D $: Cool $base, *%_)␤    (Numeric:D $: Numeric $base, *%_)␤  in block <unit> at <tmp> line 1␤␤»
03:23 xtreak joined #perl6
03:32 bjz joined #perl6
03:37 SmokeMachine IOninja: a little more complete example: https://github.com/FCO/Injector/tree/master/examples
03:43 sammers Hi #perl6
03:44 SmokeMachine BenGoldberg: a little more complete example: https://github.com/FCO/Injector/tree/master/examples
03:46 drrho joined #perl6
03:49 sammers is there any way to iterate all params passed to a sub? e.g. sub foo(:$n1, $n2) { params.map: ... } ?
03:52 SmokeMachine m: sub bla($a, :$b) {}; say&bla.signature.params
03:52 camelia rakudo-moar 5b6e0f: OUTPUT: «5===SORRY!5=== Error while compiling <tmp>␤A list operator such as "say" must have whitespace before its arguments (or use parens)␤at <tmp>:1␤------> 3sub bla($a, :$b) {}; say7⏏5&bla.signature.params␤    expecting any of:␤        argu…»
03:52 bjz joined #perl6
03:52 SmokeMachine m: sub bla($a, :$b) {}; say &bla.signature.params
03:52 camelia rakudo-moar 5b6e0f: OUTPUT: «($a :$b)␤»
03:53 SmokeMachine m: sub bla($a, :$b) {}; .say for &bla.signature.params
03:53 camelia rakudo-moar 5b6e0f: OUTPUT: «$a␤:$b␤»
03:54 SmokeMachine sammers: ????
03:56 naxieAlDle m: sub foo(*@all ($a, $b, $c)) { say $a; say $b; say $c; dd @all }; foo 42, 43, 44
03:56 camelia rakudo-moar 5b6e0f: OUTPUT: «42␤43␤44␤[42, 43, 44]␤»
03:56 naxieAlDle sammers: what about this? ↑
03:57 sammers hmm, I am trying to iterate on all passed named params from inside the sub. I could use a capture, but I want to put type constraints on the named params.
03:57 labster joined #perl6
03:57 Cabanossi joined #perl6
03:58 naxieAlDle m: sub foo(*%all) { dd %all }; foo a => 44, b => 45
03:58 camelia rakudo-moar 5b6e0f: OUTPUT: «{:a(44), :b(45)}␤»
03:58 naxieAlDle ?
03:58 naxieAlDle ah
03:58 naxieAlDle m: sub foo(*%all (:$a, :$b)) { dd %all }; foo a => 42, b => 44
03:58 camelia rakudo-moar 5b6e0f: OUTPUT: «{:a(42), :b(44)}␤»
03:58 sammers m: sub bla($a, :$b) { say &?BLOCK.signature.params }; bla(123, b => "I am b");
03:58 camelia rakudo-moar 5b6e0f: OUTPUT: «($a :$b)␤»
03:59 sammers I guess I can use &?BLOCK
03:59 wamba joined #perl6
03:59 naxieAlDle sammers: so what's wrong with my last solution?
04:01 sammers m: sub foo(*%all (Int :$a, Str :$b)) { dd %all }; foo a => 42, b => 'string'
04:01 camelia rakudo-moar 5b6e0f: OUTPUT: «{:a(42), :b("string")}␤»
04:01 sammers m: sub foo(*%all (Int :$a, Str :$b)) { dd %all }; foo a => 42, b => 123
04:01 camelia rakudo-moar 5b6e0f: OUTPUT: «Type check failed in binding to '$b'; expected Str but got Int (123)␤  in sub foo at <tmp> line 1␤  in block <unit> at <tmp> line 1␤␤»
04:01 sammers yeah, that should work
04:04 sammers naxieAlDle, that solution is just what I was looking for. thanks.
04:06 travis-ci joined #perl6
04:06 travis-ci Doc build errored. Brian Duggan 'added back lexicographically
04:06 travis-ci https://travis-ci.org/perl6/doc/builds/208709101 https://github.com/perl6/doc/compare/379e364dfdc0...7a393c3aa801
04:06 travis-ci left #perl6
04:13 skids is $*LANG.define_slang supposed to be fully functional, or just a future feature that turns off warnings for now?
04:14 skids because it doesn't work if I don't use the "old way" nqp::bindkey(%*LANG)
04:33 perlawhirl joined #perl6
04:34 TimToady it's supposed to be fully functional, but for now you probably want both the old way and the new way in a try, so that old versions still work
04:34 TimToady (as it's currently written in Tuxic)
04:35 TimToady are you also setting any actions?
04:35 TimToady or just grammar?
04:37 skids actions.
04:37 skids module Control::Bail... the new code is committed.
04:37 TimToady and what is the failure mode if you just use define_slang?  maybe it's getting confused in a subsequent 'use'?
04:38 skids I get both the warning, and none of my tokens are recognized.
04:39 TimToady is there a 'use' in your test after you use Control::Bail?
04:39 TimToady maybe a subsequent use is setting it back the wrong way...
04:39 skids no, there's a use Test above it, nothing after.
04:40 TimToady well, have to drive off, but I'll try to glare at it later
04:41 skids Thanks.  Also trying to fix tadzik's Grammar::BNF... that's got some additional challenges.
04:44 perlawhirl hi perlers
04:45 perlawhirl does any have a nice idiom to get from ({a => 'foo'}, {a => 'bar'}, {b => 'baz'}) to {a => ['foo', 'bar'], b => ['baz']}
04:45 perlawhirl m: say ({a => 'foo'}, {a => 'bar'}, {b => 'baz'}).classify(*.keys).map({.key => .value».values.flat }
04:45 camelia rakudo-moar 1934a5: OUTPUT: «5===SORRY!5=== Error while compiling <tmp>␤Unable to parse expression in argument list; couldn't find final ')' ␤at <tmp>:1␤------> 3keys).map({.key => .value».values.flat }7⏏5<EOL>␤    expecting any of:␤        postfix␤»
04:45 perlawhirl m: say ({a => 'foo'}, {a => 'bar'}, {b => 'baz'}).classify(*.keys).map({.key => .value».values.flat })
04:45 camelia rakudo-moar 1934a5: OUTPUT: «(b => (baz) a => (foo bar))␤»
04:45 perlawhirl something like that
04:48 skids m: my %a; %a.push($_) for ({a => "foo"}, {a => "bar"}, {b => "baz"}); %a.say
04:48 camelia rakudo-moar 1934a5: OUTPUT: «{a => [foo bar], b => baz}␤»
04:49 perlawhirl skids: ahh, much nicer. thanks
04:49 MasterDuke what about classify-list?
04:50 perlawhirl yeah i haven't played with it much, I know it got some work last year... but i haven't had time to see what i can do with it
04:50 perlawhirl but i was thinking maybe it could help
04:50 perlawhirl i really like the classify/categorize stuff
04:54 bjz joined #perl6
04:57 Cabanossi joined #perl6
05:01 movl joined #perl6
05:06 mst joined #perl6
05:23 astj_ joined #perl6
05:24 xtreak joined #perl6
05:32 mcmillhj joined #perl6
05:33 bjz joined #perl6
05:54 CIAvash joined #perl6
05:57 Cabanossi joined #perl6
05:57 curan joined #perl6
06:11 mcmillhj joined #perl6
06:13 wamba joined #perl6
06:20 ZzZombo_ joined #perl6
06:33 mcmillhj joined #perl6
06:49 RabidGravy joined #perl6
06:52 domidumont joined #perl6
06:55 mcmillhj joined #perl6
06:59 Todd joined #perl6
06:59 Todd Hi All,
07:00 Todd Anyone know of a way to use https://github.com/slobo/Perl6-X11-Xlib-Raw/tree/master/examples
07:00 Todd https://github.com/slobo/Perl6-X11-Xlib-Raw
07:00 Todd to read and write to both of the X11 clipboards ("clipboard" and "primary")?
07:01 mcmillhj joined #perl6
07:02 Todd I am trying to avoid xclip
07:07 Todd Here is a far easier one.  I am trying to print out the name of the sub I am in.
07:07 Todd print &?ROUTINE ~ " " ~ "$*DISTRO $OS found\n";
07:08 Todd <unit> rhel linux found
07:08 Todd &?ROUTINE resolves to <unit>, which is not the name of the sub.  What am I missing?
07:09 Todd This is the reference I am using for the variables: https://docs.perl6.org/language/variables#index-entry-%26%3FROUTINE
07:15 mcmillhj joined #perl6
07:16 eroux joined #perl6
07:29 ambs joined #perl6
07:38 bjz joined #perl6
07:38 mcmillhj joined #perl6
07:39 xtreak joined #perl6
07:52 TimToady m: sub foo { say &?ROUTINE.name }; foo
07:52 camelia rakudo-moar 1934a5: OUTPUT: «foo␤»
07:52 wamba joined #perl6
08:00 mcmillhj joined #perl6
08:04 jonas1 joined #perl6
08:07 Todd say &?ROUTINE.name still prints out "<unit>".  What am I missing?
08:08 moritz Todd: maybe you're calling it from outside a routine?
08:08 Todd double checking: print &?ROUTINE.name ~ " " ~ "$*DISTRO $OS found\n";
08:08 Todd It is inside a sub.  Is "sub" and "routine" the same thing here?
08:08 moritz a "sub" is a kind of "routine"
08:12 Todd How does it get "<unit>" from "sub OS_Check () {do something}"?
08:12 moritz Todd: dunno; care to post a short snippet that reproduces the problem?
08:13 moritz using a nopaste service
08:14 Todd sure, let me write something up that is shorter
08:14 rindolf joined #perl6
08:15 shmibs joined #perl6
08:15 Todd Just out of curiouslity, is it a good idea to always include "use v6;" as the second line of your code?
08:15 moritz yes
08:15 Todd what do you mean by "nopaste service"
08:15 Todd ?
08:16 TimToady skids, you want something like: https://gist.github.com/TimToady/df87901b812e4ac0d44e5b5240bcf77d
08:16 TimToady .tell skids you want something like https://gist.github.com/TimToady/df87901b812e4ac0d44e5b5240bcf77d
08:16 yoleaux TimToady: I'll pass your message to skids.
08:17 moritz Todd: something like http://pastebin.com/ that lets you paste mulitple lines of code, and share the URL here in the channel
08:17 TimToady ^^ that's a no-paste
08:17 Todd is three lines to much to paste here?
08:17 moritz right, gist.github.com is a very popular service here
08:17 TimToady three is usually okayish
08:19 Todd and my three liner work, so I will hit my glasses and find my booboo.
08:19 TimToady Todd: notice I used &?Routine. name above
08:19 samcv m: sub thingy { say &?Routine }; thingy
08:19 camelia rakudo-moar 1934a5: OUTPUT: «5===SORRY!5=== Error while compiling <tmp>␤Undeclared name:␤    ?Routine used at line 1. Did you mean 'Routine'?␤␤»
08:20 TimToady er, &?ROUTINE.name
08:20 samcv m: sub thingy { say &?Routine.name }; thingy
08:20 camelia rakudo-moar 1934a5: OUTPUT: «5===SORRY!5=== Error while compiling <tmp>␤Undeclared name:␤    ?Routine used at line 1. Did you mean 'Routine'?␤␤»
08:20 Todd Any feedback of "use v6;"?  My first line is "#!/usr/bin/perl6", but I sometimes write for Windows
08:20 eroux joined #perl6
08:20 TimToady you already got email for that
08:20 samcv Todd, i usually only use `use v6;` for .t files
08:21 samcv and then use .p6 for scripts and .pm6 for modules
08:21 samcv pl6 is another possible thing you can do but I like .p6 personally
08:22 Todd I have been using .pl6
08:22 samcv what editor are you using?
08:23 Todd On windows programs, I call the program with "perl6 program_name", so I don't see that there would be confusion.  Plus p6 code crashed the dickens out of a Perl5
08:24 samcv heh
08:25 Todd on Linux, I use vi, leafpad, and increadingly "geany".  On Windows I use "geany" as it is the most friendly over "ssh -X".  On geany, I turn off the tabs function, as it is ANNOYING.
08:25 moritz use v6; helps generating a good error message if you accidentally run it with p5
08:25 samcv Todd, theoretically perl 5 is supposed to use perl6 instead if it sees `use v6` but it does not work that consistently for me. and setting `#!/usr/bin/env perl6` as first line *used* to make `prove` use perl6 for the .t files, but now it doesn't
08:26 samcv use v6 is only important if the extension is pl or pm I think
08:27 samcv Todd, if you want to try out Atom which is for windows, mac and linux there's a good page on configuring it for perl 6 https://github.com/perl6/Atom-as-a-Perl6-IDE
08:28 samcv moritz, do you have the power to give me admin privs for that repo?
08:28 moritz samcv: I think so, let me check
08:28 Todd How is atom over "ssh -X"?
08:28 samcv uh it might be bad
08:29 moritz samcv: you should have admin now; please check
08:29 samcv you could maybe try some way to sync files
08:29 Todd On another subject, I wrote tons in Modula2 many, many years ago.  I am adicted to Top Down.  And, I have a piece of code I really want to make into a module.
08:30 Todd I am confused as to the name of the module.  In perl 5 , it is the first line "package Package_Name; "a
08:30 samcv thanks moritz
08:30 Todd how is this doem it perl 6?  does it take on the name of the file?
08:31 Todd done, not doem
08:31 samcv well you don't have to do that for perl 6 modules, it can just do it by filename
08:31 samcv but Todd https://docs.perl6.org/language/modules#UNIT::EXPORT::* see the `unit module` part
08:31 samcv you can do that if you wish
08:32 samcv and it only exports subs if you do like `sub foo ($one, $two) is export {…}`
08:32 samcv unless you do more work as that documentation says
08:32 mcmillhj joined #perl6
08:34 Todd I have been looking at that section for a few days now.  I "almost" understand it
08:35 Todd Here is what I am missing.  If I name the module "GreatStuff.pm6", how does the importer know to find this module?
08:36 samcv by the file name if it is not an installed module
08:36 samcv you'll use `use GreatStuff`
08:36 Todd "use GreatStuff.pm6"?
08:36 samcv i believe that also works too Todd
08:36 moritz without the .pm6
08:36 samcv but i don't include the extension though
08:36 moritz Todd: btw Perl 5 also uses only the file name to locate the module file
08:36 samcv but i think `use 'GreatStuff.pm6'` does work with quotes or something
08:37 moritz Todd: it just then messes up if the file it found doesn't declare the package of the appropriate name
08:37 samcv installed modules on perl 6 use sha1 hashes and this allows you to load modules that are different versions and ones by different authors
08:37 Todd by chance is the default ".pm"?  Can this be over ridden?
08:37 moritz it looks for both .pm6 and .pm files
08:37 samcv whose default?
08:37 samcv ^
08:39 Todd "use GreatStuff" implies "use GreatStuff.pm". If I name the module with a weird extension, can the default bve over ridden, or do I need to stick with .pm of .pm6?
08:39 Todd or not of
08:39 samcv well if you don't use a default extension, then do `use 'GreatStuff.weirdext';`
08:40 Todd Okay, that explains it.
08:41 moritz but don't do that.
08:41 Todd Is "lib" the same in p6 as p5 for my non standard locations?
08:41 samcv yep Todd
08:41 abraxxa joined #perl6
08:41 moritz http://design.perl6.org/S11.html "When you pass a string, require always assumes the string contains a filename. To specify both a module name and a filename, use a colonpair modifier: require Sense:file("/home/non/Sense.pm") <common @horse>;"
08:41 samcv actually getting error for doing `use 'extthing.pm6'` with quotes. maybe it's require that allows
08:41 moritz I don't think use supports it
08:42 samcv yeah i vaguely remember that
08:42 Todd Oh no, I will stick with .pm6.   the question was just to help me understand it.
08:42 samcv no problem Todd
08:42 Todd I have a bunch of p5 moduels kicking around and I wanted to keep things separate
08:43 mcmillhj joined #perl6
08:45 Todd yum is churning away lookig for "atom". And it foudn one at "nux" repo.  I will install it.
08:46 samcv Todd, i would just install it from rpm from their site
08:46 Todd I found with geany, that I couldn't use "=pod" like multiline quotes as I lost me colors, but swithing to  #`{} multiline quotes filed it goose
08:46 samcv the distro ones often don't work well because they don't have the right versions of dependencies
08:47 samcv Todd, i am the lead dev for the perl 6 highlighting for atom, and it's really good :) you shouldn't have any of those issues :)
08:47 samcv Todd, you can get an rpm here https://atom.io/
08:47 Todd Thank you!
08:48 samcv you're welcome :)
08:49 Todd I spoofed my User Agent and got teh win32 versio too.
08:49 Todd https://github.com/slobo/Perl6-X11-Xlib-Raw
08:50 abraxxa joined #perl6
08:50 Todd Anyone know how to use this to read and write to both of X11's clipboards?
08:51 Todd Hi samcv, have you tried it over "ssh -X"? yet?
08:51 samcv nope
08:52 moritz Todd: please don't just repost your questions from earlier; that's rather annoying
08:53 Todd Sorry, it scrolled over my page
08:54 araujo joined #perl6
08:54 Todd Samcv!  How are you reading and writing to the X11 clipboards in Atom?  Do you have a module?
08:54 samcv uh i just copy and press Ctrl + C
08:54 samcv err i mean i select and then press ctrl + c
08:54 mcmillhj joined #perl6
08:55 moritz atom is based on some chromium-based toolkit (electron) which handles copy and pasting
08:55 Todd There goes digging though the source code.  Rats!
08:58 samcv Todd, you're building something to interact with X11 pastneboard right?
08:58 samcv primary and secondary?
09:00 wamba joined #perl6
09:00 Todd "clipboard" (ctrl c-v) and "primary" (highlight and center click).  No one uses "secondary" (double click, turn blue, paste at cursor) any more.  I have code already for this, but is uses a shell call to "xclip".  I wanted to get rid of "xclip".  Also the OS::Clipboard out on github support the wrong clipboard.
09:01 samcv but secondary is what ctrl + c does
09:01 samcv you say nobody uses it?
09:01 samcv you want primary though right? the one usually done with middle click
09:02 samcv Todd, I would look at the source of the terminal `st` it supports that function
09:02 samcv and it's not very many lines of code
09:03 Todd is "st" the name of a program?
09:03 samcv yep
09:03 samcv http://st.suckless.org/
09:04 Todd my ssh is sheading some tears transfering 86 meg of atom code to a remote computer
09:05 Todd I really want to test it under ssh -X
09:05 samcv you could just try it under windows
09:05 samcv heh
09:05 samcv why not just download it useing curl or wget
09:05 samcv instead of transfering the binary over ssh
09:05 Todd "suckless" hmmmm.  There has to be a jab at WIndows there somewhere, not just xterm
09:06 samcv st is the only thing that properly renders unicode to conform to the grid
09:06 samcv i have tried like 10 other terminals and they all have the issue that sometimes a symbol is too big or too wide and it alters the alignment of other text
09:07 samcv but i usually use konsole because it's more comfortable than st. st doesn't even have scrolling unless you apply a patch :o
09:07 samcv but i have that patch. but it may be interesting to see how it does pasteboard
09:07 Todd I am on git but not finding the source code.  It must be getting late.  Bet it is written in C, wich I can barely read
09:08 samcv it's not on github
09:08 samcv oh i see what you mean
09:09 eroux joined #perl6
09:09 Todd git clone git://git.suckless.org/st  ????
09:09 samcv git clone git://git.suckless.org/st
09:09 samcv try that
09:09 samcv ya
09:09 samcv i remember checking it out before at least
09:09 Todd If it is in C, I am dead
09:10 samcv lol. I know C
09:10 samcv at first i thought you were going to want to do something with NativeCall or something
09:10 samcv idk maybe there's a C library for clipboard but i'm not sure
09:11 Todd C:  https://en.wikipedia.org/wiki/Tic
09:11 Todd Well that is what usually happens to me when I read C
09:13 Todd Apparently the X11 clipboards get imporved under Wayland, but Wayland still has the X11 hooks
09:21 Todd I jsut realized one of my confusions on module names.  "use OS::Clipboard" is really "...OS/Clipboard.pm".  Is P6 converting "::" into "/" when it looks for the modules file?
09:25 Todd Do I presume correctly that the purpose of "::" is to create subcatagories?
09:26 samcv yes Todd
09:26 samcv that is one common use of it
09:26 Todd I get it now.  I was thinking the "::" had some special function.  Thank you!
09:26 TimToady .tell skids With 44b60a560d that I just checked in, you should be able to work with just the .define_slang, if you don't care to support old versions.  note that you do still have to do the mixins; you can't just pass bare roles to .define_slang, though maybe we could support that...
09:26 yoleaux TimToady: I'll pass your message to skids.
09:27 Todd I am about to fire up Atom of ssh -X
09:28 Todd over not of
09:35 Todd well, it  55 seconds to make contact with me. Geany only takes about 10 seconds.  Atom is still painting too.  Atom may be a bit too rich for ssh -X.  Rats!  Thank you for the tip anyway!  I can always use it over xrdp
09:39 Todd it is like watching paint peal waiting for it to paint.  I had to go into <ctrl><alt><f2> and kill the ssh process
09:39 xtreak joined #perl6
09:42 dakkar joined #perl6
09:47 cibs joined #perl6
09:48 moritz or just use <return>~.
09:48 moritz (to kill an ssh session)
09:54 cibs joined #perl6
09:55 Todd question on modules.  I want two conditions to be met before my module will work.  Both are subs that check for os version and such.
09:56 Todd Do I have to run these each time from the subs "as export" or is the a one time initialization that can be run ?
09:56 moritz there's an INIT phaser for that, I think
09:57 Todd there a one time
09:58 Todd searched through https://docs.perl6.org/language/modules#UNIT::EXPORT::* for INIT and nothing turned up
09:59 moritz because it has nothing to do with exporting
09:59 moritz it runs each time a piece of code is loaded at run time
09:59 Todd found https://docs.perl6.org/syntax/INIT, but I have no clue how to use it in my module
10:01 Todd so, in my module, do I need to run the dependancies every time an "as export" sub is called?
10:01 moritz INIT { check your stuff here, die() if they are not fulfilled)
10:02 Todd okay, where, at the bottom of my module or up top with the "use xxx" stuff?
10:05 Todd something like
10:05 Todd if not INIT { OS_Check or exit 1 };
10:05 Todd ?
10:06 eroux joined #perl6
10:12 shdb joined #perl6
10:21 mcmillhj joined #perl6
10:23 moritz not "if not INIT {... }"
10:23 moritz INIT { unless dependencies-met() { die "you're f'd" } }
10:24 Todd beautiful.  thank you!  I die with "Cowardly exiting.  Bummer dude!".  Your's gets to the point sooner.  Mine is funnier.
10:25 Todd Where do I put the INIT?
10:26 moritz in the mainline of the module
10:27 Todd I am to much of a beginner to understand what that means
10:27 moritz not inside a subroutine
10:27 moritz just inside the module itself
10:29 Todd so top, bottom or anywhere, just not inside a sub?
10:31 cyphase joined #perl6
10:32 parv joined #perl6
10:33 bjz joined #perl6
10:33 mcmillhj joined #perl6
10:36 Todd got to call it a night.  Thank you for all the help!
10:39 parv joined #perl6
10:43 IOninja samcv: what was the atom IDE thing you had?
10:44 samcv https://github.com/perl6/Atom-as-a-Perl6-IDE
10:44 IOninja Thanks
10:44 IOninja huggable: atom idea
10:44 huggable IOninja, nothing found
10:44 IOninja huggable: atom ide
10:44 huggable IOninja, nothing found
10:44 IOninja huggable: atom ide :is: https://github.com/perl6/Atom-as-a-Perl6-IDE
10:44 huggable IOninja, Added atom ide as https://github.com/perl6/Atom-as-a-Perl6-IDE
10:44 samcv this is one of my favs https://github.com/perl6/Atom-as-a-Perl6-IDE#indexing-of-classes-routines-and-operators
10:49 skids joined #perl6
10:50 astj joined #perl6
11:01 salva joined #perl6
11:02 salva joined #perl6
11:03 astj joined #perl6
11:06 mcmillhj joined #perl6
11:08 cibs joined #perl6
11:13 astj joined #perl6
11:14 grondilu joined #perl6
11:19 xtreak joined #perl6
11:20 eroux joined #perl6
11:22 bjz joined #perl6
11:25 tbrowder hi #perl6
11:25 DrForr o/
11:26 tbrowder IOninja: just to close concern and prev discussion of posix time command...
11:27 tbrowder hi, DrForr!
11:27 mcmillhj joined #perl6
11:28 IOninja posix time command... what?
11:29 tbrowder the man page for time is lengthy, and i kept missing the first few words that state all output goes to stderr! quite unusual to me. anyway, after i started using the :err sdverb, all output was captured using run routine instead of using shell
11:30 skids joined #perl6
11:31 tbrowder the discussion centered around why i couldn't capture output from the system time using p6 run or shell
11:32 IOninja No, you said you were capturing `ps apache`
11:33 tbrowder that was something slightly different...
11:34 lukaramu joined #perl6
11:34 tbrowder anyway, the p6 run routine seems to work just fine.
11:35 robertle joined #perl6
11:36 lizmat joined #perl6
11:49 mcmillhj joined #perl6
11:52 tbrowder question on named params: what is the reliable way inside the sub to test for the presence of the param? a plain if or a defined or something else?
11:53 moritz tbrowder: do you really need to check for presence?
11:56 moritz if so, the only bullet-proof way is   sub f(*%named) { if %named<arg>:exist { ... } }
11:56 moritz but typically named arguments have a default anyway, and you only care if it's the default or not
11:56 moritz so you do sub f(Bool :$really) { if $really { ... } }
11:59 raschipi joined #perl6
12:00 jnthn with is often useful here
12:00 tbrowder i'm trying to find the best way to handle my use case. i want the named param to have only certain values (a constraint) but i don't want a default value.  the reason is for not confusing the user with a default value he won't understand in the context of the other choices.
12:01 jnthn (If it's not passed then it'll be undefined)
12:01 jnthn (Provided you don't supply a default)
12:03 tbrowder ok, then will an "if $arg" work or use "if $arg.defined"?
12:05 shdb hi
12:05 shdb is there any way to get the source address and port from a received udp packet?
12:06 aborazmeh joined #perl6
12:06 aborazmeh joined #perl6
12:08 SmokeMachine How can I change/add the default value of a Parameter of the signature of a function?
12:08 shdb i'm using IO::Socket::Async.bind-udp and then whenever $socket.Supply -> $v { .. }
12:09 SmokeMachine m: multi trait_mod:<is>(Parameter:D $p, :$injected!) {$p.set_default("12345")}; sub bla($a is injected) {$a.say}; bla # something like this but that works
12:09 camelia rakudo-moar 44b60a: OUTPUT: «5===SORRY!5=== Error while compiling <tmp>␤No such method 'set_default' for invocant of type 'Parameter'␤at <tmp>:1␤»
12:12 shdb SmokeMachine: it should be sub bla($a = "lala") { say $a }
12:12 mxco86 joined #perl6
12:14 wamba joined #perl6
12:15 parv joined #perl6
12:20 naxieAlDle joined #perl6
12:20 eroux joined #perl6
12:22 mcmillhj joined #perl6
12:22 naxieAlDle IOninja++
12:22 naxieAlDle I don't use twitter, but I enjoy your feed
12:24 SmokeMachine shdb: yes, but I'd like to change it to inject a default...
12:26 shdb ah ok. my bad
12:26 araraloren joined #perl6
12:27 araraloren m: say "".split(';', :skip-empty).perl; say "".split(';').perl;
12:27 camelia rakudo-moar 44b60a: OUTPUT: «("",).Seq␤("",).Seq␤»
12:28 araraloren why first split result is not a empty Seq ?
12:28 lep-delete joined #perl6
12:30 SmokeMachine shdb: like what I do to Attributes and Variables: https://github.com/FCO/Injector
12:32 IOninja araraloren: at first glance looks like a bug. Please report it
12:32 IOninja huggable, rakudobug
12:32 huggable IOninja, Report bugs by emailing to rakudobug@perl.org
12:32 araraloren hm, ok
12:33 DrForr 3 talks for YAPC::NA and ::EU.
12:33 IOninja s: '', 'split', \(';', :skip-empty)
12:33 SourceBaby IOninja, Sauce is at https://github.com/rakudo/rakudo/blob/44b60a5/src/core/Str.pm#L1454
12:34 IOninja hm
12:35 IOninja yeah, I see it. The short-circuit for empty self stuffs self into return after checking for needle chars, but need to also check for skip empty
12:36 parv joined #perl6
12:39 sena_kun joined #perl6
12:41 firestar joined #perl6
12:41 lizmat please rakudobug and I'll fix it  :-)
12:43 SmokeMachine Any way to add a default to a Parameter?
12:45 mcmillhj joined #perl6
12:46 lizmat I only see a way with using NQP
12:47 araraloren Hm, I send a email to rakudobug, It reply [perl #130955]
12:47 synopsebot6 Link:  https://rt.perl.org/rt3//Public/Bug/Display.html?id=130955
12:52 SmokeMachine lizmat: could you show me, please?
12:53 lizmat nqp::bindattr($parameter,Parameter,'$!default_value',42)
12:53 lizmat presumably, off the top of my head  :-)
12:55 SmokeMachine lizmat: thanks!
12:56 lizmat jnthn: any reason why we shouldn't allow Parameter objects to have their default value set in HLL ?
12:59 mcmillhj joined #perl6
13:01 Sound joined #perl6
13:01 jnthn lizmat: Not really, could add a set_default
13:02 jnthn To go with the set_raw, set_rw, etc.
13:03 lizmat araraloren: https://github.com/rakudo/rakudo/commit/fc86084f06
13:05 araraloren lizmat, wonderful.
13:11 Geth ¦ ecosystem: araraloren++ created pull request #305: replace it with a **version** url
13:11 Geth ¦ ecosystem: review: https://github.com/perl6/ecosystem/pull/305
13:13 Geth ¦ ecosystem: eb110ec77b | loren++ | META.list
13:13 Geth ¦ ecosystem: replace with a **version** url (#305)
13:13 Geth ¦ ecosystem: review: https://github.com/perl6/ecosystem/commit/eb110ec77b
13:14 lizmat SmokeMachine: could you check if https://github.com/rakudo/rakudo/commit/d6c95ea452 makes life easier for you ?
13:16 eroux joined #perl6
13:20 sena_kun joined #perl6
13:32 mcmillhj joined #perl6
13:33 lukaramu_ joined #perl6
13:36 cibs joined #perl6
13:39 rjbs- Camelia++
13:39 IOninja \o/
13:43 DrForr Indeed.
13:51 mcmillhj joined #perl6
13:59 SmokeMachine lizmat: I think thats perfect! thanks!
13:59 IOninja \o/
14:00 geekosaur joined #perl6
14:00 IOninja That'll probably make it possible what I long wanted to do, without a slang: assign defaults based on `//=` not on whether they were given by caller
14:02 IOninja m: multi trait_mod:<is>(Parameter:D $p, :$injected!) {$p.set_default("12345")}; sub bla($a is injected) {$a.say}; bla
14:02 camelia rakudo-moar 8c777b: OUTPUT: «5===SORRY!5=== Error while compiling <tmp>␤Type check failed in binding to '$default'; expected Code but got Str ("12345")␤at <tmp>:1␤»
14:02 IOninja m: multi trait_mod:<is>(Parameter:D $p, :$injected!) {$p.set_default({"12345"})}; sub bla($a is injected) {$a.say}; bla
14:02 camelia rakudo-moar 8c777b: OUTPUT: «5===SORRY!5=== Error while compiling <tmp>␤Calling bla() will never work with declared signature ($a = -> ;; $_? is raw { #`(Block|67516192) ... })␤at <tmp>:1␤------> 3"})}; sub bla($a is injected) {$a.say}; 7⏏5bla␤»
14:03 IOninja mmkay then
14:06 SmokeMachine :(
14:07 SmokeMachine not working? :(
14:08 SmokeMachine m: multi trait_mod:<is>(Parameter:D $p, :$injected!) {$p.set_default({"12345"})}; sub bla($a is injected = "test") {$a.say}; bla
14:08 camelia rakudo-moar 8c777b: OUTPUT: «test␤»
14:08 SmokeMachine m: multi trait_mod:<is>(Parameter:D $p, :$injected!) {$p.set_default({"12345"})}; sub bla($a is injected) {$a.say}; bla
14:08 camelia rakudo-moar 8c777b: OUTPUT: «5===SORRY!5=== Error while compiling <tmp>␤Calling bla() will never work with declared signature ($a = -> ;; $_? is raw { #`(Block|75761584) ... })␤at <tmp>:1␤------> 3"})}; sub bla($a is injected) {$a.say}; 7⏏5bla␤»
14:13 lucs IOninja: Nice Perl 6 examples you're tweeting there. Any chance you could also link to a gist of them or something for too-lazy-to-retype folks like myself who would like to play with them?
14:14 * IOninja makes no promises
14:14 lucs Thanks for considering it :)
14:15 IOninja What was the executable pastebin site? Like glot.io but without the ancient perl6 on it
14:16 wigner joined #perl6
14:16 IOninja https://tio.run
14:18 IOninja https://tio.run/#tO2Mv
14:18 IOninja (no easy URL to give straight to perl 6 bin :/)
14:19 IOninja gah, even that URL ain't proper :/
14:19 IOninja Ahhh. that one's v2 alpha. Normal one is https://tio.run/nexus/perl6
14:22 eliasr joined #perl6
14:35 dj_goku joined #perl6
14:35 dj_goku joined #perl6
14:37 cibs joined #perl6
14:39 naxieAlDle joined #perl6
14:39 SmokeMachine m: multi trait_mod:<is>(Parameter:D $p, :$injected!) {$p.set_default({"12345"})}; sub bla($a is injected) {$a.say}; say &bla.arity
14:39 camelia rakudo-moar 0633f0: OUTPUT: «1␤»
14:39 SmokeMachine m: multi trait_mod:<is>(Parameter:D $p, :$injected!) {$p.set_default({"12345"})}; sub bla($a is injected = 1) {$a.say}; say &bla.arity
14:39 camelia rakudo-moar 0633f0: OUTPUT: «0␤»
14:39 SmokeMachine lizmat: if think its not updating the function/signature...
14:42 lizmat SmokeMachine: that would be the responsibility of the "is injected" trait
14:42 SmokeMachine lizmat: makes sense... thanks!
14:42 lizmat as arity is an attribute of the Signature
14:43 lizmat which is probably going to be tricky
14:43 SmokeMachine yes, I saw... the function's arity just calls the signature's arity...
14:43 lizmat as the Parameter object doesn't know to which Signature it belongs  :-(
14:46 araraloren Is there any document about %?RESOURCES ?
14:47 SmokeMachine lizmat: :(
14:48 lizmat araraloren: S22:375
14:48 synopsebot6 Link: http://design.perl6.org/S22.html#line_375
14:48 Actualeyes joined #perl6
14:48 cdg joined #perl6
14:49 araraloren lizmat, thanks
14:50 SmokeMachine lizmat: shouldn't it know about the signature?
14:51 lizmat SmokeMachine: no, why?  I mean, a Signature needs Parameter object, but a Parameter object doesn't need Signature
14:52 lizmat also: if a Parameter object would have a reference to a Signature, it couldn't be reused
14:52 Geth ¦ whateverable: 7698e6eb7b | (Aleks-Daniel Jakimenko-Aleksejev)++ | t/evalable.t
14:52 Geth ¦ whateverable: No hardcoded nickname in tests
14:52 Geth ¦ whateverable:
14:52 Geth ¦ whateverable: Doesn't matter that much, but still.
14:52 Geth ¦ whateverable: review: https://github.com/perl6/whateverable/commit/7698e6eb7b
14:52 Geth ¦ whateverable: 8281f80d2a | (Aleks-Daniel Jakimenko-Aleksejev)++ | t/evalable.t
14:52 Geth ¦ whateverable: Fix tests that pass for no good reason
14:52 Geth ¦ whateverable:
14:52 Geth ¦ whateverable: Because the output is same in each query, the test suite interprets
14:52 Geth ¦ whateverable: the results incorrectly.
14:52 Geth ¦ whateverable: review: https://github.com/perl6/whateverable/commit/8281f80d2a
14:52 lizmat and finally: if it would have a reference to a Signature, neither of them would even be garbage collected
14:52 SmokeMachine lizmat: a Package needs Attribute object, not the opposite, but Attribute has a package Attribute...
14:54 SmokeMachine m: Attribute.new.package.say
14:54 camelia rakudo-moar 0633f0: OUTPUT: «Required named parameter 'name' not passed␤  in block <unit> at <tmp> line 1␤␤»
14:54 lizmat so neither packages or attributes will ever be garbage collected
14:54 lizmat jnthn: is that assessment correct
14:54 lizmat ?
14:54 SmokeMachine m: Attribute.new(:name<bla>).package.say
14:54 camelia rakudo-moar 0633f0: OUTPUT: «Required named parameter 'type' not passed␤  in block <unit> at <tmp> line 1␤␤»
14:55 SmokeMachine m: class C {has $.a}.^attributes[0].package.say
14:55 camelia rakudo-moar 0633f0: OUTPUT: «(C)␤»
15:06 TeamBlast joined #perl6
15:11 unicodable6 joined #perl6
15:15 tbrowder jnthn: ref  named params, i would like to have a constraint on a named param but i can't seem to do that and not use the named param in the sub call. my test code is at github gist <https://gist.github.com/tbrowder/62e22837715f749986983491655ef8fe>. what am i doing wrong? thanks.
15:17 timotimo tbrowder: you have to make sure it returns True when $fmt.defined is false
15:17 timotimo otherwise it'll reject it, right?
15:17 tbrowder hm, let me try that...
15:21 leedo joined #perl6
15:21 tbrowder timotimo: i have tried various ways to mod the constraint but i get exceptions. can you mod the gist code so it works?
15:22 timotimo i can try
15:22 timotimo let's see ...
15:22 IOninja Dunno what you're trying to do, but...
15:22 IOninja buggable: eco subset::helper
15:22 buggable IOninja, Subset::Helper 'create awesome subsets': https://github.com/zoffixznet/perl6-Subset-Helper
15:23 timotimo timo@schmand /tmp> perl6 test-param.p6
15:23 timotimo fmt = undefined
15:23 timotimo is that the output you want?
15:23 IOninja should work with in-param whereclauses as well
15:23 tbrowder yes!  can you show the code, please?
15:23 timotimo i literally just put "else { True }" in there
15:25 tbrowder ah! that works..thanks!  sounds like a good entry for the docs, no?
15:26 IOninja you've just over-complicated your code...
15:27 tbrowder also, shouldn't rakudo do that by default?
15:27 IOninja { $fmt.defined.not or $fmt ~~ &fmt }
15:27 IOninja No, it shouldn't. You're returning an Empty from your where clause which is a failed type check
15:28 tbrowder IOninja, okay, better but not so obvious to a noob...
15:29 IOninja You just never asked yourself what your where clause is returning...
15:30 IOninja Even if you don't know that lone failed `if` returns an Empty, you can see there's "nothing" returnedb :/
15:31 tbrowder got it, thanks a heap timotimo and IOninja!
15:32 tbrowder i'll take a closer look at the docs...
15:37 tbrowder btw, this is a bit shorter: "!$fmt.defined || $fmt ~~ &fmt"
15:38 IOninja $fmt andthen $_ ~~ &fmt
15:38 bdmatatu joined #perl6
15:38 IOninja oh nevermind
15:39 timotimo not quite, no
15:39 timotimo maybe "notandthen" ;)
15:39 IOninja nope
15:39 IOninja `subset-is {$_ ~~ &fmt}`
15:39 IOninja shortest :)
15:40 timotimo the what now :)
15:40 timotimo is that built-in?
15:40 IOninja buggable: eco subset::helper
15:40 buggable IOninja, Subset::Helper 'create awesome subsets': https://github.com/zoffixznet/perl6-Subset-Helper
15:40 timotimo ah
15:40 timotimo well, that makes sense :)
15:41 IOninja need to add `param-is` so it'd make more sense when used in where clauses on params
15:44 gregf_ tbrowder: i was kinda lost reading that code :|. whats token for please?
15:44 timotimo "token" is like "regex", but it turns on ratchet
15:46 IOninja Nurse Ratchet
15:46 gregf_ oh, ok. and ratchet?
15:46 gregf_ ah - nevrmind
15:47 IOninja you know, like the slang :P
15:47 IOninja We try to stay hip and cool :P
15:47 gregf_ :D
15:47 IOninja tokens and rules don't backtrack. regexes do
15:47 wamba joined #perl6
15:56 rurban joined #perl6
15:57 eroux joined #perl6
15:58 rurban left #perl6
16:04 geekosaur joined #perl6
16:08 cdg joined #perl6
16:09 mcmillhj joined #perl6
16:16 bwisti_ joined #perl6
16:16 tbrowder IOninja: subset helper looks cool. i'll have to try it.
16:17 tbrowder are you addng param-is soon?
16:18 IOninja well, it'd be just a more readable alias for `subset-is`
16:20 bwisti_ joined #perl6
16:41 pukku joined #perl6
16:45 pukku Hi! In Perl 5, if you call die() and end your error with a newline ("\n"), it suppresses any line numbers, etc. How do I do the same in Perl 6?
16:45 itaipu joined #perl6
16:45 timotimo it really depends on what you want to have happen
16:45 timotimo do you want the "die" to let calling code catch it?
16:45 pukku I just want the program to die, printing the error message, but not the backtrace.
16:46 pukku Probably not?
16:46 IOninja pukku: note "some error"; exit
16:46 timotimo in that case you want note + exit(1) (or some other non-0 number)
16:46 pukku How do I choose the non-zero number?
16:46 timotimo anything your imagination lets you come up with
16:46 IOninja pukku: just use 1 if you're not sure.
16:47 timotimo i'm not sure what the maximum number is
16:47 IOninja 254, I'd imagine
16:47 pukku Hm.
16:48 st_elmo joined #perl6
16:48 IOninja pukku: the number is used by the program running your program to figure out why it existed abnormally
16:49 IOninja and if you don't want to tell anything other than "this is not a normal exit" then any number will do and may as well use 1 (that's what Perl 5's die returns)
16:49 pukku I understand that, but I guess I'm annoyed because this means I can't just "die() if $x"
16:49 jnthn If you're doing it a bunch just define a sub
16:50 jnthn sub conk($message) { note $message; exit 1 }
16:50 pukku Also, having exit separate from note is going to make the intent a little less obvious.
16:50 pukku I guess I can do that. It does mean that every single Perl 6 program I write now has to have another bit of boiler-plate. But I guess there's nothing to do about it.
16:50 IOninja pukku: sure you can:   "some error".note, exit 1 if 1
16:51 timotimo if you want you can 'note "omg" andthen exit 1 if $failure'
16:54 IOninja .oO( make exit take a string to note()... )
16:54 SmokeMachine lizmat: only change the rarity didn't work... :( https://www.irccloud.com/pastebin/sky3GWnM/
16:55 perlpilot pukku: or ... you could provide a patch to die that implements a :no-backtrace named arg and see if it gets accepted.
16:55 IOninja That's a lot of typing...
16:56 pukku I'll look into that -- or maybe the change to exit IOninja suggested...
16:56 IOninja Also, I don't get how that'd work. IIRC die just does X::AdHoc.new("blah").throw
16:56 perlpilot pukku: Just remember "I guess there's nothing to do about it" doesn't really apply to Perl 6   ;-)
16:57 jnthn I'd probably not try and overload that behavior onto die
16:57 IOninja pukku: FWIW, I'd rather see a separate routine for that. Stuffing a string to note to exit has a bunch of problems, such as what if the user calls `exit <1>`? etc.
16:57 IOninja Best to keep it separate
16:57 perlpilot Has anyone done a carp-a-like for P6 yet?
16:58 IOninja carp-a-like? Isn't that the default behaviour for us?
16:59 perlpilot well ... carp, croak, confess, longmess, shortmess ... those are nice "hooks" for people who want custom behavior
16:59 IOninja .oO( sub cry-and-die (Str $message, Int $exit-code = 1) { $message.note; exit $exit-code; }
16:59 IOninja )
17:00 IOninja perlpilot: ah, never used it for more than "Where the hell is the caller that causes this error" :)
17:05 xtreak joined #perl6
17:06 xtreak https://www.reddit.com/r/perl6/comments/5wasxy/iowesomeness_advance_notice_of_significant_changes/decbati . Thats 100k lines of Perl6 code. Any idea on the application and links to the code?
17:06 cdg_ joined #perl6
17:09 timotimo i expect that might be RabidGravy?
17:09 IOninja xtreak: the person in question is RabidGravy. Maybe they can tell you. For the code, I just cloned https://github.com/moritz/perl6-all-modules in RabidGravy's author dir: https://github.com/moritz/perl6-all-modules/tree/master/jonathanstowe as I know most of the modules they wrote is to use at the radiostation to do something or other.
17:10 IOninja *and ran `wc` in author's dir
17:10 IOninja Lots of yakshaving there...
17:12 xtreak IOninja Thanks. Just googled "Radio station Perl6" and got this https://perl6advent.wordpress.com/2015/12/16/ :)
17:13 IOninja haha, yeah, the author is RabidGravy
17:14 * moritz tries to decide whether https://github.com/moritz/perl6-all-modules triggering a hilight in my IRC client is a bug or a feature
17:15 IOninja :)
17:19 pukku How do I push a pair onto an array? Or a simple hash? The following code doesn't do what I'm expecting...
17:19 pukku if (%p{'tags'}.elems) {         %post{'post_tags'} = { 'tags' => [] };         for %p{'tags'} -> $tag {             %post{'post_tags'}{'tags'}.push: 'tag' => $tag;         }     }     note %post{'post_tags'}.gist;
17:19 pukku OK, that paste didn't work.
17:19 * IOninja shudders at that code
17:19 IOninja pukku: use a proper pastebin like gist.github.com
17:20 pukku Basically, I want to wind up with %post = { post_tags => { tags => [ { 'tag' => 'foo'}, { 'tag' => 'bar' } ] } };
17:20 IOninja pukku: %p{'tags'}.elems should %p{'tags'}:v.elems or ditch the Perl-5-ism and write it properly as %p<tags>:v.elems
17:20 moritz or just   if %p<tags> { }
17:21 IOninja right
17:21 pukku But I wind up with %post = { post_tags => { tags => [ tag => [ 'foo', 'bar' ] ] } };
17:21 moritz pukku: there's nothing in your code to generate the inner hashes
17:21 pukku I tried "push({'tag' => $tag})", and that did the exact same thing.
17:22 pukku I tried "push(:tag<$tag>)", also did the same thing.
17:22 moritz pukku: please post a small, self-contained example using a pastebin
17:23 itaipu joined #perl6
17:24 IOninja m: my %h; %h<foo><bar>.push: "foo$_" => "meow" for ^2; dd %h
17:24 camelia rakudo-moar 9a5401: OUTPUT: «Hash %h = {:foo(${:bar($[:foo0("meow"), :foo1("meow")])})}␤»
17:24 IOninja seems to work fine on small code
17:24 IOninja m: my %h; %h<foo><bar>.push: "foo" => "meow" for ^2; say %h
17:24 camelia rakudo-moar 9a5401: OUTPUT: «{foo => {bar => [foo => meow foo => meow]}}␤»
17:25 SmokeMachine m: sub bla($a) {}; &bla.wrap: -> | {}; bla # ←shouldn't it work?
17:25 camelia rakudo-moar 9a5401: OUTPUT: «5===SORRY!5=== Error while compiling <tmp>␤Calling bla() will never work with declared signature ($a)␤at <tmp>:1␤------> 3sub bla($a) {}; &bla.wrap: -> | {}; 7⏏5bla # ←shouldn't it work?␤»
17:25 pukku I'm working on creating a smaller reproducible thing...
17:25 moritz m: use soft; sub bla($a) {}; &bla.wrap: -> | {}; bla
17:25 camelia rakudo-moar 9a5401: OUTPUT: «5===SORRY!5=== Error while compiling <tmp>␤Calling bla() will never work with declared signature ($a)␤at <tmp>:1␤------> 3ft; sub bla($a) {}; &bla.wrap: -> | {}; 7⏏5bla␤»
17:26 SmokeMachine whats soft?
17:27 moritz SmokeMachine: wrapping happens at run time, but we do some types of dispatch checking at compile time
17:27 moritz SmokeMachine: and I thought "use soft;" disabled those, but it doesn't seem to work
17:27 moritz m: use soft *; sub bla($a) {}; &bla.wrap: -> | {}; bla
17:27 camelia rakudo-moar 9a5401: OUTPUT: «5===SORRY!5=== Error while compiling <tmp>␤Calling bla() will never work with declared signature ($a)␤at <tmp>:1␤------> 3 *; sub bla($a) {}; &bla.wrap: -> | {}; 7⏏5bla␤»
17:27 moritz m: use soft &bla; sub bla($a) {}; &bla.wrap: -> | {}; bla
17:27 camelia rakudo-moar 9a5401: OUTPUT: «5===SORRY!5=== Error while compiling <tmp>␤Calling bla() will never work with declared signature ($a)␤at <tmp>:1␤------> 3la; sub bla($a) {}; &bla.wrap: -> | {}; 7⏏5bla␤»
17:27 jnthn afaik, soft prevents inlining
17:28 jnthn But doesn't skip signature checks
17:28 IOninja m: sub bla($a) {}; &bla.wrap: -> | {}; EVAL 'bla'
17:28 camelia rakudo-moar 9a5401: OUTPUT: «5===SORRY!5=== Error while compiling EVAL_0␤Calling bla() will never work with declared signature ($a)␤at EVAL_0:1␤------> 3<BOL>7⏏5bla␤»
17:29 jnthn Also, .wrap doesn't change the outside signature of the routine
17:29 moritz oh, that's a better explanation :-)
17:29 IOninja :)
17:30 pukku OK, I figured it out. I apologize for the bother -- apparently I needed the ":v" on the topic of the for loop, in order to unwrap something?
17:30 TimToady m: sub bla($a) {}; &bla.wrap: -> | {}; bla |()
17:30 camelia rakudo-moar 9a5401: ( no output )
17:30 TimToady m: sub bla($a) {}; &bla.wrap: -> | { say "gothere" }; bla |()
17:30 camelia rakudo-moar 9a5401: OUTPUT: «gothere␤»
17:31 IOninja cheater...
17:31 IOninja :)
17:31 timotimo is it "got here" or "go there"?
17:31 TimToady yes
17:31 pukku Is there a different way I should refer to an element in an array to unwrap it?
17:31 pukku sorry, an element in a hash
17:31 moritz unwrap?
17:32 IOninja pukku: we still haven't seen your code and have no idea what you're even talking about.
17:32 bdmatatu joined #perl6
17:33 IOninja pukku: %h<non-existent-key>.elems will give you 1 because that lookup gives you Any and all things are 1-elem lists. %h<non-existent-key>:v.elems will give you 0, because that gives you a list of all the values and there ain't no such key, so the list is empty
17:33 IOninja Same applies to any other methods like .elems that treat Any things as 1-elem lists
17:33 pukku I'm having difficulty turning it into something that I can easily paste, as the data is coming from a JSON source on the internet, and I don't understand enough about how this is turned into a hash in Perl 6 to figure out how to mimic this in a literal.
17:34 timotimo you can just .perl it and copy that
17:35 IOninja m: sub bla($, $) {}; &bla.wrap: -> | { say "gothere" }; bla |()
17:35 camelia rakudo-moar 3046d5: OUTPUT: «gothere␤»
17:35 IOninja How come this works?
17:36 jnthn You never callsame
17:36 TimToady |() delays the arglist construction till runtime
17:36 IOninja Ah
17:36 jnthn oh, that also :)
17:36 moritz wow, TIL
17:36 jnthn mis-read :)
17:37 moritz these are times when I wonder if I'm the/a right person to write a book about Perl 6 :-)
17:37 IOninja m: sub bla($, $) {}; &bla.wrap: -> | { say "gothere" }; INIT bla |()
17:37 camelia rakudo-moar 3046d5: OUTPUT: «Too few positionals passed; expected 2 arguments but got 0␤  in sub bla at <tmp> line 1␤  in block <unit> at <tmp> line 1␤␤»
17:37 IOninja m: sub bla($, $) {}; &bla.wrap: -> | { say "gothere" }; LEAVE bla |()
17:37 camelia rakudo-moar 3046d5: OUTPUT: «gothere␤»
17:37 IOninja m: sub bla($, $) {}; &bla.wrap: -> | { say "gothere" }; END bla |()
17:37 camelia rakudo-moar 3046d5: OUTPUT: «gothere␤»
17:38 TimToady so you've proven that INIT happens before run time, but LEAVE and END happen after :)
17:38 IOninja :D
17:39 TimToady m: sub bla($, $) {}; INIT &bla.wrap: -> | { say "gothere" }; INIT bla |()
17:39 camelia rakudo-moar 3046d5: OUTPUT: «gothere␤»
17:39 IOninja Ohh, OK. Now I get it
17:39 TimToady m: sub bla($, $) {}; CHECK &bla.wrap: -> | { say "gothere" }; INIT bla |()
17:39 camelia rakudo-moar 3046d5: OUTPUT: «gothere␤»
17:41 pukku I have to run away for a bit, I'll come back in about an hour and ask for elucidation then. Sorry, but work calls...
17:44 SmokeMachine so, is that a rakudobug?
17:45 IOninja Nope
17:45 TimToady the absence of a time machine is not a bug
17:46 SmokeMachine doesn't that make wrap kind of useless?
17:48 TimToady there are lots of ways to run a .wrap when you need to run it, as shown above, but we also don't support mind-reading
17:48 SmokeMachine ok...
17:48 moritz fwiw I've never used wrap in my own code
17:48 TimToady it's really in there for AOP and such
17:48 moritz maybe my mind isn't wired up to consider it as an option, or maybe I never needed it
17:49 cibs joined #perl6
17:49 TimToady people who rely on "before" and "after" in Moose tend to find it more in their brainspace
17:49 SmokeMachine I was trying to use that to inject default values into parameters of a function...
17:50 * moritz just uses default values :-)
17:50 SmokeMachine moritz: Im writing a dependency injector...
17:50 TimToady or .assuming
17:50 SmokeMachine assuming! thanks TimToady !
17:51 moritz .assuming *is* in my tool belt :-)
17:52 SmokeMachine no... it will not "wrap" the function... :(
17:52 TimToady .oO(never assume...)
17:53 moritz SmokeMachine: do you actually have to wrap it in-place?
17:54 moritz SmokeMachine: I mean, you can offer both an "injected" and a "pristine" version of a function, no?
17:54 SmokeMachine moritz: but won't the function must be declared as multi?
17:54 robertle joined #perl6
17:55 moritz SmokeMachine: it could be a different name
17:55 moritz SmokeMachine: or the "injected" version could live in a hash, or something
17:55 eroux joined #perl6
17:55 SmokeMachine moritz: I want to do the same I do with Attributes and Variables but with Parameters... https://github.com/FCO/Injector/blob/master/README.md
17:56 TimToady or you can define your own proto, if it's not in the same scope
17:56 SmokeMachine TimToady: its on the same scope... :( it should work as the original function...
17:57 mcmillhj joined #perl6
17:58 TimToady then you probably need to override the signature also at BEGIN time, wherever the compiler looks that up
17:58 SmokeMachine it would be perfect if the new Parameter::set_default change the signature...
17:59 * TimToady doesn't know how to do the equivalent of recomposing the signature, offhand...maybe jnthn++ knows?
18:00 TimToady it's also quite possible I still haven't had enough coffee to think of the answer
18:01 TimToady It's even more likely that, given my age, there's no amount of coffee that will help me think of it...
18:01 SmokeMachine :) ☕️
18:02 domidumont joined #perl6
18:05 TimToady of course, I suppose I could deign to read the source code, but then, so could you :)
18:06 SmokeMachine TimToady: :) I am! Thanks!
18:10 IOninja I'd be interested in recomposing signatures too...
18:10 IOninja To fix: https://rt.perl.org/Ticket/Display.html?id=130891
18:11 IOninja I think if we could transplant signature of first routine onto returning routine, then things would work out....
18:11 IOninja "in theory" :)
18:13 sufrostico joined #perl6
18:13 TimToady it has to be a modified signature, or the arity/count goes wrong when you add defaults
18:13 TimToady well, if you're adding defaults to positionals, I mean
18:13 mcmillhj joined #perl6
18:15 domidumont joined #perl6
18:15 TimToady or maybe we just need a way to tell the compiler, yes, I'm redefining it, and I know what I'm doing, so shutup
18:17 TimToady of course, how to refer to the previous definition when you're overriding its name is...interesting...since it's not OUTER
18:19 kurahaupo__ joined #perl6
18:22 IOninja m: my \x = 42; dd &x # lulzwat?
18:22 camelia rakudo-moar 3046d5: OUTPUT: «Nil␤»
18:23 sufrostico joined #perl6
18:24 andrzejk_ joined #perl6
18:25 raschipi What does x and &x have to do with one another?
18:27 IOninja What does the &() coercer do?
18:27 IOninja m: dd &(e)
18:27 camelia rakudo-moar 3046d5: OUTPUT: «2.71828182845905e0␤»
18:27 mcmillhj joined #perl6
18:28 pukku Hi! I'm back. Here is some sample code: https://gist.github.com/remorse/f59c149c52b805874cb473bf4a39b6ac . My question is, why do I require the ":v" to make this work? And is there a better way to handle this?
18:28 IOninja My eyes!
18:28 vendethiel joined #perl6
18:29 IOninja pukku: my earlier explanation applies.
18:29 IOninja pukku: change `if (%p{'tags'}.elems) {` to `if %p<tags> {` and it'll work
18:30 IOninja pukku: this explanation: https://irclog.perlgeek.de/perl6/2017-03-08#i_14227779
18:31 IOninja Wow. I actually managed to fix RT130891.... But the fix is so hackish, I fear it gave me cancer...
18:31 synopsebot6 Link:  https://rt.perl.org/rt3//Public/Bug/Display.html?id=130891
18:32 IOninja m: https://gist.github.com/zoffixznet/b227823ada32ccf867449f5749c17e18
18:32 camelia rakudo-moar 3046d5: OUTPUT: «36␤46656␤46656␤2␤2␤2␤2␤»
18:32 pukku That still doesn't solve the problem of the tags being all one thing, instead of multiple elements. I've just updated the gist with the Perl 5 version of what I'm doing. Although now that I'm looking at it, I might be able to do something with map?
18:33 IOninja I don't even get how it works... I transplanted the signature so its count/arity are tweaked, but I'm still able to use the `|args` capture inside the transplant-receiving sub? This is some prime black magic sourcery.
18:33 pukku I guess the question I'm really asking is if there is a more explicit cast to array that I should use, instead of the ':v'.
18:34 pukku (Also, there's a typo in the perl 5 version; it should be `scalar( $p->{'tags'}->@*)`)
18:34 IOninja pukku: dude, don't use :v; don't use casts. Several examples in the channel already showed you how to avoid both issues.
18:34 IOninja If you're still having issues provide proper snippet that shows the issue we can run and debug
18:35 pukku The examples have gotten rid of the .elems, but not the ':v'. The gist that I linked to is runnable, and shows the issue...
18:36 pukku If I have to have the ':v' on the for loop, that's fine, but I'm confused about why...
18:36 mcmillhj joined #perl6
18:37 IOninja OK. Let me have a closer look.
18:38 pukku Also, I guess a question is, why is `%p<tags>` so different from `%p{'tags'}`?
18:38 IOninja pukku: and now it produces desired output? with the :v on the forloop?
18:38 IOninja pukku: it's (almost) the same thing. it's just much more readable
18:38 sufrosti1o joined #perl6
18:39 pukku OK, it did do that at one point, but now it doesn't, so I'm still confused. Hang on while I undo furiously...
18:40 IOninja pukku: what's post_tags? Do you control it? Is there a reason it's set to a string at the start?
18:41 pukku It's a string so that the (eventual) templating engine will suppress the tags stuff if there aren't any.
18:43 IOninja m: https://gist.github.com/zoffixznet/f36dce071438fe305de2c330c13d80b6
18:43 camelia rakudo-moar 3046d5: OUTPUT: «{:date-gmt("XXX"), :id("XXX"), :slug("XXX"), :tags($["Galaxy", "Galaxy fan render", "planet"]), :type("photo"), :url("http://XXX"), :url-with-slug("http://XXX")}␤»
18:43 pukku OK, I've just figured it out -- the gist should be printing `%post.perl`, not `%p.perl`. Then, look at the 'post_tags' key of '%post'. Without the ':v', you get one tag, with the :v you get three.
18:44 IOninja And it should be :post_tags(:tags([{tag => "Gallaxy"}, {tag => "planet"}])) etc, right?
18:44 pukku Yup!
18:44 espadrine joined #perl6
18:44 pukku And with the ':v' it is; I'm now just trying to understand why...
18:45 agentzh joined #perl6
18:46 IOninja Ah, OK, I see it.
18:46 IOninja m: https://gist.github.com/zoffixznet/f1e978803ab1cad33ca43e3f35af35d9
18:46 camelia rakudo-moar 3046d5: OUTPUT: «{:_post(${:date-gmt("XXX"), :id("XXX"), :slug("XXX"), :tags($["Galaxy", "Galaxy fan render", "planet"]), :type("photo"), :url("http://XXX"), :url-with-slug("http://XXX")}), :_type("photo"), :post_body(""), :post_date("XXX"), :post_id("XXX"), :post_slug("…»
18:47 pukku In Perl 5, I understand the need to be explicit about running over an array, because Perl 5 doesn't have types. However, in Perl 6, shouldn't the `for` know to iterate over the array?
18:48 IOninja pukku: basically, without the :v (or the .list in my version), `for` just loops over 1-item list: the entire array with all the tags, because it's itemized. So to make it treat it as an iterable and iterate over the items inside, you have to convert it back to de-itemized list with :v or .list or @() coercer
18:48 perlpilot It's too bad we don't have a easy link to the docs where this is explained ...   :)
18:49 girafe joined #perl6
18:49 IOninja m: my $a = [1, 2, 3]; for $a { dd $_ }
18:49 camelia rakudo-moar 3046d5: OUTPUT: «Array $a = $[1, 2, 3]␤»
18:49 IOninja m: my $a = [1, 2, 3]; for @$a { dd $_ }
18:49 camelia rakudo-moar 3046d5: OUTPUT: «Int <element> = 1␤Int <element> = 2␤Int <element> = 3␤»
18:49 IOninja perlpilot: we don't?
18:49 perlpilot I was hoping for someone to prove me wrong
18:50 pukku I'm not sure what you mean by "itemized"?
18:50 perlpilot I mean, I would search for "single arg rule" or "SAR" but that would be fruitless.
18:50 IOninja m: my @a = 1, 2, 3; for (@a,) { dd $_ }
18:50 camelia rakudo-moar 3046d5: OUTPUT: «Array @a = [1, 2, 3]␤»
18:51 pukku (Well, I see what you sent to the bot, and I'm trying to understand it.)
18:51 IOninja perlpilot: but this case right now isn't about single arg rule, is it?
18:51 IOninja TBH I don't really know why `for` doesn't loop over $a
18:51 IOninja It'
18:51 IOninja It's a 1-item thing. What are the chances I want to 1-iteration-loop over it rather than over its items?
18:53 perlpilot The question of why he needs :v or .list or @() or | there is explained by the single arg rule.
18:53 IOninja pukku: make it be concidered as 1 item (rather than many items it contains). You can make it with `item` routine $ coercer and some things make stuff itemized automatically, like I think stuffing it into an array or hash.
18:53 mcmillhj joined #perl6
18:53 perlpilot or .flat I suppose
18:53 IOninja perlpilot: huh?
18:54 lostinfog joined #perl6
18:54 IOninja Single-arg rule is (1) vs (1,)
18:54 IOninja Not about @a vs $@a
18:54 IOninja Isn't it?
18:55 perlpilot https://design.perl6.org/S07.html#The_single_argument_rule
18:55 raschipi "    for @a { }              # List of @a.elems things; @a.elems iterations"
18:56 IOninja That smells very outdated: "Flattening is the idea that an @-like thing will, in certain contexts, have its values automatically incorporated into the surrounding list"
18:56 perlpilot sure, it's the closest I could get though
18:56 sufrostico joined #perl6
18:57 pukku So I guess the answer is that the reason I need to de-itemize the tags is because for some reason the JSON parser, instead of just creating an array, created an item of an array?
18:57 IOninja oh, nm, that's just... says what flattening is.
18:57 raschipi Does anyone know why it changed?
18:57 perlpilot raschipi: why what changed?
18:58 raschipi For @a flatenning to not flatenning in a for loop.
18:58 IOninja pukku: I think `slipping` is a more common term. And you'd do it with `for |%p<tags>` instead of the :v thing
18:58 IOninja raschipi: nothing's changed from what's described on that line.,
18:58 perlpilot raschipi: er, what?
18:59 raschipi m: my @a = 1, 2, 3; for @a { dd $_ }
18:59 camelia rakudo-moar 3046d5: OUTPUT: «Int @a = 1␤Int @a = 2␤Int @a = 3␤»
18:59 raschipi But the same doesn't happen for hashes, is that it?
19:00 raschipi m: my %a = 1, 2, 3, 4; for %a { dd $_ }
19:00 camelia rakudo-moar 3046d5: OUTPUT: «"1" => 2␤"3" => 4␤»
19:00 IOninja m: my @a = 1, 2, 3; my %h = foo => @a; for %h<foo> { dd $_ }
19:00 camelia rakudo-moar 3046d5: OUTPUT: «Array %h = $[1, 2, 3]␤»
19:00 raschipi Oh, I see now
19:00 IOninja m: my @a = 1, 2, 3; my %h = foo => @a; for |%h<foo> { dd $_ }
19:00 camelia rakudo-moar 3046d5: OUTPUT: «Int @a = 1␤Int @a = 2␤Int @a = 3␤»
19:00 perlpilot pukku: In your code, you had "for %post{'tags'} -> $tag { ... }"   %post{'tags'} is a single thing.  If you want it to be treated as multiple things, you have to tell Perl
19:00 IOninja pukku: it's not about JSON parser. ^ stuffing a thing into array or hash makes it itemized.
19:00 raschipi Thanks guys, sorry for the derp
19:01 IOninja .oO( scalarized? )
19:01 sufrosti1o joined #perl6
19:01 IOninja perlpilot++ thanks.
19:01 grumble joined #perl6
19:02 raschipi pukku: I got it for the first time reading this: https://docs.perl6.org/type/Slip
19:03 pukku OK -- I guess I understand what's going on, sort of. At any rate, using the slip stuff also works, and I'll hope that over time this becomes more natural to me. Thanks for all of the help understanding this -- now I get to find the next thing I don't understand!
19:04 perlpilot pukku: usually I use @() or .list
19:04 IOninja pukku: I still don't get this stuff, after a year :)
19:05 itaipu joined #perl6
19:05 IOninja m: my @a = ^3; my @b = ^3+5; @a.append: @b; say @a
19:05 camelia rakudo-moar 3046d5: OUTPUT: «[0 1 2 5 6 7]␤»
19:05 IOninja m: my @a = ^3; my @b = ^3+5; @a.append: @b,; say @a
19:05 camelia rakudo-moar 3046d5: OUTPUT: «[0 1 2 5 6 7]␤»
19:05 IOninja Like why does this not make a difference? I did add a comma!
19:06 mcmillhj joined #perl6
19:07 IOninja m: my @b = ^3+5; dd [   @b  ]
19:07 camelia rakudo-moar 3046d5: OUTPUT: «[5, 6, 7]␤»
19:07 IOninja m: my @b = ^3+5; dd [   @b,  ]
19:07 camelia rakudo-moar 3046d5: OUTPUT: «[[5, 6, 7],]␤»
19:07 IOninja But it does matter here...
19:07 n1ce joined #perl6
19:07 IOninja m: my @b = ^3+5; for (@b) { dd $_ }
19:07 camelia rakudo-moar 3046d5: OUTPUT: «Int @b = 5␤Int @b = 6␤Int @b = 7␤»
19:07 IOninja m: my @b = ^3+5; for (@b,) { dd $_ }
19:07 camelia rakudo-moar 3046d5: OUTPUT: «Array @b = [5, 6, 7]␤»
19:07 IOninja And here....
19:08 IOninja And the synopses says " rule is implemented consistently throughout the language" ... "@a.append: @b,;           # same, trailing comma doesn't make > 1 argument"
19:08 IOninja But that's inconsistent with previous examples :S
19:09 raschipi pukku: After a while you start to like it this way, because one doesn't need to dance around with references to pass the list as one thing. The other side of the coin is that you need to explicitly ask for slipping.
19:10 sufrostico joined #perl6
19:11 raschipi pukku: Things keep their shape by default.
19:11 IOninja m: my @a = ^3; my @b = ^3+5; @a.append: @b, Empty; say @a
19:11 camelia rakudo-moar 3046d5: OUTPUT: «[0 1 2 [5 6 7]]␤»
19:11 IOninja m: my @a = ^3; my @b = ^3+5; @a.append: @b, |(); say @a
19:11 camelia rakudo-moar 3046d5: OUTPUT: «[0 1 2 5 6 7]␤»
19:11 IOninja And I don't get this difference.
19:14 Cabanossi joined #perl6
19:14 raschipi IOninja: Is that tested in roast?
19:14 SmokeMachine there's no way to, from the Parameter, get the signature/function?
19:17 IOninja raschipi: what is?
19:18 mcmillhj joined #perl6
19:18 raschipi The "(@a,)" slipping.
19:18 IOninja It isn't.
19:18 IOninja It isn't slipping.
19:18 IOninja m: my @b = ^3+5; for (@b) { dd $_ }
19:18 camelia rakudo-moar 3046d5: OUTPUT: «Int @b = 5␤Int @b = 6␤Int @b = 7␤»
19:18 IOninja m: my @b = ^3+5; for (@b,) { dd $_ }
19:18 camelia rakudo-moar 3046d5: OUTPUT: «Array @b = [5, 6, 7]␤»
19:19 sufrostico joined #perl6
19:20 naxieAlDle joined #perl6
19:20 raschipi Here: m: my @a = ^3; my @b = ^3+5; @a.append: @b,; say @a
19:20 pukku Out of curiosity, is there a shorter way in Perl 6 to say `if (defined($foo) and ($foo ne '')) { ... }`?
19:20 sufrosti1o joined #perl6
19:20 IOninja pukku: yes:  if $foo
19:20 SmokeMachine m: sub bla(:$a) {say $a}; &bla.signature.params[0].set_default({1234}); bla # why that doesn't work?
19:20 camelia rakudo-moar 3046d5: OUTPUT: «(Any)␤»
19:21 IOninja raschipi: I think that's just append using +foo signature, so 1-item list with an iterable is used a 1 iterable
19:21 pukku And that doesn't run into any problems if $foo is 0?
19:21 pukku (or rather, '0')
19:21 IOninja pukku: no, we have sane bool
19:21 pukku Yay! That makes me really happy!
19:22 IOninja pukku:    if ("0") { print "I am a Perl 6 program\n" } else { print "I am a Perl 5 program\n" }
19:22 IOninja :)
19:22 IOninja prints Perl 6 or Perl 5 depending on whether you run it with p6 or p5
19:23 Cabanossi joined #perl6
19:24 [Coke] rjbs: hello en passant
19:24 IOninja I often find myself reaching for a 1-char version of `$_ ~~`
19:24 naxieAlDle c: 2015.03 if ("0") { print "I am a Perl 6 program\n" } else { print "I am a Perl 5 program\n" }
19:24 committable6 naxieAlDle, ¦2015.03: «I am a Perl 5 program»
19:24 naxieAlDle :P
19:24 IOninja :)
19:25 pukku m: if ("0") { print "I am a Perl 6 program\n" } else { print "I am a Perl 5 program\n" }
19:25 camelia rakudo-moar 3046d5: OUTPUT: «I am a Perl 6 program␤»
19:25 pukku Ok, just wanted to double-check...
19:25 pukku What does the "c" bot do?
19:25 IOninja So you'd write something like $foo andthen ⭐'foo'
19:25 IOninja or whatever
19:25 IOninja pukku: executes code on a particular commit.
19:25 IOninja pukku: there it shows that in 2015.03 release Perl 6 still had weird bool for strings :)
19:26 pukku got it
19:26 IOninja That was pre-first-stable-release
19:26 naxieAlDle pukku: oh, committable! It's a bot from whateverable family. We have built rakudo on a bunch of commits (more than 3000 builds in total), and there are a couple of bots that do interesting stuff with these builds!
19:27 IOninja .grep({!⭐/foo/})
19:27 IOninja etc
19:27 naxieAlDle pukku: arguably, the most useful of them is bisectable, which lets you find which commit caused a regression
19:28 naxieAlDle or… you can use it as a general tool to search for interesting commits :)
19:28 naxieAlDle bisect: say 5 ≤ 10
19:28 bisectable6 naxieAlDle, Bisecting by exit code (old=2015.12 new=3046d57). Old exit code: 1
19:28 bisectable6 naxieAlDle, bisect log: https://gist.github.com/23ac1920b32435c06b62810ed6d57a11
19:28 bisectable6 naxieAlDle, (2017-03-05) https://github.com/rakudo/rakudo/commit/d2c5684e50a2f4a633b6595d0e4ed445de7a6703
19:28 naxieAlDle ;)
19:29 RabidGravy ^ :)
19:29 IOninja What do :raised_hands: do?
19:29 naxieAlDle IOninja: celebrate the addition
19:29 IOninja weird
19:30 RabidGravy Yes it does seem that I have written a lot of Perl 6 code
19:30 naxieAlDle u: ????
19:30 unicodable6 naxieAlDle, U+1F64C PERSON RAISING BOTH HANDS IN CELEBRATION [So] (????)
19:30 naxieAlDle IOninja: it's not just hands, by the way
19:30 naxieAlDle but it could very well be that it is rendered as just hands :'(
19:30 IOninja lol, never seen a human do that.
19:31 naxieAlDle \o/
19:31 IOninja It's more of a "Don't shoot. I surrender" thing
19:31 TimToady canadians are so repressed...
19:31 TimToady and oppressed, apparently...
19:31 IOninja That emoji looks more like |o|
19:31 naxieAlDle IOninja: https://irclog.perlgeek.de/perl6/2017-02-27#i_14172874
19:31 TimToady touchdown!
19:31 naxieAlDle oh
19:32 naxieAlDle |ₒ|
19:33 IOninja naxieAlDle: http://i.imgur.com/NbnhLMY.png
19:33 naxieAlDle IOninja: BWAHAHAHA. Well, not it makes sense ×D
19:33 naxieAlDle now*
19:34 SmokeMachine m: sub bla(:$a = 42) {say $a}; my &d = {"12345"}; &bla.signature.params[0].set_default(&d); say &bla.signature.params[0].default === &d; bla
19:34 camelia rakudo-moar 3046d5: OUTPUT: «True␤42␤»
19:34 SmokeMachine default isn't being used?
19:35 SmokeMachine m: sub bla(:$a) {say $a}; my &d = {"12345"}; &bla.signature.params[0].set_default(&d); say &bla.signature.params[0].default === &d; bla
19:35 camelia rakudo-moar 3046d5: OUTPUT: «True␤(Any)␤»
19:38 CIAvash m: say <foo bar>.grep({!/foo/}) # IOninja ?
19:38 camelia rakudo-moar 3046d5: OUTPUT: «(bar)␤»
19:39 SmokeMachine m: sub bla(:$a = 42) {say $a}; say &bla.signature.params[0]; &bla.signature.params[0].set_default({1234}); say &bla.signature.params[0]; bla
19:39 camelia rakudo-moar 3046d5: OUTPUT: «:$a = 42␤:$a = -> ;; $_? is raw { #`(Block|52153896) ... }␤42␤»
19:41 IOninja CIAvash: yeah; it's just a bad example because `//` already uses $_ without needing smartmatching
19:42 CIAvash yeah
19:43 SmokeMachine lizmat: ^^
19:43 SmokeMachine lizmat: any idea?
19:43 IOninja CIAvash: there are 658 instances of $_ ~~ in our ecosystem
19:43 IOninja Though some are bogus, like $foo where $_ ~~ ''
19:44 pukku Is there documentation of =finish blocks, or whatever is going to replace =data blocks?
19:45 IOninja pukku: don't know, but they might be in the Pod section.
19:46 IOninja m: https://gist.github.com/zoffixznet/18e97564844b4065ad0f75a5761823e8
19:46 camelia rakudo-moar 3046d5: OUTPUT: «36␤46656␤46656␤2␤2␤2␤2␤»
19:46 SmokeMachine Im trying to find where the default value of a parameter is gotten and passed to the function... anyone know where can I find it?
19:46 IOninja Any comments on my ^ fix for https://rt.perl.org/Ticket/Display.html?id=130891#ticket-history ?
19:46 IOninja Looks insane... but it works :/
19:46 pukku I looked there, and didn't find either word. All that I have is from the old synopses, and the way they describe =data blocks doesn't work. But the =finish sort of works, so I'll just use that...
19:47 CIAvash IOninja: I think there was a time I had the same thought. Like how `when` makes it easy.
19:48 IOninja jnthn: you around? Is this a bad idea? Bind signature from one thing to another: https://gist.github.com/zoffixznet/18e97564844b4065ad0f75a5761823e8
19:49 sufrostico joined #perl6
19:50 sufrosti1o joined #perl6
19:52 moritz IOninja: won't that mess up scoping and such?
19:53 IOninja I've no idea.
19:53 IOninja It passes the stresstest... but... that probably doesn't say much.
19:54 IOninja What's weirder is that the signature becomes ($a, $b), but the routine uses |args capture to refer to args.
19:55 IOninja I think I'll just comment a diff on a ticket and won't commit anything. Has a proper evil feel to it :)
19:56 rurban1 joined #perl6
20:00 sufrosti1o joined #perl6
20:00 labster joined #perl6
20:00 IOninja Commented: https://rt.perl.org/Ticket/Display.html?id=130891#txn-1453120
20:01 IOninja And thank you RT for messing up Unicode chars -_-
20:01 moritz leanpub also messed up my Unicode chapter :(
20:02 moritz I had to change some examples, and in some cases use some pretty boring scripts to illustrate my points
20:02 IOninja heh
20:02 naxieAlDle IOninja: if you put it in the title, it just cuts it right off
20:02 skids joined #perl6
20:03 sufrostico joined #perl6
20:03 naxieAlDle (e.g. #129259)
20:03 synopsebot6 Link:  https://rt.perl.org/rt3//Public/Bug/Display.html?id=129259
20:03 vendethiel joined #perl6
20:04 IOninja m: say ‘????’.uniname
20:04 camelia rakudo-moar 3046d5: OUTPUT: «BUTTERFLY␤»
20:04 IOninja It's a Fly! It's Butter! It's BUTTERFLY!
20:05 cdg joined #perl6
20:07 moritz m: say '2017-01' .. '2017-05'
20:07 camelia rakudo-moar 3046d5: OUTPUT: «"2017-01".."2017-05"␤»
20:07 moritz m: say list '2017-01' .. '2017-05'
20:07 camelia rakudo-moar 3046d5: OUTPUT: «(2017-01 2017-02 2017-03 2017-04 2017-05)␤»
20:07 moritz m: say list '2016-12' .. '2017-05'
20:07 camelia rakudo-moar 3046d5: OUTPUT: «(2016-12 2016-13 2016-14 2016-15 2016-02 2016-03 2016-04 2016-05 2017-12 2017-13 2017-14 2017-15 2017-02 2017-03 2017-04 2017-05)␤»
20:09 raschipi Something is fucky...
20:11 cdg joined #perl6
20:11 IOninja each char goes to its char
20:11 TEttinger joined #perl6
20:11 IOninja m: say list '1126-12' .. '2017-11'
20:11 camelia rakudo-moar 3046d5: OUTPUT: «(1126-12 1126-11 1127-12 1127-11 1116-12 1116-11 1117-12 1117-11 1026-12 1026-11 1027-12 1027-11 1016-12 1016-11 1017-12 1017-11 2126-12 2126-11 2127-12 2127-11 2116-12 2116-11 2117-12 2117-11 2026-12 2026-11 2027-12 2027-11 2016-12 2016-11 2017-12 2017-…»
20:12 cdg joined #perl6
20:13 cdg_ joined #perl6
20:13 IOninja m: say ["1126-12" .. "2017-11"] eqv ["1126-12" ... "2017-11"]
20:13 camelia rakudo-moar 3046d5: OUTPUT: «True␤»
20:13 IOninja .oO( toss char Ranges; split Range to Int and Non-Int )
20:14 cdg_ joined #perl6
20:15 rurban2 joined #perl6
20:16 IOninja m: say ["2126-12" .. "2017-11"] eqv ["2126-12" ... "2017-11"]
20:16 camelia rakudo-moar 3046d5: OUTPUT: «False␤»
20:17 cdg joined #perl6
20:17 cdg_ joined #perl6
20:18 eroux joined #perl6
20:18 IOninja m: say "1117-11" ~~ "1126-12" .. "2017-11"
20:18 camelia rakudo-moar 3046d5: OUTPUT: «False␤»
20:18 IOninja m: say "1117-11" ∈ "1126-12" .. "2017-11"
20:18 camelia rakudo-moar 3046d5: OUTPUT: «True␤»
20:18 IOninja Looks like smartmatch is busted.
20:19 IOninja s: "1126-12" .. "2017-11", 'ACCEPTS', \("1117-11")
20:19 SourceBaby IOninja, Sauce is at https://github.com/rakudo/rakudo/blob/3046d57/src/core/Range.pm#L419
20:21 IOninja m: dd [ (not "1117-11" before "1126-12"), (not "1117-11" after "2017-11") ]
20:21 camelia rakudo-moar 3046d5: OUTPUT: «[Bool::False, Bool::True]␤»
20:21 IOninja well there's ya problem!
20:21 IOninja yar? yo?
20:22 moritz awwaiid: I'm trying to trace the origins of the Perl 6 matplotlib example, and so far https://gist.github.com/awwaiid/ef3f0abcfa96e34977b4 was the earliest I found
20:23 moritz awwaiid: was the your idea?
20:23 DrForr "yer" traditionally :)
20:23 IOninja Gonna try to make a module that breaks up Range to Int, Numeric, and... Weird... That forest of ?? and !! will fall
20:23 IOninja DrForr: thanks.
20:23 IOninja Gonna try... in summer I mean.
20:30 IOninja Filed: https://rt.perl.org/Ticket/Display.html?id=130959
20:30 IOninja NeuralAnomaly: status
20:30 NeuralAnomaly IOninja, [✘] Next release will be in 1 week and 2 days. Since last release, there are 42 new still-open tickets (2 unreviewed and 1 blockers) and 44 unreviewed commits. See http://perl6.fail/release/stats for details
20:30 IOninja 42 tickets \o/
20:30 IOninja m: say WHY 'Life, The Universe and Everything':
20:30 camelia rakudo-moar 3046d5: OUTPUT: «(Any)␤»
20:31 IOninja m: say WHY 'Life, the Universe and Everything':
20:31 camelia rakudo-moar 3046d5: OUTPUT: «42␤»
20:35 vendethiel- joined #perl6
20:36 jnthn IOninja: Signatures are used for the binding slow-path in Moar, and interpreted on JVM. So that has potential to get...very "interesting"
20:37 jnthn (As in, break explosively)
20:38 jnthn IOninja: Safer would be to mix in a role FakesSignature or so
20:38 jnthn Which would override the .signature, .count, and .arity methods
20:39 IOninja Thanks.
20:39 jnthn Leaving the original $!signature which other things need intact.
20:40 jnthn But changing it for those things introspecting from the outside
20:40 samcv m: say 'sta' ~~ m:i/st/
20:40 camelia rakudo-moar 3046d5: OUTPUT: «「sta」␤»
20:40 IOninja Will try that some time soon.
20:41 IOninja m: say 'stan' ~~ m:i/st/
20:41 camelia rakudo-moar 3046d5: OUTPUT: «「sta」␤»
20:42 IOninja the Cursor position gets messed up looks like; due to "st".fc.chars being 2 instead of 1
20:42 samcv m: say "st T" ~~ m:i/T/;
20:42 camelia rakudo-moar 3046d5: OUTPUT: «False␤»
20:42 samcv well i fixed that one at least
20:42 samcv on my own build
20:42 IOninja sweet samcv++
20:42 samcv it's pretty rough but i am making progress
20:43 firefish5000 joined #perl6
20:46 samcv m: say "aaaastaaa" ~~ m:i/st/;
20:46 camelia rakudo-moar 3046d5: OUTPUT: «「s」␤»
20:46 samcv bisectable6, say "aaaastaaa" ~~ m:i/st/;
20:46 bisectable6 samcv, Bisecting by output (old=2015.12 new=3046d57) because on both starting points the exit code is 0
20:46 bisectable6 samcv, bisect log: https://gist.github.com/1f6c6a843537f7b656885ef3f36aa20e
20:46 bisectable6 samcv, (2017-03-08) https://github.com/rakudo/rakudo/commit/f73d98473825461a35d193f501c91256ce639197
20:48 samcv weird it shows that commit
20:49 IOninja bisect: old=26e6993bd82 say "aaaastaaa" ~~ m:i/st/;
20:49 bisectable6 IOninja, Bisecting by output (old=26e6993 new=3046d57) because on both starting points the exit code is 0
20:49 bisectable6 IOninja, bisect log: https://gist.github.com/f22f777fee7d1b9c8be81cfa7af0f1d0
20:49 bisectable6 IOninja, (2017-03-08) https://github.com/rakudo/rakudo/commit/f73d98473825461a35d193f501c91256ce639197
20:49 lichtkind__ joined #perl6
20:49 IOninja c: f73d9847382~1 say "aaaastaaa" ~~ m:i/st/;
20:49 committable6 IOninja, ¦f73d9847382~1: «False»
20:49 IOninja c: f73d9847382 say "aaaastaaa" ~~ m:i/st/;
20:49 committable6 IOninja, ¦f73d984: «「s」»
20:49 IOninja Geth: ver https://github.com/rakudo/rakudo/commit/f73d9847382
20:49 Geth IOninja, version bump brought in these changes: https://github.com/perl6/nqp/compare/2017.02-61-g3d6948a...2017.02-65-g4c0f698
20:50 samcv m: say "a st" ~~ m:i/st/;
20:50 camelia rakudo-moar 3046d5: OUTPUT: «False␤»
20:50 samcv ok i just have to fix this case here
20:50 samcv plus there's it incorrectly giving back only one character when you do m:i/st/ but that's a different issue though same cause of the problem
20:53 raschipi Is that an "st" ligature as an Unicode char? Isn't that supposed to be part of the font? Is there a language that treats 'st' different from 'st'?
20:53 raschipi u: st
20:53 unicodable6 raschipi, U+FB06 LATIN SMALL LIGATURE ST [Ll] (st)
20:54 moritz well yes, a German teacher will mark it as an error if you use the ligature in German text :-)
20:54 Cabanossi joined #perl6
20:59 lizmat m: sub bla(:$a = 42) {say $a}; BEGIN say &bla.signature.params[0].default; BEGIN &bla.signature.params[0].set_default({1234}); BEGIN say &bla.signature.params[0].default; say &bla.signature.params[0].default; bla   # SmokeMachine
20:59 camelia rakudo-moar 3046d5: OUTPUT: «-> ;; $_? is raw { #`(Block|58947920) ... }␤-> ;; $_? is raw { #`(Block|58948424) ... }␤-> ;; $_? is raw { #`(Block|58948424) ... }␤42␤»
21:00 lizmat SmokeMachine: so it *does* change the default value correctly if you do it at compile time
21:00 dct joined #perl6
21:00 lizmat and that's the value you see at runtime as well
21:01 lizmat feels like there's some optimization at work here
21:01 SmokeMachine m: sub bla(:$a = 42) {say $a}; BEGIN say &bla.signature.params[0].default.WHERE; BEGIN &bla.signature.params[0].set_default({1234}); BEGIN say &bla.signature.params[0].default.WHERE; say &bla.signature.params[0].default.WHERE; bla
21:01 camelia rakudo-moar 3046d5: OUTPUT: «140416596895552␤140416567823856␤140416567823856␤42␤»
21:02 jnthn If you're going to manipulate a signautre you must do it at compile time.
21:02 SmokeMachine m: sub bla(:$a) {say $a}; BEGIN say &bla.signature.params[0].default.WHERE; BEGIN &bla.signature.params[0].set_default({1234}); BEGIN say &bla.signature.params[0].default.WHERE; say &bla.signature.params[0].default.WHERE; bla
21:02 jnthn (If you're doing it to something that exists at compile time)
21:02 camelia rakudo-moar 3046d5: OUTPUT: «41428280␤139648216589752␤139648216589752␤(Any)␤»
21:02 jnthn We compile most signatures, not interpret them
21:02 SmokeMachine lizmat: yes, it changes... but I don't receive it on the function...
21:02 jnthn So by runtime what's in the Signature object is irrelevant
21:03 jnthn That compilation happens at the closing curly of the sub
21:03 SmokeMachine jnthn: hum... thats why!
21:03 SmokeMachine jnthn: any way to change it?
21:03 jnthn No.
21:03 jnthn Well
21:03 moritz you could write a trait
21:03 jnthn At BEGIN time you can of course
21:03 moritz that should run early enough, no?
21:03 jnthn Yes, traits run at BEGIN time
21:04 jnthn I figured the question is "can I have it always interpret the signature"
21:04 jnthn To which the answer is certainl no
21:04 jnthn *certainly
21:04 cdg joined #perl6
21:05 jnthn Pretty sure if you put routine traits on the subroutine they have the signature object available, so you've got both parameter traits and routine traits as options
21:05 SmokeMachine jnthn: on the last example I changed the signature at compile time but it didn't change (by it I mean what the function received...)
21:06 jnthn You changed it too late
21:06 jnthn < jnthn> That compilation happens at the closing curly of the sub
21:06 jnthn The BEGIN is after the }
21:06 jnthn Do I want to ask why you're trying to do this? :)
21:06 lizmat jnthn: yeah, but I think that's the point: to be able to do it *after* the sub has been compiled    :-)
21:07 jnthn OK, then "not unless you write a slang"
21:07 jnthn But why not just put it into a trait?
21:07 raschipi Ele tá muito loco.
21:07 jnthn Note that your trait could just install a closure as the default which then grabs the value from somewhere you *can* change at runtime
21:09 SmokeMachine m: multi trait_mod:<is>(Routine:D $r, :$bla!) {&bla.signature.params[0].set_default({1234})}; sub bla(:$a) is bla {say $a.VAR}; bla # jnthn: something like this?
21:09 camelia rakudo-moar 3046d5: OUTPUT: «Any␤»
21:10 jnthn Something like
21:10 jnthn Why the .VAR?
21:10 SmokeMachine m: multi trait_mod:<is>(Routine:D $r, :$bla!) {&bla.signature.params[0].set_default({1234})}; sub bla(:$a) is bla {say $a}; bla # jnthn: something like this?
21:10 camelia rakudo-moar 3046d5: OUTPUT: «(Any)␤»
21:10 SmokeMachine jnthn: sorry...
21:10 jnthn Oh, and use $r in the trait, not bla
21:10 SmokeMachine sure!
21:10 jnthn Then you can apply the trait on whatever routine you want
21:11 SmokeMachine m: multi trait_mod:<is>(Routine:D $r, :$bla!) {$r.signature.params[0].set_default({1234})}; sub bla(:$a) is bla {say $a}; bla
21:11 camelia rakudo-moar 3046d5: OUTPUT: «(Any)␤»
21:11 SmokeMachine but it isn't working...
21:11 jnthn Hmm
21:11 SmokeMachine i am not getting 1234...
21:12 jnthn I...wonder if that's thanks to the compiler having its own internal data structure for Parameter as well as the object...
21:13 jnthn Ah, yeah, it is
21:13 jnthn .oO( 8 years is plenty long enough for a compiler to have legacy code... :P )
21:14 itaipu joined #perl6
21:14 cdg_ joined #perl6
21:14 jnthn SmokeMachine: I can fix this case relatively easy
21:14 jnthn Though gotta head afk for a bit soon
21:15 SmokeMachine jnthn: :) I'd like to read that commit
21:18 jnthn Totally untested patch: https://gist.github.com/jnthn/9e43772eef65d86d42c9a6526418c9b2
21:18 jnthn Feel free to try it...I'll bbiab :)
21:21 SmokeMachine compiling...
21:23 ggoebel joined #perl6
21:31 moritz https://gist.github.com/moritz/54e2fb94687784679eb1f053bbd40dcc I can't seem to make Inline::Python return a date object; what's wrong here?
21:32 * moritz probably too tired
21:32 moritz the weird thing is: if I pass too few arguments to datetime.date, it complains
21:32 moritz but still it returns Any?
21:34 robertle do the supplies of IO::Socket::Async (e.g. "listen" or "Supply") have any guarantees around concurrency? e.g. would you only ever get one these called at the same time per socket? or do you need to ensure that yourself (e.g. with "whenever")?
21:34 bjz joined #perl6
21:38 lizmat whenever has .act semantics, so that should insure you against any concurrency issues
21:38 lizmat but could you elaborate with some code?
21:40 robertle understand the whenever beahvior. but for example the simple code at the top of https://docs.perl6.org/type/IO::Socket::Async, second code block
21:40 robertle that wraps the listen and Supply into a single "react", so serializing everything on that server
21:41 robertle that seems to be quite serial to me, I am wondering if e.g. a HTTP server shouldn't allow concurrent stuff to happen on unrelated sockets
21:41 robertle so I am looking at https://github.com/perl6/perl6-http-server-async/blob/master/lib/HTTP/Server/Async.pm6
21:41 robertle to learn a bit more
21:42 robertle this does not use "whenever", but does some other stuff that is moderately nasty
21:42 robertle and quite frankly I am not even sure that this is safe or complete
21:42 robertle for example I am wondering if there isn't a concurrent modification race around @!connects
21:43 robertle so I am wondering if there are some guarantees already built into IO::Socket::Async
21:43 sufrostico joined #perl6
21:43 sufrosti1o joined #perl6
21:45 pukku I know that I can use Perl 5 and Text::VimColor to get an HTML colorized version of Perl 6 code. But is there an equivalent to Perl::Tidy for reformatting code? I'm looking for something to line up my assignments, regularize whitespace, etc...
21:47 SmokeMachine jnthn:  https://www.irccloud.com/pastebin/vvHicvao/
21:48 Todd joined #perl6
21:49 skids Who's a rakudo "braid" internals expert?
21:49 yoleaux 08:16Z <TimToady> skids: you want something like https://gist.github.com/TimToady/df87901b812e4ac0d44e5b5240bcf77d
21:49 yoleaux 09:26Z <TimToady> skids: With 44b60a560d that I just checked in, you should be able to work with just the .define_slang, if you don't care to support old versions.  note that you do still have to do the mixins; you can't just pass bare roles to .define_slang, though maybe we could support that...
21:49 sufrostico joined #perl6
21:49 Todd Hi All,  I am trying to learn "use NaticeCall;".  Would someone mind translating this call into perl6 (reference "man XDisplayName"):
21:49 Todd char *XDisplayName(char *string);
21:50 Todd K am reading https://docs.perl6.org/language/nativecall, but not understand a lot of it, so an example would be appreciated
21:51 lizmat robertle: jnthn would be the person to really ask this
21:53 robertle currently a HTTP::Server::Async seems to only emit stuff from the "Supply" tap after the previous one has been finished. but I do wonder if that is guaranteed or an accident...
21:53 IOninja pukku: I think DrForr is working on that
21:54 robertle for example: https://gist.github.com/robertlemmen/56ff110b3c57b3368064e4098bc9129e
21:54 pukku Thanks -- that means it probably won't be ready for next week (I'm trying to give a short talk with some Perl 6), so I'll just format it by hand...
21:54 robertle you can then connect and send two pieces of data (same socket). they do get handled by diufferent threads, but sequentially
21:54 IOninja Todd: know nothing about native call, but a wild guess would be:   sub XDisplayName(Str --> Str) is native {}
21:55 IOninja pukku: there's Facebook post that says "Also a Perl6::Tidy comment stripper takes 5 lines of code. Including I/O."... but no links to any code :/
21:56 IOninja skids: TimToady probably. He's been doing all the recent braids work.
21:56 skids IOninja: thanks.
21:57 Todd I am not sure how to put "char *XDisplayName(char *string);" into "sub XDisplayName() is native('something') { * };"
21:58 Todd This is inline C, I presume
21:59 moritz Todd: if you're looking for working NativeCall examples, I can recommend looking into the DBIish source code
22:00 lizmat Todd: supposing the name of the library providing the "XDisplayName" is "libX11", then 'is native("X11")' should do the trick
22:01 lizmat provided that library is installed on your system, of course
22:01 Todd I have seen this code.  I don't understand it.  So I was trying to figure out how do "char *XDisplayName(char *string);", which is somethign I need.  DBIsh will be great if I ever need to talk SQL though
22:02 IOninja Todd: have you tried my suggestion?
22:02 skids .tell TimToady 44b60a560d did the trick.  Not that I'll be yanking the "old way" code just I instinctively tested the "new way".  Thanks.
22:02 yoleaux skids: I'll pass your message to TimToady.
22:02 moritz Todd: you complained about a lack of examples in the docs; I pointed out more examples
22:02 moritz Todd: sometimes I think you aren't *really* trying to understand stuff yourself
22:02 lizmat robertle: have you tried using .act instead of .tap ?
22:02 pukku Thanks to everyone who helped me earlier today, especially IOninja -- have a great night!
22:03 lizmat .act ensures it only gets run by one thread at a time
22:03 IOninja You too.
22:03 Todd So far I have "sub XDisplayName() is native ('X11') {}" but I still don't know how to inline the C code
22:04 Todd where does the "char *XDisplayName(char *string);" go?
22:04 IOninja Todd: nowhere. You translate that to Perl 6 types and NativeCall's types
22:05 sufrostico joined #perl6
22:05 IOninja Todd: there's a converstion table here: https://docs.perl6.org/language/nativecall#Passing_and_Returning_Values
22:05 lizmat IOninja: sadly, char * is not in that list ?
22:05 IOninja Todd: and I *think* char * is Str
22:06 IOninja Or maybe not... "Str            (C string)"  is char * a C string?
22:06 lizmat sub XDisplayName(Str:D $name) is native ('X11') { * }
22:06 lizmat if what IOninja said is correct
22:06 jnthn SmokeMachine: Hmmm...odd
22:06 lizmat timotimo:  ^^ comments ?
22:07 * IOninja &
22:07 Todd mortiz: I am weird in the the way I learn.  That is why I am looking for an example of something I need
22:08 Todd "sub XDisplayName(Str:D $name) is native ('X11') { * }"  what is "*" and what is "Str:D $name""
22:08 jnthn SmokeMachine: Oh, maybe I should have checked if it's Code rather than Block
22:09 lizmat * is Whatever: in this context it means: take whatever is in the mentioned external library and execute that
22:10 lizmat Str:D means: only accept defined Str objects as a parameter
22:10 Todd Okay, so "*" is litterally "*"
22:10 Todd looking at "https://docs.perl6.org/language/nativecall#Passing_and_Returning_Values".  It is going right over my head.
22:11 lizmat m: dd *.WHAT
22:11 camelia rakudo-moar 149286: OUTPUT: «Whatever␤»
22:11 sufrosti1o joined #perl6
22:12 Todd I still can't figure out where to put the "char *XDisplayName(char *string);"
22:12 lizmat Todd: you don't
22:12 lizmat you will not need to write any C code
22:12 lizmat that's beauty of NativeCall
22:12 lizmat *the
22:13 Todd now I am confused.  It can read my mind?  How does it know want that particular function from X11?
22:13 lizmat because of the name you gave the sub
22:14 lizmat it will look for that name in the X11 lib
22:14 lizmat *tha* name
22:14 lizmat *that*   *sigh*  :-)
22:14 Todd I thought that was arbitrary.  Now I understand.  Thank you!
22:14 lizmat if you want, you can use another name with "is symbol"
22:15 lizmat sub display-name(Str:D $name) is native ('X11') is symbol("XDisplayName" { * }
22:15 lizmat sub display-name(Str:D $name) is native ('X11') is symbol("XDisplayName") { * }
22:17 lep-delete joined #perl6
22:17 Todd Ah poop.   "sub XDisplayName(Str:D $name) is native ('X11') { * }" gives "Missing block at /home/linuxutil/./X11Display.pl6:14 ------> sub XDisplayName(Str:D $name) is native⏏ ('X11') { * }"
22:19 Todd lizmat: thank yo for the symbol example.  Now I understand
22:20 lizmat Todd: can't have a space between native and ("X11")
22:21 Todd Just figured that out.  Thank you!
22:21 Todd More errors.
22:21 Todd Calling XDisplayName() will never work with declared signature (Str:D $name)   in method CALL-ME at /usr/share/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) line 326   in block <unit> at ./X11Display.pl6 line 16
22:22 Todd Now what is wrong?
22:22 lizmat m: sub a(Str:D $a) {}; a()   # basically what's happening
22:22 camelia rakudo-moar 149286: OUTPUT: «Too few positionals passed; expected 1 argument but got 0␤  in sub a at <tmp> line 1␤  in block <unit> at <tmp> line 1␤␤»
22:23 lizmat m: multi sub a(Str:D $a) {}; a()   # basically what's happening
22:23 camelia rakudo-moar 149286: OUTPUT: «5===SORRY!5=== Error while compiling <tmp>␤Calling a() will never work with any of these multi signatures:␤    (Str:D $a)␤at <tmp>:1␤------> 3multi sub a(Str:D $a) {}; 7⏏5a()   # basically what's happening␤»
22:24 Todd I am calling the sub with "my $Display = XDisplayName();" which is the line16 it is complaining about
22:24 lizmat Todd: if you declare a sub to take one Str:D parameter, and then write code that will call it without any parameters, rakudo will tell you that it can nevcer work
22:24 lizmat *never
22:24 Ven joined #perl6
22:25 Todd Short between the headsets.  I was thinking it was a return function.  "my $Display; XDisplayName( $Display );" fixes it.
22:26 Todd Wow.  I feel like I just expereinced two days i a class room environment.  Thank you all!  Now I am "dangerous!"
22:26 lizmat Todd: with great power comes great responsibility  :-)
22:27 robertle another question around IO::Socket::Async: can I close() a socket from another thread safely? what about events happening on it at the same time?
22:28 lizmat robertle: which thread does what *should* not matter
22:28 lizmat robertle: but I'm not 100% sure we're there yet  :-)
22:28 Todd Hmmm.  I am getting "uninitialized value $Display" coming back from the sub.  It should be something like ":0.0"
22:28 Todd $ echo $DISPLAY
22:28 Todd :0.0
22:29 Todd Now what am I doing wrong?
22:29 jnthn SmokeMachine: Just checked; if you change Block for Code in my suggested patch it's happy
22:30 jnthn robertle: Yes, you can close it from any other thread safely, though anything that tries to write to it after close will end up with an broken Promise from the write
22:30 lizmat Todd: looking at interface doc at https://tronche.com/gui/x/xlib/event-handling/protocol-errors/XDisplayName.html
22:30 robertle lizmat: that sounds promising!
22:30 jnthn Though that has to be handled anyway because the client could close the connection.
22:30 robertle jnthn: that sounds almost perfect
22:31 lizmat it appears to also return a Str
22:31 mcmillhj joined #perl6
22:31 jnthn lizmat: In terms of safely for IO::Socket::Async and Proc::Async, we run a signle libuv event loop and dispatch all operations over to it
22:31 lizmat sub XDisplayName(Str:D $name) is native ('X11') returns Str { * }
22:32 jnthn lizmat: So we're pretty safe on that front :)
22:32 lizmat Todd:  ^^^ could you try that ?
22:32 SmokeMachine jnthn: I'll do that when I arrive home
22:34 Todd remoed the space after native.  Returns and unitialized variable
22:34 Todd no joy
22:36 jnthn SmokeMachine: OK; I ran a spectest of the patch and it came out OK
22:36 Todd figured it out.  Give me a moment
22:38 mcmillhj joined #perl6
22:43 Todd And it is a bit weird.
22:43 Todd sub XDisplayName(Str:D $name) is native('X11') returns Str { * };
22:43 Todd my $Display; my $RtnStr;
22:43 Todd $Display = XDisplayName( $RtnStr );
22:43 Todd print "\$Display = <$Display>   \$RtnStr = <$RtnStr>\n";
22:44 Voldenet joined #perl6
22:44 Voldenet joined #perl6
22:44 Todd Here is what is wierd.  I have to use $RtnStr in the () or it does to work.  Nothing gets put in $RtnStr either.  How do I get rid of $RtnStr?
22:45 robertle another concurrency question: if I change not an object, but a variable/binding, what does that mean in a concurrent context?
22:45 robertle so if I have a my $var = Foo.new;
22:46 robertle and then do $var = Foo.new() on another thread, is that safe?
22:46 Sound joined #perl6
22:46 lizmat robertle: make sure that that happens only in one thread at a time
22:46 lizmat robertle: ah, in that way
22:46 lizmat each thread has its own lexical scope
22:46 robertle lizmat: youa re saying that modifying a variable/binding is not safe across threads?
22:46 lizmat so as long as the $var is local to the thread's scope, you're ok
22:46 robertle right
22:46 lizmat otherwise, you'll have a race condition
22:47 robertle ok, so looking at https://github.com/perl6/perl6-http-server-async/blob/master/lib/HTTP/Server/Async.pm6 again
22:47 lizmat start { my $var = Foo.new }   # ok
22:47 robertle that modifies @!connects from various threads
22:47 lizmat my $var; start { $var = Foo.new }    # BAD BAD BAD
22:48 robertle it creates a new object, so there isn't a concurrent modification of a value, but the binding changes... is that not safe then?
22:49 lizmat robertle: but it does it inside a protect block
22:50 Todd figured it out.  from https://tronche.com/gui/x/xlib/event-handling/protocol-errors/XDisplayName.html, "If a NULL string is specified, XDisplayName() looks in the environment for the display and returns the display name that XOpenDisplay() would attempt to use"
22:50 Todd So I changed $RtnStr to $NullStr so I could see what I was doing
22:51 robertle lizmat: on line 37 yes, but e.g. line 69 accesses the same variable from a different thread, and does not take the lock
22:51 lizmat robertle: I think you just exposed a race condition there
22:52 robertle lizmat: great, because that used to confuse the hell out of me!
22:52 lizmat the .tap in line 65 should probably be an .act
22:52 lizmat jnthn: ^^^ do you agree?
22:53 Todd Thank you guy!  Now I am really dangerous!!!  Got to go.  Bye Bye.
22:53 lizmat Todd: not all of the guys here are guys  :-)
22:54 El_Che :)
22:54 Todd So I have to watch the swearing?
22:54 robertle lizmat: how does turning that into an .act solve the problem? that does not protect against concurrent access by line 37 (right?)
22:54 Cabanossi joined #perl6
22:55 lizmat Todd: depends  :-)
22:55 lizmat robertle: that would prevent concurrent access to @!connects in listen
22:55 bwisti joined #perl6
22:56 jnthn lizmat: The stream of incoming connections is actually a serial Supply
22:56 lizmat jnthn: ah, didn't know that, so the .tap is fine
22:56 jnthn Yeah. It's kinda presumed that if you are going to have concurrency, per-connection is the valuable place :)
22:57 robertle ok, that is what I was wondering about earlier: are IO::Socket::Async events serial even in the absence of act/whenever
22:58 robertle but the problem here, if I understand it, is the concurrent access by line 37, which is not IO::Socket::Async at all, just start+loop
22:58 robertle but using $l.protect around line 69 should do the trick
22:59 jnthn Yeah
23:00 robertle man, how I hate concurency
23:00 lizmat jnthn: how would that protect access between !timeout and listen ?
23:01 lizmat that would only be the case if they shared the lock
23:01 jnthn lizmat: I was agreeing that 69 needs the lock too
23:01 jnthn (I didn't look at 37 before :))
23:01 lizmat so the lock needs to become an attribute of the object, right ?
23:01 lizmat the HTTP::Server::Async object
23:02 jnthn Yes
23:02 lizmat robertle: time for a PR I guess  :-)
23:03 jnthn tbh I'd probably have written the lot in a react block or something though
23:03 lizmat jnthn: I think this predates react / whenever  :-)
23:03 jnthn Then instead of a thread that sleeps for 1s it'd be whenever Supply.interval(1) { }
23:03 jnthn Yeah, that's fair enough :)
23:04 robertle jnthn: excellent point, because the reason I bring this up is that I can't get my react blocks to work!
23:04 robertle so if I want to write something like this, I need to do timeouts as well
23:04 robertle and they don't come from eth same supply
23:04 robertle ah forget that, I know how to fix that
23:04 robertle but you don't want to do all in the same react block, right? otherwise you loose al concurrency
23:05 robertle and then the timeouts become a problem...
23:05 jnthn Well, can always `start` the per-connection handler
23:06 andrzejku joined #perl6
23:07 jnthn Rest time for me...hopefully I'll sleep a little less awfully tonight
23:07 robertle night!
23:07 jnthn 'night o/
23:29 geekosaur joined #perl6
23:43 mcmillhj joined #perl6
23:46 zakharyas joined #perl6
23:46 unicodable6 joined #perl6
23:49 geekosaur joined #perl6
23:55 Cabanossi joined #perl6
23:59 mcmillhj joined #perl6

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

Perl 6 | Reference Documentation | Rakudo