🦋 Welcome to Raku! raku.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: colabti.org/irclogger/irclogger_log/raku
Set by ChanServ on 14 October 2019.
elcaro Been poking around with APL the last few days. I still don't know what I'm doing with it, but I saw this quote at dyalog.tutorial.com... 06:37
"Often, those who hate APL don't really understand it. Or, they understand it only enough to argue its weak points. Hopefully, this course will teach you enough about APL to love it or hate it intelligently. You may as well be a well-informed bigot."
that's a really great quote that could easily apply to Raku (or Perl) 06:38
sortiz Indeed 06:42
PimDaniel Hello everybody. 12:05
tadzik o/
PimDaniel Is there a buildin function like assert that throws an exception if assertion is false? 12:06
El_Che while testing? docs.raku.org/language/testing 12:18
PimDaniel No while running! But i see die is an overloaded sub and could probably make the job. 12:20
gfldex m: die "welp‼" if False; 12:23
camelia ( no output )
gfldex m: sub assert($msg, &c) { die $msg if c() }; assert("welp‼", { True }); 12:24
camelia welp‼
in sub assert at <tmp> line 1
in block <unit> at <tmp> line 1
gfldex That would be a good candidate for a macro because the stacktrace starts at the wrong spot if thrown in the sub assert. 12:25
PimDaniel In fact i need to control bounds! limits. 12:26
gfldex : 1st thank's for your help! 12:27
die if width > maxwidth;
but there can be many well say 4 conditions max. 12:28
what is c() au juste!
?
A sub?
i'm quite new to raku. 12:29
PimDaniel Is &c a pointer to sub? 12:29
tadzik you can see it that way, yes 12:30
in this case it's just a Callable I think, that's why you can pass a block, which isn't even a sub
PimDaniel @tadzik : ok i see. 12:31
patrickb m: sub a() { say "Lubba dub dub" };my $x = &a; $x(); 12:32
camelia Lubba dub dub
tadzik m: sub assert($msg, &c) is hidden-from-backtrace { die $msg if c() }; assert("welp‼", { True }); # is that still a thing?
camelia welp‼
in block <unit> at <tmp> line 1
lizmat is hidden-from-backtrace still is, yes 12:33
tadzik it'd be fun to apply it to the block itself too
...though that won't really make sense
nevermind :P
PimDaniel why not just : die if $a < $LIMIT; ? 12:34
well limit is not a constant in fact and constants have no $ in raku. 12:35
gfldex m: use experimental :macros; macro assert($msg, $c) { quasi { {{{ die $msg if $c }}} } }; assert("welp‼", { False });
camelia 5===SORRY!5=== Error while compiling <tmp>
("welp‼", { False })
at <tmp>:1
gfldex PimDaniel: ^^^
That will throw from the right line number. 12:36
PimDaniel gfldex : not sure i can make a macro : my limits can change during runtime. 12:38
gfldex The macro takes any expession as a 2nd argument. (I think.) 12:39
PimDaniel gldex : Ok i was not sure to understand! 12:40
gfldex I'm not sure macros are ment to be understood.
PimDaniel may not experimental features disapear? 12:41
gfldex Macros are planned to change. That's why you may want to use v6.d.
PimDaniel macro are processing lighter! but present heavy! 12:42
gfldex PimDaniel: see: gfldex.wordpress.com/2020/10/26/pl...olescence/ 12:43
PimDaniel gfldex : Ok, thanks again. 12:44
I must still learn again and take choice. Thanks to all of you. You bought me light! 12:45
PimDaniel gfldex : what is m: ? a label? 13:00
gfldex m: say "m: is a marker for this irc bot."; 13:02
camelia m: is a marker for this irc bot.
gfldex is heads to $dayjob
PimDaniel Ho sorry! Your 1st solution works : sub assert($msg, &c) is hidden-from-backtrace { die $msg if c() }; assert("welp‼", { True }); just test on die must be reverte { die if not c() } or unless c(). 13:03
Because we assert something True and rise exception on False. 13:04
PimDaniel I think it is convenient enought for me , i can even change sub to put several conditions and adapt the message. 13:08
lizmat m: sub assert($a is raw,&op,$b is raw) { die "assert failed: $a &op.name() $b" unless op($a,$b) }; assert(42,&[<],6) # PimDaniel 13:27
camelia assert failed: 42 infix:«<» 6
in sub assert at <tmp> line 1
in block <unit> at <tmp> line 1
lizmat m: sub assert($a is raw,&op,$b is raw) { die "assert failed: $a &op.name() $b" unless op($a,$b) }; assert(42,&[<],666)
camelia ( no output )
PimDaniel lizmat: thanks! I'll test your solution. 13:28
lizmat note that &[foo] is a short annotation for &infix:<foo> 13:29
where foo can be any infix operator
PimDaniel Okay! i must watch that! it will be probably usefull for multi-conditions assertions. 13:30
lizmat just realize that everything in Raku is an object, even objects are objects :-) 13:32
PimDaniel ok like in Java! :))))
lizmat I guess :-) 13:33
PimDaniel No not *like" fortunatly! 13:35
nige o/ 14:05
just trying to sort out Fosdem video recording for a Raku-related presentation - does anyone have any tips for recording slides and speaker at the same time? 14:06
lizmat would be interested in that as well :-) 14:08
kiti_nomad[m] Very happy, rakudo's Chinese book is published
I bought one 14:09
lizmat kiti_nomad[m]++
kawaii www.irccloud.com/pastebin/xBEmbeZK...s%20why%3F 14:28
For some reason the items in my array here are being put into one object (a string?) when unpacked, these are 'Devops' and 'Web' not 'Devops Web', any ideas why? ^
lizmat what's in %team ? 14:29
or %config for that matter ?
kawaii %team is the top level hash, containing keys of all the member usernames, %config is another hash containing a whole bunch of sub-keys, let me extract the appropriate parts 14:30
lizmat perhaps golf it down ?
kawaii I can make an attempt
lizmat afk for a few hours& 14:32
PimDaniel hi everybody : I my nick hightlighted sometimes, when some of you replies to me. How do you make it? Thank's. 14:47
*I see !
I mean i see my nick in light yellow ... how do you make it? 14:48
Light yellow is due to my program : i use irssi.
perry Huh, when was this a thing? course.raku.org 14:53
patrickb perry: Exists since a week or so. Kudos go to Andrew Shitov 14:55
MasterDuke kawaii: there may be a precedence problem with your assignment and the feed operators 14:57
what happens if you try `my $a = do <...>`?
kawaii MasterDuke: I resolved it by changing my ==> to distinct .map() calls instead 14:58
no idea why it fixed it, but it did
`%member<role_memberships><standard>.map({%config<discord-team-roles>{$_}}).map({"<@&{$_}>"}).join(', ')`
MasterDuke probably the precedence then, someone else here had a similar problem a day or two ago 14:58
notagoodidea MasterDuke: Yep, it was me and `do` solve the issue. 15:00
tellable6 2021-01-13T20:54:35Z #raku <melezhik> notagoodidea: this is good , very clear
MasterDuke m: my $a = <a b c> ==> map { .uc } ==> join(","); say $a; my $b = do <a b c> ==> map { .uc } ==> join(","); say $b
camelia (a b c)
A,B,C
MasterDuke kawaii: ^^^ 15:01
PimDaniel Does "is raw" means any type? 15:03
I mean for a sub argument : sub mysub ( a is raw) {...} ? 15:05
MasterDuke 'is raw' deals with containerization, but i'm not the person to explain in any more depth than that 15:10
PimDaniel MasterDuke : Okay thank's dont't worry, i'll found it. 15:12
notandinus is there a cgi module for raku? 17:03
or something that could run in cgi mode (like mojo (p5)) ? 17:04
lizmat news.ycombinator.com/item?id=25775696 # Raku course comments on Hacker News 17:05
[Coke] there are multiple web service frameworks. I'm not sure anyone has a CGI dropin 17:10
but start here: modules.raku.org/search/?q=cgi 17:11
(yes there appear to be) 17:12
notandinus hmm yeah i started there 17:16
i'm not sure if fastcgi is the same thing as cgi 17:17
btw is modules.raku.org down for anyone else?
[Coke] it's up here. 17:19
lizmat uo for me
tony-o works fine for me, i think cloudflare is having some issues though.
[Coke] downforeveryoneorjustme.com/modules.raku.org 17:20
notandinus hmm looks up again, wasn't responding to pings for like a minute 17:22
tony-o cf is having some issues 17:33
notandinus looks like ngnix supports fastcgi, will check it out tomorrow 17:57
notandinus sleeps
sortiz \o #raku 19:56
[Coke] hurls twitter.com/cokebot9000/status/134...4776266761 in case anyone wants to fill out a CS related poll. 20:19
sortiz I am surprised by the lack in the documentation of references to creating by direct assignment of @ or% sigiled variables of alternate types (is Foo = ...). Only binding is marginally mentioned or used.
[Coke] (it me. I cokebot9000)
sortiz m: my %M is Map = :foo(1), :bar('hi'); dd %M; 20:20
camelia Map.new((:bar("hi"),:foo(1)))
sortiz m: my @B is Buf[int32] = 200,300,400; dd @B; 20:21
camelia Buf[int32].new(200,300,400)
sortiz I suspect it is the reason why many users end up creating Array when a List is enough. 20:25
m: my @l is List = <foo bar>; dd @l; 20:26
camelia ("foo", "bar")
codesections oh, cool, that Raku tutorial lizmat mentioned is on the HackerNews front page 21:57
guifa codesections: nice 22:32
cono p6: my $s = Supply.from-list(<a b c>); my $x = supply { whenever $s { .emit }}; my $y = supply { whenever $x { .emit }}; $y.tap: *.say 22:41
camelia a
b
c
cono why similar code stucking? my $s = Supply.from-list(<a b c>); my $z = $s; for ^2 { $z = supply { whenever $z { .emit } } }; $z.tap: *.say 22:42
gfldex cono: you tap on $z after anything can be send to it. Also you shadow $z in the loop body 22:57
cono I thought that from-list gives me on-demand supply, so it waits until I tap on it 23:00
like this tap: $z.tap: *.say 23:01
gfldex you shadow `$z = $s` with `$z = supply` 23:02
cono not sure I understand what `shadow` means
gfldex You replace the Supply.from-list with another Supply object. 23:03
cono yes, and closuring from-list in {} 23:04
gfldex "Note that no history is kept for on-demand supplies, instead, the supply block is run for each tap of the supply." 23:08
gfldex m: my $s = Supply.from-list(<a b c>); my $z = $s; for ^2 { our $z = supply { whenever $z { .emit } } }; $z.tap: *.say 23:15
camelia a
b
c
gfldex cono: ^^^
cono wow, seems like a scoping bug to me 23:16
cono p6: my $s = Supply.from-list(<a b c>); my $z = $s; for ^3 { our $z = supply { whenever $z { "$_ layer".emit } }; }; react { whenever $z { .say }} 23:25
camelia a
b
c
gfldex m: { say &?BLOCK.signature }; await supply { say &?BLOCK.signature } 23:28
camelia (;; $_? is raw = OUTER::<$_>)
()
gfldex cono: supply and whenever blocks are not normal blocks. I don't think they are supposed to form a closure.
cono oh, you are correct 23:42
p6: my $s = Supply.from-list(<a b c>); my $z = $s; sub magic($t) { supply { whenever $t { "$_ layer".emit } } }; for ^2 { $z = magic($z) }; react { whenever $z { .say }}
camelia a layer layer
b layer layer
c layer layer
cono thanks! gfldex++ 23:43
moon-child I'm trying to figure out why a script is slow; can anyone lend a hand? 23:44
the script is ix.io/2M3n/perl6; it's a testrunner for my c compiler 23:45
it currently takes 0.7~0.8s (or, claims to). If I run the tests from the shell, they take half that
moon-child but curiously, the time doesn't seem to be in the grammar or parsing; if I comment out the lines that actually do the compilation (but still run everything else), it claims to take 0.01~0.02s--practically instant 23:46
tony-o you might use Bench and time different parts you think are eating time 23:50
moon-child if I comment out the 4 lines that actually compile things, the time goes down almost to nothing. That seems pretty damning... 23:52
(though it might be optimizer-related?)
also curious why adding .hyper/.race to the loop doesn't help performance any 23:53
tony-o you might look into Proc::Async if you want to run tests in parallel 23:54
moon-child oh, oops, apparently I was racing 23:59