»ö« Welcome to Perl 6! | perl6.org/ | evalbot usage: 'p6: say 3;' or rakudo:, or /msg camelia p6: ... | irclog: irc.perl6.org or colabti.org/irclogger/irclogger_logs/perl6 | UTF-8 is our friend!
Set by moritz on 22 December 2015.
00:01 wamba joined
grondilu doubts it's possible 00:11
bioduds_ it compiles
and asks for the input
grondilu looks in S19
bioduds_ Usage: ef8a4da32a.pl [--kv=<Associative>] 00:12
but I can't seem to find the correct input syntax on the command line
zengargoyle thinks there's a getopt-ish module. always found MAIN args to be *really* hard for anything but basic strind/bool type things.
grondilu does not find any occurrence of C<:%> in S19
sub MAIN( *%options ) {...} does work 00:15
and it might be what you wanted to do
strangely though, sub MAIN(Str *%options) {...} fails 00:16
zengargoyle but i myself was thinking of asking a similar question about same sort of thing with '@'.
bioduds_ grondilu : how would it be called on the command line?
grondilu perl6 prog.p6 -foo=bar -pi=3.14
it's not a named h
basically you will not use the name of the hash on the command line. You only give the pairs it will be made of. 00:18
bioduds_ let me try 00:19
grondilu there's really not much point in using a named parameter when there is only one parameter, anyway.
(unless you have multiple candidates, of course) 00:20
bioduds_ cool, this works for me
grondilu is glad he could help 00:21
bioduds_ thanks, man 00:23
if you find out later if and how naming the parameter on the MAIN could work, please tell me 00:24
grondilu I keep doubting it's possible. 00:26
you'd have to somehow pass a Perl 6 syntax on the shell command line. That can't fly, can it? 00:27
zengargoyle thinks a HOWTO-MAIN doc is needed. :)
grondilu how MAIN works should be the main subject of a perl6 man page. 00:28
wait, scrap that.
zengargoyle with a bunch of practical-ish examples.
grondilu realizes that not all Perl 6 programs have a MAIN subroutine. 00:29
bioduds_ well, my user-ish role would say: if it's there, there must be a way to use it
anyhow, since this here sub MAIN( *%kv, Str :$new ) { is working 00:30
then it does what I need
grondilu it's kind of special though. MAIN has a Perl 6 syntax but its semantics transcend Perl 6 to go into shell territory.
00:30 canopus left
grondilu so it's not too surprising that there is a mismatch at some point. 00:31
zengargoyle i think the issue is that it's just a standard sub specification and going from 'chunk of text from CLI' -> Perl6-thing.
yeah, that.
grondilu is always happy when he can use the verb "transcend" in a sentence :)
bioduds_ surely, only one hash set so to speak can be captured by this approach 00:32
but it gives a lot of room actually, doesn't it? 00:33
grondilu I don't follow you
00:33 sufrostico left
zengargoyle the slurpy only permits one hash (or array) at end. 00:34
00:37 tushar joined
zengargoyle thinks that going from array of string from CLI to variables is going to take getopt-ish complexity vs simple sub signature. 00:41
otherwise we'd be able to call any P6 sub with and array of strings and have it work. :)
grondilu also, doesn't the correct syntax for a long parameter name in shell requires two and not just one dash? 00:50
like $ dothis --with-parameter=the-parameter 00:51
and $ dothat -x=2
zengargoyle yeah, and Bool have some weird --\name for the false case.
just took a quick peek at perl6-all-modules and found no MAIN that use anything other than :$ 00:52
grondilu is not surprised
anything else would require some form of marshallization, shouldn't it?
s/shouldn't/wouldn't/ 00:53
zengargoyle i once made a :$file that was type checked to IO.r or something but it was crazy hard vs just getting a string and checking myself.
grondilu strings are more or less the only types the shell and Perl 6 have in common. No wonder that's what is used for argument passing between them. 00:54
zengargoyle this all brings back horrible memories of programming where you didn't even get an array of strings but just one string you had to parse yourself. 00:55
grondilu meh, that happened often for me. 00:56
I mean like, unacceptably often.
bioduds_ being able to *%kv is awesome enough
opens up a bunch of opportunities
im already using it
grondilu bioduds_: I would recommend naming it *%options though 00:57
bioduds_ makes no diff, here look: sub MAIN( *%kv, Str :$op ) { with %kv { for %kv.kv -> $key, $value { get-json( WHERE => $key, EQUALS => $value, op => $op ); } } without %kv { get-json; } }
this is what im doing, im treating it right away 00:58
grondilu or even *%command-line-options if you don't mind being verbose.
bioduds_ cause in my case here, im building a key=>value NoSQL system
so the parameters are actually the key and the value to be searched 00:59
so, they are not actually options
grondilu does sub MAIN (*%kv, Str :$op) {...} behaved as you expected? I'm a bit surprised it's even legal.
bioduds_ yes, perfectly
now I can do search for name="Some Name" op="eq" 01:00
and search rate="4.3" op="gt"
works fine
grondilu m: sub (*%h, :$foo) { say %h.perl }(foo => "bar")
camelia rakudo-moar 8aa0aa: OUTPUT«{:foo("bar")}␤»
grondilu m: sub (*%h, :$foo) { say %h.perl, " and ", $foo }(foo => "bar") 01:01
camelia rakudo-moar 8aa0aa: OUTPUT«{:foo("bar")} and bar␤»
grondilu hum... so the argument ends up in both parameters. That's slightly weird.
zengargoyle how many 'op'? 01:02
bioduds_ a few 01:05
zengargoyle m: sub (:$foo, *%h) { say %h.perl, " and ", $foo }(foo => "bar")
camelia rakudo-moar 8aa0aa: OUTPUT«{} and bar␤»
bioduds_ eq, lt, gt, lte, gte
for starters
zengargoyle slurpy should go at end i think.
but makes op need to be first i think. 01:06
bioduds_ what do you mean?
sorry, didn't quite catch what you're trying to say
zengargoyle m: sub (:$foo, *%h) { say %h.perl, " and ", $foo }(foo => "bar", foo => "baz") 01:08
camelia rakudo-moar 8aa0aa: OUTPUT«{} and baz␤»
zengargoyle pondering collison when op is a name for a parameter and a poddible key in kv.... 01:09
bioduds_ oh, yes
zengargoyle thought checking :$op first would grab first --op and *% would get any additional --op... 01:10
bioduds_ perhaps subset Operator where "eq"|"gt"|"lt";
zengargoyle don't seem to work that way. :P
bioduds_ with sub MAIN( *%kv, Operator :$op ) {
zengargoyle yeah, or i was thinking earlier of multi sub MAIN('eq', ...) multi sub MAIN('lt', ...) 01:11
sorta sub-command like.
01:12 Actualeyes joined
zengargoyle but it forces order to your parameters. 01:12
01:13 pierre_ joined
bioduds_ yes 01:13
zengargoyle loves to have a multi sub MAIN('test') in progs.
bioduds_ declarative programming to the rescue! :D
grondilu would rather write it multi sub MAIN(:$test!) 01:16
so that it's called as $ perl6 prog --test
01:17 pierre_ left
mst I like my perl5 solution 01:17
where if it's a module, it loads, and if it's a script, iut runs
see p3rl.org/App::opan
(note i mention this in a spirit of "steal!" not anything else ;) 01:18
grondilu wonders if you can call MAIN inside a MAIN to do recursion.
zengargoyle just another sub. 01:20
grondilu tries. Indeed, just an other sub.
zengargoyle i wonder about multi dispatch tho with :$test! 01:21
vs *@args or somesuch
mst |c is your friend 01:22
zengargoyle always wins?
bioduds_ how would I go about checking if some string meets my subset? 01:23
i mean, introspection
zengargoyle $str ~~ subset
bioduds_ ok, this 01:24
zengargoyle just guess, if is don't work file a LTA bug. :P
bioduds_ unless ($key ~~ Operator) { get-json( WHERE => $key, EQUALS => $value, op => $op ); } }
scott I made a really simple perl6 script I'd like to be able to run as part of my shell, but it consistently takes about 250ms to run. I noticed in --stagestats that the parse stage is consistently slow: "Stage parse : 0.160". is there a way to avoid re-parsing every time, for a simple one-off script? 01:25
part of my shell prompt*
zengargoyle make most of script a module that gets precomipled and then tiny script that uses module? 01:26
scott I wonder if that would even help, considering the script is already tiny
20 lines of uncomplicated code
zengargoyle maybe not.
scott this is the script gist.github.com/solson/c28d547b5d3...ed905dc099 01:27
running it directly with `perl6` is just too slow for my purpose, unless there's some way to make it avoid re-parsing 01:28
bioduds_ now eq, lt, gt, gte, lte are reserved
zengargoyle : also, as you pointed, sub MAIN( Operator :$op, *%kv ) { instead of sub MAIN( *%kv, Operator :$op ) {
zengargoyle scott: IMHO perl6 isn't fast enough yet for *quick* depending on values of *quick*. 01:29
scott startup time is the only thing that really matters here
(which is dominated by parsing) 01:30
zengargoyle yeah, not sure if 'use Foo;Foo::run' is faster than just 'Foo' for 20 lines or not... 01:31
scott it'd be cool if standalone scripts could get precompiled like modules do 01:32
grondilu just make it a module 01:33
zengargoyle i think it's on the wishlist. at least that's what i'm told everytime i bring it up.
scott I'm not familiar with how to make modules yet, and this kind of becomes more inelegant than ruby as soon as it uses more than one file
01:33 eliasr left
grondilu what if you just add 'unit module ::;' on the top? Wouldn't that do precompilation? 01:34
zengargoyle oh, i means script to standalone executable...
scott grondilu: I'll try it
01:34 canopus joined
scott grondilu: seems to have no effect, at least when running `perl6 format-duration.p6` 01:35
grondilu indeed 01:36
scott actually, it had an effect in that MAIN wasn't executed anymore, but parsing was still slow each time
grondilu well, I tried.
a module should execute MAIN though, if called as a program. 01:37
shouldn't it? 01:38
zengargoyle i would suspect not 01:39
grondilu scott: maybe you can compile it with --target=moar or something 01:41
scott that gets me gist.github.com/solson/1e801aef7c3...a75645c63c 01:42
grondilu I don't recall the exact syntax. jnthn once showed me but I forgot. 01:43
I do remember it is possible though.
zengargoyle maybe that changed when things started going into compunitrepos instead of fs. 01:44
or try morevm...
01:45 TEttinger joined, wamba left
grondilu --target=mast do work but it'd be silly to use that. 01:47
zengargoyle --target=mbc --output=file.mbc works.... 01:50
or at least created the file and i don't know how to run it. :P 01:51
grondilu --target=mbc maybe? I can't test it right now I'm compiling rakudo
nope 01:52
scott zengargoyle: yeah, that worked for me 01:55
zengargoyle can't figure out how to run it.... think it takes: moar + some libpaths 01:56
grondilu just copy what the perl6 executable do :)
$ cat $(which perl6) 01:57
scott I managed to get moarvm to segfault attempting that
grondilu oh yeah I forgot you want to feed it with bytecode 01:58
do $ moar --help, I think it tells you to use --dump 01:59
oh no, sorry
zengargoyle Unhandled exception: Could not look up the container config for 'rakudo_scalar' 02:01
grondilu yeah, got the same 02:02
02:07 tushar left 02:08 cbk_ left 02:09 samcv left
bioduds_ grondilu : you're right, this here is better multi sub MAIN( Operator :$op, *%kv ) { for %kv.kv -> $key, $value { unless ($key ~~ Operator) { get-json( WHERE => $key, EQUALS => $value, op => $op ); } } } multi sub MAIN() { get-json; } 02:10
zengargoyle my sorta guess is that file.mbc has to be somehow combined with bootstrap or core or some other mbc to get to the stage where it's directly runnable by moar.
like some ld stage... 02:11
02:12 noganex joined 02:15 noganex_ left
grondilu as I said I vaguely recall jnthn showing it can be done and it was not very complicated. 02:17
02:18 BenGoldberg joined
grondilu though it's possible I'm confusing things 02:18
zengargoyle yeah, one of those things that waiting for somebody who knows to show up is probably faster than trying to figure it out... 02:20
scott thanks for looking into it 02:32
zengargoyle squirrel! 02:33
02:34 johnjohn101 joined
johnjohn101 hi perl6 02:34
zengargoyle it's odd that it's BOOTSTRAP.moarvm where the error pops up.
i'm sorta miff'd that my simple test doesn't work. :P 02:36
turning 'perl6 test.p6' into 'nqp test.nqp' into 'moar test.mbp' into just './test' is a worthy progression. 02:42
02:49 samcv_ joined, samcv_ is now known as samcv 03:00 cowens left 03:10 BenGoldberg left 03:12 kaare_ joined 03:14 johnjohn101 left, pierre_ joined 03:18 flexibeast left 03:19 pierre_ left
awwaiid Just posted blog mentioning Perl 6, thelackthereof.org/TLT/2016.09.23/...he_Methods 03:32
03:37 labster left, luis` joined, kst` joined, canopus left, woolfy left, [1]ringer1 left, noganex_ joined, djbkd_ joined, zhmylove joined, Xliff_ joined, mohae_ joined, setty2 joined, cpage__ joined, bisectable6 left, committable6 left, amalia_ left, leego left, pyrimidine joined, sjohnsen- left, luis left, [particle] left, pdcawley left, kmwallio left, timeless left, setty1 left, camelia left, Timbus left, inokenty left, synopsebot6 left, kmwallio joined, setty2 is now known as setty1, notbenh left, infina left, ringer1 joined, DarthGandalf left, mattp__ joined, Sgeo_ joined, Gothmog_ left, lizmat_ joined, dalek left, labster1 joined, inokenty1 joined, committable6_ joined, bisectable6_ joined, dalek joined, pdcawley_ joined, zhmylove_ left, mattp_ left, TEttinger left, perigrin left, Jonis left, krunen left, pochi_ left, chee left, sergot left, ChanServ sets mode: +v dalek, Timbus joined, perigrin_ joined, leego joined, noganex left, TimToady left, ft left, jnthn left, mst left, ggherdov left, Grrrr left, Jonis_ joined, nebuchad` joined, dj_goku_ joined, kaare__ joined, krunen__ joined, DarthGandalf joined, kaare_ left, zoosha left, dj_goku_ left, dj_goku_ joined, sjn left, cooper left, awwaiid left, hcit left, woodruffw left, cxreg left, nightfrog left, avuserow left, erdic_ joined, AndyBotwin left, psch left, spider-mario left, markk left, Guest60806 left, shadowpaste left, sjn_ joined, pierrot left, sftp left 03:38 simcop2387 left, mohae left, TEttinger joined, _notbenh joined, awwaiid joined, profan_ joined, Sgeo left, bpmedley left, vcv left, dylanwh left, rjbs left, masak left, rcy left, tailgate left, BinGOs_ joined, cpage_ left, Khisanth left, djbkd left, masak joined, _notbenh is now known as notbenh, vcv_ joined, AlexDaniel left, breinbaas left, lizmat left, perlpilot left, aindilis` left, MilkmanDan left, facetious joined, cxreg2 joined, dylanwh joined, sjohnsen joined, Praise left, krunen__ is now known as krunen, a3r0 left, ponbiki left, john51 left, sftp joined, cpage__ is now known as cpage_, kst left, grondilu left, broquaint left, bhm left, BooK left 03:39 ilogger2_ joined, AndyBotwin joined, KotH_ joined, perlpilot joined, a3r0 joined, orevdiabl joined, ponbiki joined, mspo_ joined, richi238 joined 03:40 ponbiki is now known as Guest17098, amalia_ joined, telex joined, pochi joined, Guest71143 joined, ggoebel_ joined, [particle] joined 03:41 arnsholt_ joined, Khisanth joined 03:42 john51 joined, grondilu joined, Grrrr joined, ChanServ sets mode: +v camelia, edenc_ joined 03:43 sivoais joined, pierrot joined, wtw joined, mst_ joined, tinita joined, Upasaka joined, Celelibi_ joined 03:44 decent joined, woodruffw joined 03:48 psch joined, rjbs joined, BillSussman joined, krunen_ joined, richi238 left, labster joined, pochi left, [1]ringer1 joined, emdashcomma joined, bob777 joined, Bucciarati_ joined, skaji_ joined, edenc_ left, bjz joined, luis joined, markk_ joined, gensym joined, grondilu_ joined, [particle] left, [particle]1 joined, domm1 joined, mohae joined, matt_ joined, perigrin joined, matt_ is now known as Guest28917, kaare__ joined, Guest71143 left, richi235 joined, AndyBotwin left, vytas-local_ joined, facetious joined, wtw left, MilkmanDan joined 03:49 grondilu left, vytas left, garu_ left, ssm left, dsp_ left, Juerd_ joined, decent left, telex left, dan joined, MilkmanDan left, MilkmanDan joined, Juerd_ is now known as Juerd, decent joined, canopus joined, vcv joined, moritz_ joined, xinming joined, Sgeo joined, beatdown joined, profan joined, edenc joined, gabiruh joined, Gothmog_ joined, hcit joined, wtw joined, avuserow joined, m0ltar joined 03:50 ssm joined, pdcawley joined, xiaomiao joined, cgfbee joined, jnthn joined, olinkl joined 03:51 tony-o joined 03:52 breinbaas joined, AlexDaniel joined, john51 left, atacama joined, ilbot3 joined, john51 joined, ft joined 03:53 sunnavy joined 03:54 rmmm joined, raydiak joined 03:55 ingy joined, giraffe_ joined, masak_ joined, dsp_ joined, shadowpaste joined 03:56 richi235 left, grondilu_ left, sivoais left, sivoais joined 03:57 lizmat joined, Actualeyes joined 03:58 richi235 joined, dj_goku joined, dj_goku left, dj_goku joined 03:59 garu joined 04:00 bartolin joined, sivoais left 04:03 pochi joined, telex joined 04:05 ggherdov joined 04:10 w4and0er96 joined 04:11 BuildTheRobots joined 04:14 timeless joined 04:19 bob777 left, Actualeyes left, bob777 joined 04:20 [particle] joined, ringer1 joined
SmokeMachine____ Hi! I am having this problem, but the module (i think) is in the right place... any suggestion? 04:20
04:20 mohae_ joined, garu left, NeuralAnomaly_ joined, huggable_ joined
SmokeMachine____ www.irccloud.com/pastebin/TCh2pnb9/ 04:20
04:20 ingy left, vcv left, masak_ left, john51 left, [ptc]_ joined, giraffe_ left, garu_ joined, Actualeyes1 joined, timeless left, Spot__ joined, breinbaas left, markk_ left, [1]ringer1 left, Spot__ left, Spot__ joined, w4and0er96 left, [particle]1 left, SourceBaby joined, nemo_ joined, vcv joined, breinbaas joined, Woodi_ joined, atacama left, [ptc]_ is now known as [ptc], Khisanth left, ingy joined, atacama joined, richi235 left, vytas-local_ left, BuildTheRobots left, edenc left, beatdown left, NeuralAnomaly left, pochi left, jcallen left, ggherdov left, Juerd left, arnsholt_ left, Sgeo left, pierrot left, cgfbee left, dan left, MilkmanDan left
salparadise SmokeMachine____: code causing the problem will help I think 04:20
04:20 erdic joined 04:21 Gothmog_ left, beatdown_ joined, Gothmog_ joined, DANtheBEASTman joined, vytas-local_ joined, sftp joined, Juerd joined, mohae left, Sgeo joined, jcallen joined, poisonby joined 04:22 camelia joined, spider-mario joined, cgfbee joined, richi235 joined, inokenty joined 04:23 kmwallio joined, ChanServ sets mode: +v camelia, pochi joined, Unavowed joined 04:24 giraffe_ joined 04:25 john51 joined
SmokeMachine____ I have a module ProblemSolver on ./lib/ProblemSolver.pm6 and a ProblemSolver::State on ./lib/ProblemSolver/State.pm6 04:25
04:25 petercommand joined, markk joined 04:26 abruanese joined, imcsk8 joined
SmokeMachine____ and a test t/03-problem.t that does: use lib "lib"; use ProblemSolver; 04:26
04:26 huf joined
SmokeMachine____ salparadise: ^^ 04:26
04:26 john51 left, simcop2387 joined
SmokeMachine____ ProblemSolver and ProblemSolver::State are classes... 04:26
04:27 [Coke] joined
SmokeMachine____ salparadise: ant idea? 04:27
04:27 arnsholt joined, MilkmanDan joined, masak_ joined, japhb joined, pierrot joined, Khisanth joined, labster left 04:28 eyck joined, cosimo joined, sivoais joined 04:29 ggherdov joined
salparadise not really, more code, is ProblemSolver something you wrote? 04:30
SmokeMachine____ www.irccloud.com/pastebin/0ERDdoJc/
yes, I did write ProblemSolver and ProblemSolver::State
04:33 clkao joined 04:34 Util joined, infina joined, timeless joined 04:35 w4and0er96 joined, john51 joined 04:36 wtw_ joined, Cabanossi joined 04:38 wtw left
SmokeMachine____ Looks that the problem is when I create a attribute with the use'd type as type 04:39
04:41 holyghost joined 04:47 baest_ joined 04:50 baest_ left 04:52 baest joined 05:02 cbk_ joined 05:05 cpage_ joined 05:16 pierre_ joined 05:17 melezhik joined 05:20 pierre_ left 05:21 cbk_ left 05:30 AlexDaniel left 05:38 pierre_ joined 05:50 grondilu joined 05:56 yoleaux joined, ChanServ sets mode: +v yoleaux 05:58 holyghost left, pierre_ left 05:59 wamba joined 06:01 kurahaupo joined 06:11 ufobat joined 06:30 andrzejku joined 06:41 kurahaupo left 06:49 KotH_ is now known as KotH 06:52 Matthew[m] joined 06:56 wamba left 07:05 darutoko joined 07:32 firstdayonthejob joined 07:35 kaare__ is now known as 92AAADCOE, edenc joined, BuildTheRobots joined, jnap_ joined, PotatoGim joined, kipd joined, Peter_R joined, damnlie joined, jsimonet joined, albongo joined, avalenn joined, isacloud joined, DrParis joined, kipd left, kipd joined, PotatoGim left, PotatoGim joined, jnap_ left, jnap_ joined, BuildTheRobots left, BuildTheRobots joined, andrzejku left, BuildTheRobots left 07:36 espadrine joined 07:39 PotatoGim left 07:41 BuildTheRobots joined 07:45 PotatoGim joined 07:50 grondilu left 07:52 andrzejku joined 07:55 RabidGravy joined 08:03 andrzejku left 08:05 cyphase joined 08:07 andrzejku joined 08:08 cpage_ left 08:10 cpage_ joined, FROGGS joined 08:13 breinbaas left, cyphase left 08:14 breinbaas joined
moritz_ SmokeMachine____: have you used ProblemSolver::State in ProblemSovler.pm? 08:17
08:18 cyphase joined 08:25 [particle] left, [particle] joined 08:29 andrzejku left 08:38 cyphase left 08:39 BinGOs joined 08:41 domidumont joined 08:45 cyphase joined 08:46 domidumont1 joined, domidumont left 08:47 andrzejku joined 08:48 ka joined 08:58 BillSussman left 09:04 eliasr joined 09:08 bpmedley joined 09:10 labster joined 09:12 domidumont1 left 09:25 hanekomu joined 09:27 Bucciarati_ is now known as Bucciarati, hanekomu left, canopus left 09:29 hanekomu joined 09:32 canopus joined, Ven_ joined 09:37 Ven_ left, Ven_ joined
dalek line-Perl5: a03cc7b | niner++ | lib/Inline/Perl5.pm6:
Faster and safer check to determine if we construct a subclass object
09:38 nebuchadnezzar joined 09:51 Ven__ joined 09:52 Ven_ left 09:55 RabidGravy left 10:03 ka left 10:08 setty1 joined 10:11 yqt joined 10:13 nadim_ joined 10:14 firstdayonthejob left 10:20 andrzejku left 10:21 labster left 10:23 ocbtec joined 10:31 Ven__ left 10:35 imcsk8 left, imcsk8 joined 10:38 wamba joined
El_Che impressive netsplit 10:42
10:53 Actualeyes1 left
dalek c: 8dd339e | (Jan-Olof Hendig)++ | doc/Type/Range.pod6:
Added some more code examples plus some sundry stuff
11:08 Actualeyes joined
bioduds_ hey guys 11:14
is this here valid? a hash of hashes? my %hash-set = { "técnico" => { "Marcelo Oliveira" => Técnico.new( nome=>"Marcelo Oliveira", gênero=>"Homem", idade=>49, rate=>3.88 ) }, { "Levir Culpi" => Técnico.new( nome=>"Levir Culpi", gênero=>"Homem", idade=>52, rate=>4.12 ) }, { "Cuca" => Técnico.new( nome=>"Cuca", gênero=>"Homem", idade=>49, rate=>"-" ) }, "tim
psch m: my %h = foo => { bar => 1, baz => 2 }; say %h<foo><bar> 11:15
camelia rakudo-moar 539a7d: OUTPUT«1␤»
psch bioduds_: no, it's not, because you're assigning a one-item list to a hash 11:16
m: my %h = { a => 1 }
camelia rakudo-moar 539a7d: OUTPUT«Potential difficulties:␤ Useless use of hash composer on right side of hash assignment; did you mean := instead?␤ at <tmp>:1␤ ------> 3my %h = { a => 1 }7⏏5<EOL>␤»
psch m: my %h = { a => { b => 2 } }
camelia rakudo-moar 539a7d: OUTPUT«Potential difficulties:␤ Useless use of hash composer on right side of hash assignment; did you mean := instead?␤ at <tmp>:1␤ ------> 3my %h = { a => { b => 2 } }7⏏5<EOL>␤»
psch oh, no, my private test was just weird
bioduds_: do you get an error from the compiler? or just that warning
bioduds_: because in general we try to make the compiler make sense when it says something :) 11:17
11:23 domidumont joined
bioduds_ warning I guess 11:23
Potential difficulties: Useless use of hash composer on right side of hash assignment; did you mean := instead? at /home/ubuntu/dev/futs/scripts/ef8a4da32a.pl:37
psch m: my %h = { a => 1 }, { b => 2 }; say %h.keys # useful use of hash composers, as counter example 11:24
camelia rakudo-moar 539a7d: OUTPUT«(a b)␤»
psch m: my @a = [ 1, 2, 3 ]; say @a.elems
camelia rakudo-moar 539a7d: OUTPUT«3␤»
dalek c: 3ad38ad | (Jan-Olof Hendig)++ | doc/Type/Str.pod6:
Added blurb in docs for split that specifying a negative limit does not produce any meaningful result.
bioduds_ what is it telling me? I don't understand the warning: Potential difficulties: Useless use of hash composer on right side of hash assignment; did you mean := instead? at /home/ubuntu/dev/futs/scripts/ef8a4da32a.pl:38 11:27
psch bioduds_: { } is a hash composer, it composes a hash 11:28
bioduds_: a hash assignment means you're assigning to a hash
bioduds_ why is it saying that it is useless? 11:29
psch bioduds_: assignments to sigiled variables are coercive, so you're uselessly creating a hash that the assignment could create for you
bioduds_ oh, I think I get it, so how would be the non-useless syntax?
psch leave out the outer-most hash composer
11:30 rindolf joined, CIAvash joined
bioduds_ oh, I think I got it 11:30
the outer { is useless 11:31
got it, thank guys
11:32 ka joined
bioduds_ meaning, this here will suffice: my %hash-set = "técnico" => { "Marcelo Oliveira" => Técnico.new( nome=>"Marcelo Oliveira", gênero=>"Homem", idade=>49, rate=>3.88 ), "Levir Culpi" => Técnico.new( nome=>"Levir Culpi", gênero=>"Homem", idade=>52, rate=>4.12 ), "Cuca" => Técnico.new( nome=>"Cuca", gênero=>"Homem", idade=>49, rate=>"-" ) }, "time" => { "C 11:32
11:32 scott joined
scott I'm also learning perl6 and just cleared this up for myself in the repl. a => 1 is a Pair, {a => 1} is a Hash, but like they say, assigning a pair or list of pairs to a %-sigil variable coerces to hash anyway 11:32
11:34 Ven_ joined 11:36 Ven_ left, Ven_ joined
scott it's also fine to put regular parentheses around your list of pairs, as in `my %h = ( a => 1, b => 2, ... )`, since that's still just a list of pairs 11:38
SmokeMachine____ moritz_: yes 11:40
11:41 mst_ is now known as mst, mst left, mst joined 11:42 mst is now known as mst_, mst_ is now known as mst 11:46 Ven_ left 11:49 ka left 11:55 infina left, infina joined 11:56 ka joined 12:05 92AAADCOE left 12:06 ka left 12:08 ka joined 12:20 sammers joined 12:21 rindolf left 12:30 dayangkun joined 12:36 rindolf joined, bstamour joined 12:40 dayangkun left, dayangkun joined 12:44 pmurias joined 12:45 dayangkun left, bstamour left 12:47 Zoffix joined
Zoffix scott, I recommend you think of Hash as %(a => 1) rather than {a => 1}. It's easy to get tripped up in cases where the curly version gets treated as a block 12:48
m: $_ = 42; dd { a => $_ } # case in point
camelia rakudo-moar 539a7d: OUTPUT«-> ;; $_? is raw { #`(Block|57555136) ... }␤»
Zoffix scott, also, you don't need any parentheses at all. my %h = a => 1, b => 2; works 12:49
m: my %h = a => 1, b => 2;
camelia ( no output )
Zoffix m: my %h = a => 1, b => 2; dd %h
camelia rakudo-moar 539a7d: OUTPUT«Hash %h = {:a(1), :b(2)}␤»
scott heh, I was just messing with cases involving that {} confusion
Zoffix m: my %h = :1a, :2b; dd %h
camelia rakudo-moar 539a7d: OUTPUT«Hash %h = {:a(1), :b(2)}␤»
scott for multiline hashes, it seems nicer to have a delimiter around it 12:50
.oO( Death to parentheses! )
scott the semicolon looks really awkward when there is no delimiter
on a line by itself, or taking a place where a trailing comma should be 12:51
relatedly, I'm attempting to grok the whole variables/bindings/assignment situation in perl6. are there any important differences between `my %h = :1a, :2b` and `my Hash $h := %(:1a, :2b)` (post-creation)? they both seem to handle assignment the same way, they seem to have the same .VAR type 12:55
12:56 rindolf left 12:57 pierre_ joined
llfourn_ scott: you don't really need the 'Hash' in the second one if you want it to be like the first 12:57
also % will behave differently in for loops to $
12:57 ilbot3 left, ilbot3 joined
llfourn_ m: my %a = one => "two",three => "four"; for %a { .say } 12:58
camelia rakudo-moar 539a7d: OUTPUT«three => four␤one => two␤»
llfourn_ m: my $a := %( one => "two",three => "four"); for $a { .say }
camelia rakudo-moar 539a7d: OUTPUT«three => four␤one => two␤»
llfourn_ oh maybe I'm wrong about that
m: my $a := %( one => "two",three => "four"); for $a { .^name.say }
camelia rakudo-moar 539a7d: OUTPUT«Pair␤Pair␤»
scott in this case $a.VAR isn't Scalar, it's Hash 12:59
llfourn_ m: my $a = %( one => "two",three => "four"); for $a { .^name.say }
camelia rakudo-moar 539a7d: OUTPUT«Hash␤»
12:59 Zoffix left
llfourn_ oh you're right that's the difference 12:59
so the container type determines loop behaviour rather than the sigil
good to know :)
scott basically I'm trying to find out if I can reduce all sigils to special cases of $ to help my mental model 13:00
llfourn_ I think sigils still affect assignment 13:01
like when you use '=' rather than ':='
scott '=' seems to depend again on the container, not the sigil
once I make $h like above, assigning to it later works the same as for a normal %h 13:02
llfourn_ m: my @a = <one two three>; say @a
camelia rakudo-moar 539a7d: OUTPUT«[one two three]␤»
llfourn_ m: my Array $a = <one two three>; say $a
camelia rakudo-moar 539a7d: OUTPUT«Type check failed in assignment to $a; expected Array but got List ($("one", "two", "three"))␤ in block <unit> at <tmp> line 1␤␤»
scott right, that's not the case I am referring to
that's assigning to a Scalar-wrapped Array 13:03
llfourn_ m: my Array $a := [one two three]; $a = <one two three>; say $a # oh I see sorry
camelia rakudo-moar 539a7d: OUTPUT«5===SORRY!5=== Error while compiling <tmp>␤Undeclared routines:␤ three used at line 1␤ two used at line 1␤␤»
llfourn_ m: my Array $a := [<one two three>]; $a = <one two three>; say $a # :S
camelia rakudo-moar 539a7d: OUTPUT«Cannot assign to an immutable value␤ in block <unit> at <tmp> line 1␤␤»
13:03 wamba left
scott interesting 13:04
I'm unsure what makes @a mutable and $a not when their .VARs are both Array
llfourn_ you can have @a immuteable as well
13:04 rindolf joined
scott can you make that $a mutable? 13:04
llfourn_ m: my @a := <one two three>; @a = <four> 13:05
camelia rakudo-moar 539a7d: OUTPUT«Cannot modify an immutable Str␤ in block <unit> at <tmp> line 1␤␤»
scott oh
llfourn_ it will be mutable if we just assign to an array
m: my $a = [<one two three>; $a = <four>; say $a
camelia rakudo-moar 539a7d: OUTPUT«5===SORRY!5=== Error while compiling <tmp>␤Cannot use variable $a in declaration to initialize itself␤at <tmp>:1␤------> 3my $a = [<one two three>; $7⏏5a = <four>; say $a␤ expecting any of:␤ term␤»
llfourn_ m: my $a = [<one two three>]; $a = <four>; say $a; #ek 13:06
camelia rakudo-moar 539a7d: OUTPUT«four␤»
llfourn_ but as sson as you := you get the container fo the RHS
which is immuteable above
of the* 13:07
scott m: my $a = [<one two three>]; say $a.VAR.WHAT
camelia rakudo-moar 539a7d: OUTPUT«(Scalar)␤»
scott m: my @a = <one two three>; say @a.VAR.WHAT 13:08
camelia rakudo-moar 539a7d: OUTPUT«(Array)␤»
scott m: my $a := [<one two three>]; say $a.VAR.WHAT # this is what I meant, rather
camelia rakudo-moar 539a7d: OUTPUT«(Array)␤»
scott I'm curious what makes one mutable and the other not
if you compare, say, my $a = 42 and my $a := 42, one is Scalar and the other is Int
and the Scalar container makes the former mutale
llfourn_ right. you can't assign the second one for the same reason you can't do '42 = 3' 13:09
you can't do [<one two three>] = [<four>] either 13:10
so the LHS needs to be writeable
13:11 domidumont left
scott hmm, the $h example was writeable because %(:1a, :2b) is writeable 13:13
but @(1, 2, 3) returns List, not Array
I don't know how to make a writeable array without a @ variable 13:14
llfourn_ m: my $a := [<one two three>]; $a[3] = "four"; # this should work?
camelia ( no output )
llfourn_ m: my $a := @(1,2,3); say $a.^name; 13:15
camelia rakudo-moar 539a7d: OUTPUT«List␤»
llfourn_ hmm I didn't know whtat
scott your example with the indexing mutates a container element, not the array
m: my $a := [<one two three>]; push $a, "four" 13:16
camelia ( no output )
scott hmm, it is writeable?
llfourn_ so Array,Hash - elements are writable. List,Map elements are not.
13:17 ilbelkyr joined
scott I still don't get what makes @a assignable 13:17
timotimo awwaiid: i like your latest blog post :)
llfourn_ scott: as opposed to $a := [..]? 13:18
scott since arrays, even when you can push to them, complain about immutable values when you assign to them
llfourn_: right
immutable is a bit of a misleading descriptor when you can add, remove, and mutate elements
13:19 grondilu joined
timotimo an array gives you a scalar container for each of the elements in it 13:19
llfourn_ scott: yeah I see what you mean. In the case of $a := [..]. it means the variable's container itself is not writable.
gfldex is there a way to import symbols from a package into the current scope?
timotimo m: (1, 2, 3, 4)[0].VAR.WHAT.say; [1, 2, 3, 4][0].VAR.WHAT.say;
camelia rakudo-moar 539a7d: OUTPUT«(Int)␤(Scalar)␤»
scott timotimo: sure, that explains one of the things in my list (mutating) but not the rest
timotimo i haven't backlogged yet :) 13:20
scott you can also push to an "immutable" array
llfourn_ scott: all arrays are mutable
grondilu m: (my $ := [])[0] = pi
camelia ( no output )
llfourn_ the variable that contains the array object may not be
timotimo ah 13:21
we differentiate on the syntax level between listy assignment and itemy assignment
that's a thing that tripped me up a few times
scott llfourn_: I'm looking for confirmation of that distinction 13:22
with scalars it's obvious, like Scalar vs Int
normally a $ variable is bound to a Scalar container
grondilu [] is a scalar container
scott but so far I haven't been able to observe the container of a @ variable
it just shows up as Array 13:23
but assigning to an Array elsewhere fails