🦋 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.
00:10 pecastro left 00:15 sena_kun joined 00:16 zacts joined, Altai-man_ left 00:18 aborazmeh joined, aborazmeh left, aborazmeh joined 00:20 zacts left 00:28 NewGreyhawke left
guifa2 Xliff: You could make a suffix, I suppose, but IME it's *very* tricky keeping native stuff as natives. Even doing something like $a + ($b - $c) has booted them out of native and into general Ints 00:32
00:43 MilkmanDan left 00:45 MilkmanDan joined, aborazmeh left 00:53 _jrjsmrtn joined 00:55 __jrjsmrtn__ left 01:02 silug left 01:03 silug joined 01:22 NewGreyhawke joined 01:23 silug6 joined, silug left, silug6 is now known as silug, lucasb left 01:59 molaf left
Xliff guifa: Yeah. Everything has to be typed! 02:02
Using binds also helps.
The moment it conts, you lose the native, I think.
02:03 Noisytoot left 02:06 ManifestO left, ManifestO joined 02:07 Noisytoot joined 02:11 molaf joined 02:13 Altai-man_ joined 02:16 sena_kun left 02:21 Noisytoot left 02:24 Noisytoot joined 02:30 Noisytoot left 02:35 oodani_ left, oodani joined 02:37 kst left
Geth doc: coke self-assigned xt/examples-compilation.t github.com/Raku/doc/issues/3391
889c6aa040 | (Tom Browder)++ (committed using GitHub Web editor) | doc/Language/intro.pod6
02:48
03:22 kst joined 03:25 guifa2_ joined, guifa2 left, guifa2_ is now known as guifa2 03:34 gordonfish joined 03:48 cpan-raku left 03:50 RaycatWhoDat joined, zacts joined, cpan-raku joined, cpan-raku left, cpan-raku joined, RaycatWhoDat left 04:09 leont joined 04:14 sena_kun joined 04:15 sivoais_ left, sivoais joined 04:16 Altai-man_ left 05:05 reach_satori left, reach_satori joined 05:07 skids joined 05:18 wamba joined 05:45 rindolf joined 06:13 Altai-man_ joined 06:16 sena_kun left 06:17 NewGreyhawke left
cpan-raku New module released to CPAN! Chart::Gnuplot (0.0.18) by 03TITSUKI 06:19
06:30 skids left 06:44 xinming left
cpan-raku New module released to CPAN! Chart::Gnuplot (0.0.19) by 03TITSUKI 06:51
07:15 wamba left 07:32 xinming joined 07:47 xinming left 07:49 xinming joined
linkable6 Link: docs.raku.org/language/intro
DOC#3252 [closed]: github.com/Raku/doc/pull/3252 proposed table of Raku vs. Perl 6 deprecations
07:59 Zero_Dogg left 08:08 Noisytoot joined 08:14 sena_kun joined 08:16 Altai-man_ left
Geth doc: e707196480 | (JJ Merelo)++ | doc/Type/Supply.pod6
Changes former definition to table
08:25
doc: f818b95bce | (JJ Merelo)++ | doc/Type/Supply.pod6
Adds new definitions to Supply.throttle.

Also rewrites a part. Closes #175
linkable6 Link: docs.raku.org/type/Supply
DOC#175 [closed]: github.com/Raku/doc/issues/175 [docs] Document Supply.throttle(:$vent-at)
08:36 Zero_Dogg joined
Geth doc: d9fa24d5bc | (JJ Merelo)++ | doc/Type/Supply.pod6
Reformatting working on #1875
08:50
doc: b4ac61ded0 | (JJ Merelo)++ | doc/Type/Supply.pod6
Moves Supply.reduce, closes #1875

