🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). This channel is logged for the purpose of keeping a history about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | Log inspection is getting closer to beta. If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 25 August 2021.
moon-child somebody remind me how I make a regex from a string again? 03:18
moon-child hm, looks like <{thestring}> 03:24
mfiano Hello all. I'm a newbie exploring the terrain...coming from CL :) 08:55
eseyman hello and welcome, mfiano 08:57
mfiano Thanks. I was told this language is semantically very similar to CL, so I'll give it a fair chance. 08:58
(I haven't used Perl for about 20 years since I was in college, and I think I forgot everything about it)
El_Che there is no perl knowledge needed to learn raku 08:59
mfiano Good. I have exclusively used CL for many years. 09:01
lizmat mfiano: feels to me you will be able to write more self-documenting code in Raku :-)
tellable6 2021-10-07T21:04:15Z #raku <[Coke]> lizmat any suggestions for monochromec's request for someone to talk about Raku on a podcast?
mfiano lizmat: Why is that?
lizmat I was looking at the description at en.wikipedia.org/wiki/Control_Language
mfiano That is not the CL I was referring to
lizmat aaah... *phew* :-) 09:02
mfiano Common Lisp :)
lizmat ah, I see ok
lizmat mfiano: I assume you read www.codesections.com/blog/raku-lisp-impression/ and the discussion on /r/rakulang: www.reddit.com/r/rakulang/comments...mpression/ 09:03
mfiano Does Rakudo implement all of the specification. I am a little hesitant on learning a language that has a specification maintained by the same party as implementors. ANSI defines the CL standard, in contrast. 09:04
History has been terrible for languages teams that specify the language themselves/only have 1 implementation 09:05
lizmat: Not yet, will do. 09:06
lizmat mfiano: in Raku, it is roast that defines the implementation, really 09:07
Nemokosch > History has been terrible for languages teams that specify the language themselves/only have 1 implementation
there is a difference between the two statements, though
lizmat but at the moment, there is only 1 implementation in active development, so there is a risk indeed...
mfiano I see 09:08
That's ok. I can ignore that for now. 09:09
My other hesitation is more serious.
Nemokosch Why is that? 09:10
mfiano I am mostly a low-level game engine developer, and data visualization programmer. As such I have used the extremely performant Common Lisp for about 20 years. My research leads me to believe Rakudo currently struggles to perform better than Python in some simple programs I've seen. I still think Raku is interesting to learn, but I just don't know what I'd use it for. 09:11
Nemokosch It doesn't seem like Python suffered by not having an external standard 09:12
mfiano This is a issue of performance, not standardization. As I mentioned, I am ignoring the previous issue for now.
Nemokosch I can't see where you mentioned that 09:13
mfiano mfiano │ That's ok. I can ignore that for now.
lizmat well, most of the work on the new-disp the past 18 months was about performance
mfiano But is it suitable for soft real-time applications? 09:14
Nemokosch Well okay, that said nothing about performance 😅 whatever
lizmat and that was only setting up the foundation on which to implement further optimzations
mfiano: I know people use it in audio applications...
mfiano Is it garbage collected?
lizmat yes
mfiano Good.
Do you know what type of GC Rakudo uses? 09:15
I hope pauseless
lizmat moarvm.org/features.html 09:16
at the moment, GC is still "stop the world" type, afaik
you might want to ask MoarVM specific questions on the #moarvm channel though
"When multiple threads are running, collection can run in parallel (meaning that the world is stopped, and multiple threads work on the collection job to get it done more swiftly)." 09:17
mfiano I see, so not Pauseless, but parallel, so pretty good. 09:21
lizmat yeah... plans are to make it pauseless as well, but getting it working in parallel without too many bugs, is already quite an achievement :-) 09:25
mfiano Indeed 09:26
Thanks for answering my questions so far. I guess I'll just keep reading the documentation to get a better idea. 09:29
lizmat you're welcome... of course there's no such thing as actually trying stuff 09:30
also, you might want to check out Comma (commaide.com) if you're into IDE's :-)
mfiano I'm not. I prefer vim :)
But thanks 09:31
lizmat mfiano: perhaps a recent discussion could be of interest in that respect: www.reddit.com/r/rakulang/comments...n_writing/ 09:32
mfiano Are there any notable published books? 09:47
lizmat raku.org/resources/ has a list 09:51
some of them still refer to Perl 6, but you get the gist :-)
mfiano That leads me to another question 09:52
> The Perl 6 programming language has a long story. It emerged in 2000 and got its first stable specification in 2015. "Perl 6 at a Glance" is the first book based on the standard 6.c of the language.
If I were to read a Perl 6 reference rather than a Raku one, how do I know by how much the language differs by? 09:54
It's unclear to me the version history of the specification other than a commit log in the roast repository.
Similarly, if I were to read a "Raku" book, how will I know how much it differs from the specification version that Rakudo targets? 09:56
lizmat mfiano: it is basically s/Perl 6/Raku
mfiano Then what is 6.c? 09:57
lizmat any differences you might find between the modern Perl 6 books and Raku, is what you would also see between versions of Raku
6.c is the language version released in 2015
6.d is the language version released in 2018 09:58
mfiano I see. I'm not used to this and I can see it being a major problem for compatible and future-proof code. In CL, there is only one version of the standard that will never change because it is defined by an international standards organization and the language definition is powerful enough for users to extend any aspect.
lizmat late this year / early next year 6.e will be released
it is the intent that any Raku implementation should support up to 3 language versions back transparently 09:59
mfiano I see. It will just take me some getting used to, because in CL, there is code from the 1960's that will still run. 10:00
lizmat when you say "use v6.c" in a compilation unit, you are guaranteed the semantics of that language version in that compilation unit
likewise, if you load a module with a version specification, you are guaranteed *that* version of the module 10:01
use Foo::Bar:ver<0.42>
mfiano Ok 10:03
lizmat multiple versions of the same module can be installed at the same time :-)
and be used inside the same program, as imports are lexical 10:04
mfiano I will admit, the feature (from Lisp) that attracts me the most is multiple dispatch
lizmat m: sub ok(\a) { say "foo" }; { use Test; ok 1 }; ok 1 10:05
camelia ok 1 -
foo
lizmat mfiano: yeah, multiple dispatch is a very nice and useful feature :-)
mfiano Does Raku have a meta object protocol? 10:06
Doubtful, but worth asking :)
It seems there is no OpenGL bindings module? That shoots down about 90% of the things I'd use it for. 10:20
lizmat mfiano: yes, Raku most definitely has a MOP 10:23
lizmat mfiano: docs.raku.org/language/mop 10:24
whatnext hello all :) I have a question: what is the best way to alias long package names? I am struggling to find any reference to this
moritz_ a super simple way is constant ShortName = A::Much::Longer::Name; 10:26
whatnext ah ok - that looks good! 10:27
moritz_ m: constant I = Int; sub f(I) { }; f 'foo';
camelia 5===SORRY!5=== Error while compiling <tmp>
Calling f(Str) will never work with declared signature (Int)
at <tmp>:1
------> 3constant I = Int; sub f(I) { }; 7⏏5f 'foo';
moritz_ you can see in this example that you can use the aliased name this way in type constraints, and the compile-time checker picks up on it
(because constants are evaluated at compile time)
whatnext yes that looks like the answer - thanks! 10:28
mfiano I see. No GPU driver API support yet is going to be a deal-breaker. I'll check back some other time. 10:29
github.com/Raku/raku-most-wanted/b...interfaces
Lists both OpenGL and Vulkan as wanted and not yet even WIP
I understand though. It took years for us to do so in Lisp 10:30
lizmat mfiano 10:42
too bad... please do check in again from time to time
patrickb Raku can interface directly with C libraries / functions. So especially with something like the OpenGL API a dedicated wrapper might be something you don't actually need in practice. 10:43
Nemokosch Isn't using Lisp for OpenGL pretty uncommon per se? 10:46
timo mfiano: very possibly out of date, that repo, tbh 11:30
github.com/YellowApple/p6-GLFW hasn't been touched in a while, though 11:31
but SDL2::Raw already handles creating opengl context for you and you can bind all the opengl functions by hand as you encounter the ones you need haha
timo github.com/bartschuller/perl6-OpenGL is also a thing 11:32
but that is also untouched for a long while
fortunately opengl uses basically no structs? vulkan on the other hand ... oof 11:35
moritz_ structs aren't a problem, if the C API treats them as opaque (gives you getters/setters/constructors/destructors for them) 14:25
timo vulkan doesn't do that, to my knowledge 14:29
RaycatWhoDat Running into a bit of an issue implementing the `[` and `]` operators in BF: github.com/RayMPerry/kitchen-sink/...r.raku#L25 14:31
How can I backtrack or change the currently matched target? 14:32
Or am I thinking about this wrong?
timo you may want to just store the positions of all brackets and match the pairs up later
or you can have a "match bf code between matching brackets" style 14:33
in which case bf programs with unmatched brackets will fail to parse if you don't put in an error handling case
oh, you're trying to have the interpreter in the actions methods
i guess in that case the second one is your best bet 14:34
but causing the action methods for the inner code to re-run sounds tricky
tonyo_ RaycatWhoDat: are you trying to find matched `[` `]` in a regex?
RaycatWhoDat tonyo_: Kinda. I'm trying to loop inside of the actions. But more generally, I'm just trying to figure out if you can ignore certain matches or move the pointer back to a previous `[` 14:37
previous Match *
RaycatWhoDat However, I can also accept that grammars aren't really structured for that kind of movement 14:38
It would be nice tho
tonyo_ it might be easier instead of trying interpret it directly to turn it into a raku code block, like an ast 14:39
[ -> while <whatever> {, ] -> }
RaycatWhoDat Got it. I'll try all three. 14:40
tonyo_ the grammar/action would be able to produce an AST for that and then the interpreter just runs the ast (then you can cache it, show the execution plan, etc) 15:01
mykhal Hi, i'm looking fort short rakudiom (Raku idiom) for Python-like stripping, e.g. "abarbaraaaa".strip("a") -> "barbar", without regexp. Could't trim(Str, Str) work like that? Aren't they trimming always something in reality, instead of whitespace-like nothing? 16:17
moritz_ why without regex? 16:24
mykhal it would be 2 OR-ed regexp, too tedious 16:26
.. s/exp/exps/ 16:27
Altreus wat :) 16:28
moritz_ $s.subst(/^a+/, '').subst(/a+$/, '') 16:29
codesections mykhal: If you _really_ want to avoid a Regex, there are plenty of ways to do so. Here's the first one that came to mind, which is a bit verbose but reads well enough: 16:36
m: with "abarbaraaaa" { say .substr: .comb.first(* ne 'a'):k, .comb.first(:end, * ne 'a'):k }
camelia barbar
codesections That said, if you're looking for an _idiomatic_ Raku solution, then yeah, a regex (or two in a chain as moritz_ showed) is the way to go. 16:37
Altreus that definitely counts as any definition of "tedious" I can come up with :) 16:38
mykhal pity, however in bash it's not trivial as well (unlike for one-ended solution) 16:40
codesections That's fair :) I'd probably do it with a regex myself, though not one with any ors. I'd use S/^a* (.*?) a*$/$0/
m: say with "abarbaraaaa" { S/^a* (.*?) a*$/$0/} 16:41
camelia 5===SORRY!5=== Error while compiling <tmp>
Unsupported use of bare "say". In Raku please use: .say if you meant
to call it as a method on $_, or use an explicit invocant or argument,
or use &say to refer to the function as a noun.
at <tmp…
codesections m: with "abarbaraaaa" { say S/^a* (.*?) a*$/$0/}
camelia barbar
codesections m: say "abarbaraaaa".subst: /^a* (.*?) a*$/, $0 # if you prefer the method call form 16:42
camelia Use of Nil in string context

in block <unit> at <tmp> line 1
mykhal stril not fully compliant with DRY principle :) 16:49
wouldn't you love feature req. for trim solution mentones? fortunately, currently it raises error, instead of doing something (else) 16:51
Altreus Perfect is the enemy of good
mykhal m: "abarbaraaa".trim("a")
camelia Too many positionals passed; expected 1 argument but got 2
in block <unit> at <tmp> line 1
mykhal mykhal: ???? s/mentones/mentioned/ 16:53
or m: "abarbaraaa".trim(/a+/) 16:54
Altreus you could also use MONKEY-TYPING; and augment Str :) 16:57
mykhal right, but that would be mre tedous than using regexp ;) 17:06
today 'm lossy 17:07
Altreus but DRYer 17:08
you can't have both, apparently
mykhal in curr. ver. 17:09
SmokeMachine have EXPORT-POST-CHECK-PASS already changed name? I'm trying to use it on RakuAST branch with RAKUDO_RAKUAST env var set to 1 with no luck 18:59
Geth doc: a354a2dfa1 | (Marcel Timmerman)++ (committed using GitHub Web editor) | doc/Language/concurrency.pod6
Update concurrency.pod6
19:17
linkable6 Link: docs.raku.org/language/concurrency 19:18