Also, some clarification.
linkable6 Link: docs.raku.org/type/Supply
DOC#1875 [closed]: github.com/Raku/doc/issues/1875 [bug][docs] Supply.reduce waits for the Supply to finish
09:13 oddp joined, MasterDuke joined 09:26 Sgeo left 09:31 cpan-raku left, cpan-raku_ joined, cpan-raku_ left, cpan-raku_ joined 09:42 HarmtH_ joined 09:43 markong joined, HarmtH left 09:49 wamba joined 09:51 Black_Ribbon left 09:54 markong left 09:55 markong joined
Geth doc: bb4543d9ac | (JJ Merelo)++ | doc/Type/Supply.pod6
Adds definitionf of Supply.tail #3527
10:02
linkable6 Link: docs.raku.org/type/Supply
DOC#3527 [open]: github.com/Raku/doc/issues/3527 [RFE][docs][help wanted][versions] Checklist for 2020.07
10:13 Altai-man_ joined 10:16 sena_kun left 10:22 pecastro joined
holyghost I am going to start Tuesday on racul, a scheme language extension compiler/interpreter which extends raku applications, probably not the compiler itself 10:26
It's on Xliff's server and at github.com/theholyghost2/racul
I chose the name from dracul (dragon knight) and guile (gnu extensions system from the scheme language) 10:27
So basically it's scheme language specifically for raku, instead of using guile, I start from scratch 10:28
It'll be revised scheme report 3 at the minimum
So no continuations for example, to start with 10:29
(I've written unterpaganperl)
It's probably be written in plain ANSI C 10:31
I cannot give pf and pm a new language though, but if racul is somewhere, anyone can extend the scheme language 10:32
It'll be a modularized system 10:33
10:55 NewGreyhawke joined 10:58 erdic left 10:59 telex left 11:01 erdic joined 11:02 telex joined 11:19 xinming left 11:20 xinming joined, aborazmeh joined, aborazmeh left, aborazmeh joined 11:24 xinming left 11:25 xinming joined 11:29 kensanata joined 11:41 kensanata left 11:44 wamba left 11:55 NewGreyhawke left 12:14 sena_kun joined 12:17 Altai-man_ left 12:34 aborazmeh left
Xliff gist.github.com/Xliff/600d1c8ba52c...f43fb24ccc <- Solves my enum problem 12:48
12:48 Ven`` joined 12:55 Zero_Dogg left 12:59 sena_kun1 joined 13:03 kensanata joined 13:09 Zero_Dogg joined
[ptc] silly question time: theoretically, the regex `m:i:g/ 'bb' || <-[ b ]> ** 2 /` should match either two 'b's or not a 'b' twice 13:25
my question is: is it possible to write that more elegantly? 13:26
codesections Hmmm, interesting question. My first thought (combining into `[ 'bb' || <-[ b ]> ] ** 2` doesn't work. 13:32
[ptc] maybe `[ 'b' || <-[ b ]> ] ** 2` ? 13:34
codesections er, right, that's what I meant (the 'bb' was a typo on my part). I thought that might work, but it doesn't 13:36
but that matches 'ab'. Which I'm slightly surprised by – I guess the branch is evaluated seperately on each repetition 13:37
[ptc] hrm, true. Weird. 13:40
m: say "abBii" ~~ m:i:g/ 'bb' || <-[ b ]> ** 2 /;
camelia (「bB」 「ii」)
[ptc] say "abBii" ~~ m:i:g/ [ 'b' || <-[ b ]> ] ** 2 /;
evalable6 (「ab」 「Bi」)
lizmat moritz ^^ 13:41
[ptc] my raku is amazingly rusty... still trying to get back up to speed
Voldenet m: "aaabbbac" ~~ m:Perl5:g/bb|[^b]{2}/ 13:42
camelia ( no output )
[ptc] Voldenet: in theory that should work (at least, that was the version on the T-shirt I used to own ;-) ) 13:43
Voldenet oh, i just realized what it means :D 13:44
and it'd work in perl5, so I wonder why doesn't it now 13:45
m: "aaabbbac" ~~ m:Perl5:g/a/
camelia ( no output )
Voldenet m: "aaabbbac" ~~ m:Perl5/a/
camelia ( no output )
codesections I'll be kind of sad if the best Raku regex we can come up with involves the `Perl5` adverb :) 13:46
Voldenet that's weird
codesections m: say "aaabbbac" ~~ m:Perl5:g/bb|[^b]{2}/
camelia (「aa」 「bb」 「ac」)
Voldenet …lol, right
codesections :)
Voldenet I'd argue about "best" - shortest maybe ;) 13:47
[ptc] yeah, I'd like to steer clear of the Perl5 adverb :-) 13:48
Voldenet m: say "aaabbbac" ~~ m:g/bb||<-[b]> ** 2/
camelia (「aa」 「bb」 「ac」)
Voldenet it's almost the same
in fact 13:49
m: say "aaabbbac" ~~ m:g/bb|<-[b]> ** 2/
camelia (「aa」 「bb」 「ac」)
[ptc] true, but it has more of a raku flavour, and that's what I'm interested in
yeah, that's definitely better than my attempt 13:50
Voldenet it's literally the same tho :D
[ptc] but in p5 it's not possible to spread it out with whitespace (not using /x, of course) 13:51
and I think that makes it easier for the brain to parse when reading it
Voldenet i've seen regex hell, nothing scares me anymore 13:52
[ptc] hehe
m: say "aaabbbac" ~~ m:g/ bb || <-[b]> ** 2/
camelia (「aa」 「bb」 「ac」)
[ptc] that feels a bit more "idiomatic raku" to me... Dunno if there's such a thing as idiomatic raku yet though 13:53
Voldenet m: say "aaabbbac" ~~ m:g/ bb || <-[b]><-[b]> / 13:56
camelia (「aa」 「bb」 「ac」)
[ptc] m: my $question = 'aaabbbac'; $question ~~ m:g/ bb || <-[b]> ** 2/; 13:59
camelia ( no output )
[ptc] m: my $question = 'aaabbbac'; say $question ~~ m:g/ bb || <-[b]> ** 2/;
camelia (「aa」 「bb」 「ac」)
13:59 wamba joined
[ptc] I had hoped to be able to use rx//, but the :g adverb doesn't work with rx// 14:00
took me a while to work out why, but once I found the place in the docs, it became clearer :-)
thanks for the tips everyone!
codesections m: say 'aaabbbac' ~~ m:i:g/ 'a' ** {(1, 3)}/ 14:01
camelia (「aa」)
codesections why doesn't that dwim? I would have thought that would be "either 1 or 3 'a's", but it returns 2 14:02
timotimo it numifies the list, the list has two elements, so it's equivalent to `** 2` 14:04
codesections …oh. Right, because it won't take a list, just a Range 14:05
timotimo that's right
14:05 sena_kun1 left
timotimo if you want to have two alternatives, you will need an alteration 14:05
perhaps at some point junctions of integers could be supported? 14:06
codesections and the same is true of something like (1, * + 5 … 6)
Which I *think of* as a Range, but really reduces to a (perhaps lazy) List
timotimo i would not call that a range 14:07
especially since it has a gap :) 14:08
codesections Well, it's a Seq
timotimo yeah, ... is the Sequence operator
Range is more closely related to the mathematical notion of an Interval
codesections I (sloppily) think of as being "like Ranges but fancier" :) 14:09
which I should probably stop doing!
m: 'aa' ~~ /a ** {('str', 'str2')}/ 14:13
camelia ( no output )
codesections m: 'aa' ~~ /a ** {'str2'}/ 14:14
camelia Cannot use non-Numeric or NaN value as quantifier
in block <unit> at <tmp> line 1
14:14 Altai-man_ joined
moritz a sequence operator is closer to a loop 14:14
codesections Do you think it's a bug that the List example coerces to Numeric without throwing the same error that the Str version does?
14:14 rawr is now known as grumble
timotimo could probably warn when it's a literal 14:15
if you're using a variable that has a list in it and it gets numified for you, that's usually a feature; like "match a string with as many 'a's as the array has elements" essentially 14:16
codesections is that just to save typing `.elems`?
14:16 sena_kun left
moritz yes 14:18
also, p5 heritage
14:19 xelxebar_ joined 14:20 xelxebar left
codesections and I guess we do have a warning sign docs.raku.org/language/traps#Lists...ic_context 14:20
14:20 sftp left
codesections :) 14:20
(Just not on the Regex page) 14:21
14:23 sftp joined 14:37 Xliff left
samebchase- In Raku, we use grep when we want to filter elements based on a predicate. How do we return the elements from a sequence that do NOT match a predicate. Other languages have a "remove" function, what's the most idiomatic Raku way of doing this? 14:59
14:59 xinming left
samebchase- "Note that if you want to grep for elements that do not match, you can use a none-Junction:" hmm, found this in the documentation 15:00
15:00 xinming joined
codesections In many cases, you can also just flip the test, right? 15:01
m: (^20).grep({!.is-prime})
camelia ( no output )
codesections m: say (^20).grep({!.is-prime})
camelia (0 1 4 6 8 9 10 12 14 15 16 18)
samebchase- hmm, complementing the predicate seems to be the easiest way 15:03
thanks codesections!
codesections you're welcome :) 15:04
(Something I really like about Raku is how it does a lot more with simple combinations of well-thought out operations (here, smartmatching and junctions) where other languages use a lot more methods) 15:05
timotimo codesections: many tests are not code :) 15:06
m: say <a b c d e f g>.grep(none <a e f>)
camelia (b c d g)
samebchase- The reason I ask is, I was writing some code recently, and to write a filter, I had an "if", of the form (if cond A and cond B, then check cond C or return true otherwise). It seemed clunky to have a true in the else branch, so I changed it to use remove with the if changing to (if cond A and cond B then check inverse of cond C), and I got rid of t
he "true" part if that makes any sense
15:08 pi4 left 15:09 e left
samebchase- , but the language I was using (Clojure) had "when", but Raku's when has the behaviour which bit me recently "When the when block is executed, control is passed to the enclosing block and /following statements are ignored/!" 15:10
codesections That *feels* like a good use case for a Junction, but I'm not quite sure… 15:11
samebchase- so I avoid using when as much as possible
codesections Why's that? To avoid multiple exit points for the fn? 15:12
samebchase- I guess, it seems to me right now, that we can use a combination of flipping the predicate or the none Junction as described in the documentation, depending on the case
codesections, basically someone used to Lisp or Clojure's when/unless should be wary of Raku "when" gotcha, but interestingly enough Raku's "unless" does not have the same gotcha 15:13
codesections Interesting. I hadn't thought about it from a Lisp point of view. There, the distinction between `if` and `when` is that `when` allows multiple forms without `progn` or whatever? (My Lisp is a bit rusty) 15:15
samebchase- If you don't have an else branch, it just seems cleaner to use when/unless (in those languages), but I guess, in Raku we should use if without an else branch in situations where there could be other statements following the if block.
15:16 kensanata left
samebchase- codesections: yeah, the implicit progn/do is a convenience feature 15:16
If anyone can let me know why Raku's "when" does it this way, I am interested to know the reason, purely out of curiosity. 15:17
15:18 NewGreyhawke joined
codesections re "use if without an else branch", especially since `if` can be an expression, with either `do` or parens 15:18
samebchase- I had a major, "is there something wrong with the universe" situation, when the last few statements of my program were just not getting executed, and then I read the documentation
codesections m: say (if True { 'foo' } ~ 'bar'
camelia 5===SORRY!5=== Error while compiling <tmp>
Strange text after block (missing semicolon or comma?)
at <tmp>:1
------> 3say (if True { 'foo' }7⏏5 ~ 'bar'
codesections m: say (if True { 'foo' }) ~ 'bar'
camelia foobar
15:18 MilkmanDan left
codesections I can't speak to the "why" – I'm new and wasn't there – but `when`'s behavior always made sense to me because I thought of it as part of the `given … when` construct, just used without the `given`. Which makes it a bit like the `case` block in switch statements in many langauges (or, the `match` block in Rust, where I was coming from). Not having fall through there made sense to me 15:21
Well, that and I wasn't expecting a `when` to exist, so I first learned it as "if without fallthrough" instead of expecting it to exist 15:22
15:23 MilkmanDan joined
Kaiepi `when` is a bit weird and took me a while to understand how to use it well 15:27
i don't like to think of it like `case` in a `switch` because you can use it anywhere, not just in a `given` 15:28
unlike `if`, it smartmatches $_ against its condition
this makes it useful in stuff like `for` loops as well:
m: for 1..100 { when * %% 15 { say 'FizzBuzz' }; when * %% 3 { say 'Fizz' }; when * %% 5 { say 'Buzz' }; default { say $_ } }
camelia 1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
Fizz
22
23
Fizz
Buzz
26
Fizz
28
29
FizzBuzz
31
32
Fizz
34
Buzz
Fizz
37
38
Fizz
Buzz
41
Fizz…
holyghost ok, I started work on racul, I have some lines for a symbol table already, I will continue later on 15:30
Bzzzt
15:31 wamba left
samebchase- Kaiepi: nice 15:43
15:43 wamba joined 15:45 Voldenet left 15:51 NickSeagull joined 15:52 NickSeagull left 15:53 NickSeagull joined
codesections m: sub f($i) { (^$i).map({CATCH { default { "PLACEHOLDER" } }; if $_ == 5 {die}; $_ × 2})}; say f 10 15:55
camelia (0 2 4 6 8 Nil 12 14 16 18) 15:56
NickSeagull Hi! Raku newcomer here :) Coming from Haskell, I'm loving the language a lot
codesections why is the 6th item in that list ^^^^ `Nil` and not `PLACEHOLDER`?
NickSeagull: Welcome! I'm also fairly new, and came here from Rust 15:57
15:57 Voldenet joined, Voldenet left, Voldenet joined
NickSeagull I'd like to be a bit more involved in the community. Are there any efforts geared towards having LSP ready for Raku? I'd like to work on that :) 15:58
codesections I miss `Option` and expect you'll miss `Maybe`, but otherwise like it a lot :)
lizmat LSP ?
NickSeagull codesections: Thanks! :D
codesections Language Server Protocol
NickSeagull lizmat: Language Server Protocol: microsoft.github.io/language-server-protocol/ 15:59
lizmat ah... I seem to recall it being mentioned before
but I think it was like "a nice to have"
NickSeagull I thought about starting to work on it as a pet project, while getting more in depth with Raku. But didn't want to split efforts if something was going on already 16:00
Looks like there's nothing on GitHub about it though
codesections I've been toying with the idea of building an Emacs extension that's modeled after a striped down version of the LSP – but just focused on documentation rather than autocompletion 16:01
but using the same basic json transport and client/server model 16:02
NickSeagull codesections: Cool! What I like about LSP itself is that it unifies the core part of the language support and then the users can use their favorite editors :) 16:03
codesections Yeah, that is powerful!
Altai-man_ NickSeagull, there is github.com/azawawi/ide-perl6 and github.com/azawawi/app-perl6langserver but I think they are incomplete and want a maintainer, so if you feel like doing a great thing you can try to contact author / fork and go.
NickSeagull This is super helpful Altai-man_ , thanks! 16:04
codesections have you seen this talk by Jonathan Worthington about building the Comma IDE for Raku? www.youtube.com/watch?v=zDP9uUMYrvs 16:05
NickSeagull codesections, Nope, but will look into it now ty
codesections He talks about writing a different compiler/interpreter for the IDE work to deal with the (very different) challenge of real-time autocompletion/etc with program input that is usually invalid 16:06
I *suspect* that a LSP implementation might also need a different compiler backend 16:07
(The Comma one is not currently open source, though I know Johnathan has mentioned the possibility of releasing it at some point)
16:13 zacts left 16:15 sena_kun joined 16:16 Altai-man_ left 16:18 Sgeo joined
Geth doc: 5850cdf925 | (JJ Merelo)++ | doc/Type/Supply.pod6
New functionalities of Supply.tail #3527
16:21
linkable6 Link: docs.raku.org/type/Supply 16:22
DOC#3527 [open]: github.com/Raku/doc/issues/3527 [RFE][docs][help wanted][versions] Checklist for 2020.07
16:22 zacts joined 16:24 zacts left 16:25 zacts joined 16:26 zacts left
NickSeagull I'm confused, why are there two github orgs: Raku and Perl6? 16:31
timotimo the name change ws just recently
NickSeagull timotimo, Yep, but shouldn't it be just a rename of the GH org instead of creating a new one? 16:32
moritz there's a slow migration from Perl6 to Raku
NickSeagull in what way moritz ?
16:34 Zero_Dogg left
moritz repos are being migrated one by one, after careful consideration if we still need it 16:35
NickSeagull Ah cool :) 16:36
Is there a way to typecheck a module using Rakudo? Without running that is 16:39
timotimo very difficult 16:40
BEGIN time stuff, including using modules, and types that are defined with predicates that are code, all make it extra hard
moritz NickSeagull: there are some type errors that are caught at compile time. You can catch those with rakudo -c path/to/file 16:41
but most type errors are run time
timotimo the lack of restrictions on what subclasses are allowed to do with methods also makes things dicey
NickSeagull ah :(
timotimo in C++ for example, you have restrictions what subclasses do with a virtual method's signature, right? 16:42
NickSeagull I see 16:43
Yet for simple functions it'd be nice to have something. E.g.: sub f(Int $x --> Bool){ "hello" }; say f 3.4 16:44
holyghost First write of variable and lambda symbol ADTs are in, in racul
timotimo m: sub f(Int $x){ say "hi" }; f(4.3)
camelia 5===SORRY!5=== Error while compiling <tmp>
Calling f(Rat) will never work with declared signature (Int $x)
at <tmp>:1
------> 3sub f(Int $x){ say "hi" }; 7⏏5f(4.3)
timotimo ^- this is a compile-time error
NickSeagull timotimo, Yep, but if that compilation succeeds, it will get run 16:45
timotimo ah, there's a syntaxcheck flag to rakudo
NickSeagull Would be nice if that rakudo -c checked that
timotimo -c check syntax only (runs BEGIN and CHECK blocks)
NickSeagull With -c I only get "Syntax OK" for that code
timotimo oh, it doesn't 16:46
Geth doc: 1db69d68e1 | (JJ Merelo)++ | doc/Type/Supply.pod6
New functionalities of Supply.head using WhateverCode #3527
linkable6 Link: docs.raku.org/type/Supply
DOC#3527 [open]: github.com/Raku/doc/issues/3527 [RFE][docs][help wanted][versions] Checklist for 2020.07
timotimo in that case, just use --target=optimize instead, lol
because this check currently lives in the optimizer
(among other things it's because subs can be post-declared and thus may not be available for checking at the call site)
Geth doc: acf784f300 | (JJ Merelo)++ | doc/Type/Supply.pod6
New functionalities of Supply.head using WhateverCode #3527
timotimo perhaps RakuAST will allow this to happen earlier 16:47
16:48 Zero_Dogg joined
NickSeagull timotimo, --target=optimize works, thanks! Coming from Haskell, I'm used that mostly everything happens in the compilation phase heh 16:50
timotimo right 16:51
NickSeagull btw timotimo where can I learn more about RakuAST? Is that a library in development?
timotimo raku has some things that you usually get from dependent typing environments, but only checked at run time, and therefore not exhaustive at all like a full agda or coq thing
i'll dig up some links for you 16:52
www.youtube.com/watch?v=91uaaSyrKm0 - this ought t get you started
NickSeagull Thanks will watch it
timotimo, regarding checking types at runtime and ensuring code correctness, how do we work around that? With a TDD approach? 16:53
16:54 NewGreyhawke left
timotimo yeah, perl in general has been big on TDD for a long long time 16:54
NickSeagull But with Raku's type system would it be a thing yet? 16:56
timotimo u.setxkbmap.de/#0-H_jmNFEquodjEBSMW8tQ eeeeexcuse me?
sena_kun timotimo, some of the characters from famous `$character death` are alive though. :P 16:57
NickSeagull timotimo, it looks like its another guy
timotimo impostors trying to ruin our reputation 16:58
NickSeagull heh 16:59
17:07 NewGreyhawke joined
NickSeagull What's the current way of starting a new project? Does one have to write meta6.json by hand and all that jazz? Or am I missing some hidden thing in zef? 17:07
timotimo Comma offers this functionality i think 17:10
can also try App::Assixt, mi6, and similar tools
there is more, i forgot the other names 17:11
NickSeagull timotimo, thanks looking into them 17:12
timotimo i use mi6 for JSON::Fast
"mi6 new Foo::Bar" exists according to its USAGE 17:13
NickSeagull Awesome!
kawaii someone once sent me a one-liner that would identify all of the module namespaces for easy meta population, but I've long since lost it 17:14
codesections NickSeagull: there's also this page of Module dev tools: docs.raku.org/language/modules-extra 17:15
NickSeagull codesections, wow!!! That's what I needed :) 17:16
codesections I can't personally vouch for how up-to-date that page is
I'm still struggling to understand Raku's model for handling exceptions. 17:18
m: sub f { CATCH { default { 42 }}; die}; say f
camelia Nil
codesections why does that return `Nil` instead of `42`?
NickSeagull codesections, perhaps you have to wrap it in try?
17:18 Ven`` left
timotimo blocks return the last thing in them 17:18
NickSeagull m: sub f { try { CATCH { default { 42 }}}; die}; say f
camelia Died
in sub f at <tmp> line 1
in block <unit> at <tmp> line 1
timotimo m: sub f { die; CATCH { default { 42 }}; }; say f 17:19
camelia Nil
timotimo hm, ok
codesections there is a different form, with try as a statement modifier 17:20
sub f { CATCH { default { 42 }}; die}; say f
evalable6 Nil
codesections m: sub f { try { die } // 42 }; say f 17:21
camelia 42
codesections so I know how to get the output I'm looking for, but I'd still like to understand what CATCH is doing
17:36 Ven`` joined
guifa2 CATCH will grab whatever exception was thrown. It's a phaser though, so it's not called in the normal flow 17:42
Most languages require you to use the structure try { … } catch { … }
codesections with you so far 17:43
17:44 markoong joined
guifa2 Just like sometimes it can be cleaner / more readable / etc to use a postfix "if" (esp as a first line in a sub, "DIE If { condition is of secondary importance}" ) 17:44
It can be nice from a readability standpoint to let me know what will happen in the case of a failure in a true
try*
so you can do
17:44 markong left
guifa2 try { CATCH { *this-is-important-to-know* } now we try the stuff } 17:45
phasers will execute at special times, rather than in code order
codesections m: sub f { CATCH { default { say "I caught something. Returning 42"; 42 } }; die }; say f
camelia I caught something. Returning 42
Nil
guifa2 CATCH is a phaser, so you can put the catch wherever you want in a block
and it will only execute if there's an exception
codesections That CATCH block is being triggered, but it's *not* returning anything? 17:46
guifa2 If you want to ignore the error you need to tell CATCH things are okay
use .resume if you want to continue the operations from the point of the exception 17:48
codesections Yeah, but I *don't* want to continue from the point of the exception. I want to abort the current function with a default return value 17:49
guifa2 sub f { say "1. "; CATCH { default { say "Caught"; } }; say "2. "; die; say "3. "; "4." }; say f
evalable6 1.
2.
Caught
Nil
guifa2 ah
then just put in "return foo" :-)
m: sub f { say "1. "; CATCH { default { say "Caught"; .resume } }; say "2. "; die; say "3. "; "4." }; say f
camelia 1.
2.
Caught
3.
4.
guifa2 is what I wanted to say but 17:50
m: sub f { say "1. "; CATCH { default { say "Caught"; return "5." } }; say "2. "; die; say "3. "; "4." }; say f
camelia 1.
2.
Caught
5.
codesections m: sub f { CATCH { default { say "I caught something. Returning 42"; return 42 } }; die }; say f
camelia I caught something. Returning 42
42
codesections oh 17:51
I could have sworn I tried that...
guifa2 Ha, that's how it always goes 17:52
codesections m: sub f($i) { (^$i).map({CATCH { default { return 42 } }; when $_ == 5 { fail }; $_ × 2})}; say f 10 17:53
camelia Attempt to return outside of immediately-enclosing Routine (i.e. `return` execution is outside the dynamic scope of the Routine where `return` was used)
in block at <tmp> line 1
in any at <tmp> line 1
in block <unit> at <tmp> line 1
codesections Or, simplified a bit: 17:56
m: sub f { (1).map({CATCH { default { return 42 } }; die })}; say f
camelia Attempt to return outside of immediately-enclosing Routine (i.e. `return` execution is outside the dynamic scope of the Routine where `return` was used)
in block at <tmp> line 1
in any at <tmp> line 1
in block <unit> at <tmp> line 1
codesections how is that different?
17:56 NewGreyhawke left
guifa2 hmmm 17:59
18:03 Xliff joined
Xliff \o 18:04
guifa2 codesections: if you put it in a try block, it all works fine
err no 18:05
codesections This has *something* to do with the difference between Blocks and Routines. «Blocks that aren't of type Routine (which is a subclass of Block) are transparent to return» 18:06
I'm used to thinking of `map`, etc as Higher Order Functions that take fns as their arguments. But in Raku they take Blocks
which (I think?) makes a subtle but key difference 18:07
18:14 Altai-man_ joined 18:16 sena_kun left
codesections actually, maybe 100% of my confusion comes from `map` or other HoF and not from CATCH at all 18:20
guifa2 codesections: here's a way to make it work: tio.run/##K0gtyjH7/7@4NEkhjatagYtT...xEqFtP//AQ
codesections m: sub f { (1).map({return 42}) }; say f
camelia Attempt to return outside of immediately-enclosing Routine (i.e. `return` execution is outside the dynamic scope of the Routine where `return` was used)
in block <unit> at <tmp> line 1
guifa2 I'm sure what's going on is that map is obscuring the ability to return to locate the main sub
But you can pass a sub into map, and violà, return function works (but it will do it once per map operation) 18:21
codesections interesting – thanks! 18:23
that's exactly the behavior I would have expected (without needing the inner sub)
jdv79 which is exactly what the docs point to:) 18:25
codesections jdv79: how do you mean/which docs? 18:27
jdv79 for some reason when i see pointy block i think sub but i guess semantics are different
docs.raku.org/routine/map#(List)_routine_map 18:28
18:28 melezhik joined
timotimo yeah, pointy blocks aren't Routine, which is where returns happen 18:34
18:35 ab5tract joined
ab5tract I've written a new blog post that I thought some folks here might enjoy: 5ab5traction5.bearblog.dev/for-lov...e-underdog 18:36
codesections timotimo: I get that. But what don't get is why `return` from a pointy block inside a `map` inside a `sub` can't seem to find the sub it's in to return from
m: sub f { (1).map({return 47})}; say f
camelia Attempt to return outside of immediately-enclosing Routine (i.e. `return` execution is outside the dynamic scope of the Routine where `return` was used)
in block <unit> at <tmp> line 1
timotimo is execution actually sill inside the sub, or was the lazy list returned from the sub already? 18:37
codesections ..... ohhh
timotimo that seems to be the case here
codesections light bulb moment
ab5tract I only indirectly discuss Raku in this one because this post is about filling in the perspective that leads me to choose Raku as one of my "chosen few" programming languages.
codesections sub f { eager (1).map({return 47})}; say f 18:38
evalable6 47
codesections It all suddenly makes sense!
guifa2 ab5tract++ 18:40
weekly: 5ab5traction5.bearblog.dev/for-lov...e-underdog
notable6 guifa2, Noted! (weekly)
ab5tract thanks guifa2 :) 18:41
codesections guifa2: so, with timotimo's insight, that means the code you posted to Tio could become 18:42
m: sub f { eager (^2).map({ CATCH { default { return 42 } }; die } ) }; say f
camelia 42
timotimo or your code could become 18:43
m: say 42
camelia 42
guifa2 ;-)
timotimo i'm not sure what exactly the code is trying to do :D
guifa2 codesections: I guess the questino is whether you want one single return or multiple
codesections yeah. And there are pretty good options for both :)
jdv79 fun stuff 18:47
timotimo you can also "last" out of a map, can't you? 19:00
codesections I would assume so. Aren't for loops compiled down to maps? 19:05
CIAvash m: say 1,2,3 ≡ 3,2,1 19:07
camelia 12True21
CIAvash is that expected?
19:08 melezhik left
lizmat CIAvash: yes, because ≡ applies .Set semantics 19:09
ah, you mean, why does it output 12...21 ? 19:10
hmmm... maybe the precedence is off
m: say 1,2,3 (==) 3,2,1
camelia 12True21
lizmat m: say 1,2,3 (<=) 3,2,1
camelia 12True21
CIAvash yeah
lizmat well, if it's off, it's off for all set semantics operators 19:11
m: say (1,2,3) (==) 3,2,1
camelia False21
lizmat m: say (1,2,3) (==) (3,2,1)
camelia True
19:19 kensanata joined 19:20 Noisytoot left, Noisytoot joined 19:28 skids joined
timotimo codesections: no, in some cases we generate a little while loop that repeatedly calls .pull-one on an iterator 19:44
19:48 kensanata left
codesections timotimo: interesting! So when the docs say «The :$label and :$item are useful only internally, since for loops get converted to maps.», I guess that's incorrect/incomplete? 19:51
docs.raku.org/type/Any#routine_map
ab5tract: Nice post :) One way I like to look at that sort of question is by asking *why* something is popular, and then seeing how/if that reason applies to me 19:57
timotimo they are only optimized to a while loop if there are no tricky things
also not in a context where the foor loop would be lazy
codesections so, for programming languages, many are popular because they are good fits for coding in large teams. That might be a real advantage for some use cases, but not for mine
timotimo optimizations happen only if 1) you cannot find out that we've cheated or 2) when we get caught, we can immediately fix stuff as if we never did anything 19:58
ab5tract codesections: thanks!
codesections timotimo: Interesting :D On a related question, is there any semantic difference between a `do for` loop and a `map`?
timotimo not sure, don't think so 19:59
codesections cool
19:59 xinming left 20:00 xinming joined
ab5tract codesections I like that line of questioning. Thanks for sharing :) 20:05
In other news, I've just broken ground on a project that will really, really benefit from the upcoming macro system: github.com/ab5tract/raku-SilverAPL...ctions.pm6
20:15 sena_kun joined
NickSeagull ab5tract, any info on this macro system you talking about? 20:16
20:17 Altai-man_ left
ab5tract NickSeagull only what's been written up recently in the RakuAST proposal/reports 20:17
NickSeagull Links to that? I'm new to Raku :) 20:18
ab5tract jnthn.net/papers/2020-gpw-realizin...macros.mp4 :) 20:20
proposal: news.perlfoundation.org/post/gp_rakuast 20:21
updates (starting from May): news.perlfoundation.org/list?categ...evelopment
NickSeagull Thanks ab5tract :) 20:23
20:24 wamba left
ab5tract enjoy and welcome to raku! 20:26
NickSeagull ^_^ 20:28
20:29 [particle] joined, [particle] left
guifa2 NickSeagull: there's been a fair bit more too, jnthn++ gave a good talk/overview of it at CiC this year 20:31
NickSeagull I'm watching it right now guifa2
guifa2 www.youtube.com/watch?v=91uaaSyrKm0&t
ah haha
NickSeagull If we end up having macros, it'd be interesting to see how implementing a type system in it would work in Raku 20:32
I mean this: www.ccs.neu.edu/home/stchang/pubs/c...pl2017.pdf
The talk gives a lot of intersting ideas for sure 20:34
guifa2 It's going to be great for formatters — as soon as it's released I'll be updating a few of my modules and they should be muuuuch faster 20:41
NickSeagull guifa2, are there any formatters for Raku? :o 20:42
also, is there an estimated release date?
codesections Johnathan's initial grant proposal had a timeline that ran through August: news.perlfoundation.org/post/gp_rakuast 20:46
(That same blog has a couple of updates since then. I don't think they've said anything about the schedule, but they're interesting reading nonetheless) 20:47
guifa2 NickSeagull: you have sprintf built in 20:50
I've been developing international formatters for, e.g., numbers and dates
codesections Oh, I misunderstood what you meant – I thought you were talking about formatters in the sense of "code formatters" (like gofmt, rustfmt, prettier.js, etc) 20:52
20:53 dolmen joined 21:02 markong joined 21:03 markoong left, Kaeipi joined, Kaiepi left
NickSeagull No, I actually meant code formatters lol 21:05
codesections :) Well, I don't *think* there are any – or even any pervasive style guides, for that matter. Part of what I like about Raku is the There's-More-Than-One-Way-To-Do-It philosophy that recognizes that different problems call for different solutions (including differently formatted solutions!) 21:08
Just imo, anyway
sena_kun Comma does code formatting with more or less rich config. 21:09
It's based on intellij API, though, and even considering this it was kind of a pain to implement. :) 21:10
codesections Interesting – I didn't realize that. Does it have a default ruleset online anywhere? (I'd be interested in seeing what line lengths and such it defaults to) 21:11
21:16 leont left 21:19 rindolf left 21:30 Xliff left, dolmen left 21:31 dolmen joined, dolmen left
codesections Raku may rightly pride itself on having fewer "WAT" moments than your typical language, but I will say it's the only language where I type `say .WHAT` with any regularity :D 21:34
ab5tract jnthn are you expecting there to be any significant differences from a user-facing perspective between writing macros against `use experimental :macros` today vs post-RakuAST? (eg, is the experimental flag a result of a missing semantics, a missing syntax, or both?)
codesections hehehe 21:35
timotimo jnthn's on vacation for two weeks :)
ab5tract timotimo good to hear :D 21:36
I finally bought Comma PRo 21:37
*Pro 21:38
very glad I did
timotimo nice
21:39 Ven`` left
ab5tract My brain is definitely taking a while to adjust to the idea of having the power of Raku amplified to the power of an IDE. I have spent so much time with dynamic languages that I never acclimated to the living standards of a modern IDE 21:39
Now that I've been placed over a steaming hot pile of Java at work, I've come to appreciate all these delightful trappings and am really excited to use them with a language that I actually enjoy using :) 21:40
codesections What does it have that impressed/surprised you? I'm not a big IDE fan, but I checked out the Community Edition just to see how the other half lived :D 21:41
ab5tract codesections hard to specifically pin down the benefits of the IDE lifestyle without a whole lot of words 21:42
at this point I still haven't used a whole lot of Comma, but plenty of IntelliJ IDEA
thundergnat Hey, Anybody around have the latest version of JSON::Fast installed that can test a potential bug for me to confirm it isn't just me?
codesections yeah, sure 21:43
ab5tract "of time" xx 2
thundergnat gist.github.com/thundergnat/69457d...f05ec776e8 <-- Try running that and see if it fails.
21:43 Petr37 joined
codesections "Hard to pin down without a whole lot of words", yeah, I feel that way about both vim and emacs, so I know what that's like :) 21:43
NickSeagull My issue with Comma is that it is unable to set the Raku SDK on Win10 :( 21:45
timotimo did you try it with the version that was released just about a week ago?
ab5tract codesections venerable text editors. I've decided to dedicate my limited brain space on that front to really learning `kakoune` . I know quite a bit of `vim` but I still do plenty of things wrong.
thundergnat timotimo: version 0.13? yes
NickSeagull I tried it yesterday for the first time timotimo 21:46
Petr37 good day/night. I need help with my problem. How i can catch redirect url when request any url? Many thanks
ab5tract enough that I decided re-learning them the right way (buffers vs tabs for instance) is functionally more or less equivalent to learning a brand new editor
codesections I get output of: «unexpected R in an object at 15» plus a backtrace 21:47
21:47 mistersir joined
timotimo sorry i meant comma 21:47
ab5tract `kak` is so cool that it even comes with Clippy resurrected in ASCII form (and as an actually useful software helper too)
thundergnat codesections: Yeah, that's what I'm seeing to. I'm pretty sure it's a bug in JSON::Fast
I'll file an issue. Thanks for confirming. 21:48
codesections np 21:49
Petr37 can't find any solutions in Raku ..
timotimo weird, i think to-json shouldn't have changed
oh, hm 21:50
thundergnat timotimo: It was working with previous version and many before that. Suddenly went sideways. I have to assume it was a problem in the latest version.
rypervenche Petr37: You're using Cro?
timotimo ok, str-escape seems to have changed 21:51
er, no, that's also old
Petr37 rypervenche, no, i try WEW module
WWW
thundergnat timotimo: It only seems to be a problem escaping in hash keys, regular string seem to get escaped ok 21:52
timotimo ok got the fix
thundergnat Um. I was just about to file an issue, should I skip it if you are already on top of it? 21:53
21:53 NickSeagull left
codesections But then the PR won't have an issue to close :D 21:53
thundergnat What the heck, it's already written. github.com/timo/json_fast/issues/70 21:54
timotimo uploaded to cpan 21:55
thundergnat Woot! Installed 0.14, seems to be fixed. 21:59
21:59 ab5tract left
timotimo thank you for your contribution 21:59
naturally i also added a test
22:00 sjn joined
thundergnat 18 minutes from first hmm. I think there may be a problem to publicly disseminated fix. Thanks! 22:00
timotimo i hope you're also enjoying liz' rewritten json parser bit
codesections wow, that's pretty amazing. Reminds me of old stories about live-patching an production Lisp server while on a customer support call 22:01
"bug, what bug? Try [reinstalling the package] and see if that fixes it" :D 22:02
rypervenche Petr37: It looks to follow redirects, from what I can tell. Do you have an example where it's not working for you?
thundergnat Um. Well not too much yet. It promptly fell over and corrupted my JSON files the first time I tried to use it. ;) But I'm sure it will grow on me! :D
Petr37 rypervenche, i cant find examples))
22:04 Kaeipi left
rypervenche Petr37: If you do something like this: use WWW; say get 'google.com'; 22:04
It will redirect to 'www.google.com'.
Petr37 rypervenche, when i write get(url),i get redirect url in response.can i use cro for this? 22:05
22:15 Altai-man_ joined 22:16 sena_kun left 22:20 yuplushi left
rypervenche Petr37: What are you trying to ultimately do? 22:24
Petr37 rypervenche, i try extract redirect uri from response. 22:26
22:31 Black_Ribbon joined 22:33 Kaiepi joined
rypervenche Petr37: Ah yeah, WWW doesn't look like it can do that. It's a very simple module. It only has a few subroutines: github.com/raku-community-modules/...ib/WWW.pm6 22:33
Petr37 rypervenche, may be cro can do that? 22:34
rypervenche Someone else may be able to chime in here, but I think you could do it with HTTP::UserAgent, which is what WWW uses on the backend. 22:38
You might need to write the logic in there.
Petr37 rypervenche, thanks. i try 22:48
rypervenche Looks like HTTP::UserAgent also does the redirect without telling you. Hmmm... Maybe someone else will have some ideas.
23:13 pecastro left, eseyman left 23:18 Petr37 left 23:21 eseyman joined 23:38 markong left, MilkmanDan left 23:39 Petr37 joined, MilkmanDan joined