🦋 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.
lucs Instead of traversing a huge (for example) capture with for $s ~~ m:g/.../ {...} , can I do something like while $s ~~ /.../ {...} ? 00:01
s/can I/how can I/ 00:02
A plain 'while' like that keeps hitting the first match all the time, not sure how to make it move along.
gfldex lucs: if you want to act as the grammar is parsing, you have to put the code that reacts inside the grammar itself 00:11
lucs: see example 4 in gfldex.wordpress.com/2021/03/11/ra...match-for/
lucs gfldex: Will read that, thanks. 00:12
lucs gfldex: If I understand your example, is it correct to say that the 'take' is evaluating to False? 00:39
dtb does anyone know how to read from stdin. This is not easily findable at docs.raku.org 02:03
moon-child dtb: get to read a single line. words or lines to get a sequence of words or lines (respectively) 02:08
dtb @moon-child Right, what's the RAKU equivalent of my $foo = <STDIN> ? 02:11
moon-child I don't know what <STDIN> is 02:12
to read everything, use slurp
dtb @moon-child OK, I see the get documentation in IO::CatHandle. Thanks; 02:21
raydiak dtb: $*IN is what you're looking for. IO::Handle docs list the various ways to read from it. CatHandle is something different 02:27
moon-child you don't need $*IN. Plain get works implicitly on $*IN 02:28
dtb @moon-child Yeah, my $foo = get; works.
moon-child it would be cool if there were shorthand T@ and T% (or something like that) for Positional[T] and Associative[T] 06:34
so you could say, e.g., sub foo(--> Int@) instead of sub foo(--> Positional[Int])
moritz_ I'm not sure that what Raku needs is more abbreviations :D 06:53
moon-child maybe... 06:55
it's just really weird that Int @x is so much shorter than Positional[Int] \x. Latter seems stuffy and verbose 06:56
frost-lab m: say Int(True); say True.Int 07:47
camelia True
1
moon-child m: say Bool ~~ Int 08:07
camelia True
frost-lab Why is the former Boolean instead of 1 08:08
moon-child frost-lab: because bools are already ints. Bool.Int is special-cased docs.raku.org/routine/Int#enum_Bool 08:12
frost-lab moon-child It makes sense. Thanks. 08:15
nige o/ just trying to get some evidence together for the EU trademark application 08:16
lizmat, do you happen to have stats on the readership for the Raku Weekly? 08:17
I understand that the weekly is branded "Rakudo Weekly News - News about the Raku Programming Language on Rakudo" - it's still useful from the point of view 'about the Raku Programming language'
jjatria guifa++ on the insane hatred for l10n and friends 08:19
I don't like abbreviations that make me think _more_
moon-child wait, l10--ohh 08:26
I don't like that
jraspass i18n, k8s are the other two i know - en.wikipedia.org/wiki/Numeronym 08:27
moon-child I think I've made my peace with i18n. But I still don't _like_ it 08:28
db48x my favorite is l20n 09:22
because it was localization 2.0 09:23
Altreus i18n does have the benefit of not making me type the whole word out every time I need to reference it 09:50
Modules that didn't shorten it that way tended to use the entire line width just to reference them 09:51
db48x I wonder if we could shorten them further 10:54
Altreus you can have apostrophes in raku so yeah 11:21
l'n
db48x lol. I was thinking of emoji, but that works too :) 11:35
guifa Altreus: I think use statements are uncommon enough it’s not a huge concern — it’s in the exported subs for common use stuff. But thankfully Raku can help out there by letting module authors give people options on how stuff get imported in 13:05
Altreus well I've not actually seen it in use since 2009 perl5 code 13:13
:D
guifa Most of the time we can lexically scope like lizmat++ said to avoid probelms, but when they have to be in the same scope, I think it might not be a bad idea to have either a :long option for the use statement, or a dummy .rakumod file (maybe lib/Foo/Bar/CrystalClear.rakumod) that imports a slightly longer version of things just in case 13:16
guifa is afk
lucs I'm expecting to catch all here, but every second one is skipped: 14:25
p6: .say for "Ab Ac Ad Ae Af Ag" ~~ m:g/ A .*? )> [ A | $ ] /;
camelia 「Ab 」
「Ad 」
「Af 」
lucs Is my understanding of )> incorrect? 14:26
Or, how dow I make that work? 14:28
codesections What do you intend `[ A | $ ]` to be doing? (the A there is capturing the A's that aren't in your match)
lucs codesections: My intention is to capture A followed by anything up to the next A. 14:29
And to capture all such groups.
So I'd like to get «「Ab 」␤「Ac 」␤「Ad 」␤「Ae 」␤「Af 」␤「Ag 」␤ 14:30
codesections Ah. In that case, I think you need a lookahead assertion: docs.raku.org/language/regexes#Loo...assertions 14:31
lucs Dang, that's kind of what I thought )> did :)
Will read, thanks.
codesections to express 'match up to the next A without consuming the next A'
lucs Exactly
Aw, I knew that :/ 14:32
lucs is more and more forgetful over the years :(
codesections The )> is similar, but slightly different -- it limits what is part of the capture, but no what is matched (frequently that amounts to the same thing, but not here b/c of the :g) 14:33
lucs codesections: Yep, now I understand.
codesections :)
softmoth dtb, I've created an issue for documenting how to read from stdin. Thanks for reporting the problem. github.com/Raku/doc/issues/3867 14:55
dtb @softmouth Yeah, I found the get documentation in IO:Handle but the one line that called out reading from stdin was confusing. 15:16
dtb @softmouth After Hello World, this seems like a fairly common task for noobs so maybe an example in the Raku by Example 101. 15:18
dpk if i want to use Raku as grep with Raku regexes, how do i do that? raku -pe something or other? 15:25
dpk ah, raku -ne 'say $_ if $_ ~~ /some regex here/' 15:27
dpk remind me to create a proper rakugrep command-line tool some day 15:36
lizmat weekly: www.nntp.perl.org/group/perl.perl5...59770.html 15:55
notable6 lizmat, Noted! (weekly)
lucs dpk: Port ack to Raku. 15:58
dpk that would indeed be handy 16:02
lizmat I have considered it 16:15
and would support anybody who would take that on 16:16
[Coke] probably would need to call it something else, but seems like a good plan! 16:17
El_Che the competence will be hard now that ack has faster alternatives 16:25
tadzik do any of these alternatives actually support Perl regexes? 16:26
El_Che pcre 16:28
(I am an ack user)
ag supports pcre
pretty sure they all do
(even grep supports pcre)
[Coke] I imagine anyone using a raku regex command line tool is more interested in being able to use those specific regexes. 16:29
El_Che I don't know 16:30
the readability of raku regexes is a huge win for programs
for a one liner it's less relevant
they tend to be less complex, I would think 16:31
[Coke] ... right, so if they *wanted* them, they're going to be more concerned about having the regexes than the speed. otherwise just use the variety of existing tools. 16:36
El_Che it would be a cool dev tool to learn regexes on top 16:39
kleb hi folks! why do I get "TTT" as output to this program? 17:39
#!/usr/bin/env raku
use v6;
my $a = False;
my $b = True;
my $c = False;
given ($a, $b, $c) {
    when (False, False, False) { say "FFF"; }
    when (False, False, True)  { say "FFT"; }
    when (False, True,  False) { say "FTF"; }
    when (False, True,  True)  { say "FTT"; }
    when (True,  False, False) { say "TFF"; }
    when (True,  False, True)  { say "TFT"; }
    when (True,  True,  False) { say "TTF"; }
    when (True,  True,  True)  { say "TTT"; }
    default {
        say "default";
    }
evalable6 default
codesections m: say $_ ~~ True 17:40
camelia Potential difficulties:
Smartmatch against True always matches; if you mean to test the topic for truthiness, use :so or *.so or ?* instead
at <tmp>:1
------> 3say $_ ~~ 7⏏5True
True
codesections kleb: ^^^^
True always matches and False always doesn't
kleb ah, gotcha 17:41
interesting
lizmat this allows you to e.g. use a condition in a grep, as grep just does a smartmatch on what it is given
[Coke] if you had just "when True" or "when False" it would give you that same warning. I suspect the (T,T,T) hides it enough 17:42
kleb i think i understand the root of the problem, but am still unclear as to how i can achieve the sort of behavior i am looking for 17:44
what is the cleanest way for me to select the FTF branch? 17:46
*if i have three booleans, and want to dispatch to a code snippet depending on their relative values 17:47
codesections m: say (False, True, False) ~~ (:not, :so, :not)
camelia True
kleb ah, bingo! 17:48
i didn't realize I could put the :not :so in those locations
thanks folks!
codesections I _think_ that works. I'm still getting my head around how smartmatching and destructuring (in signatures) interact/compare
kleb it does! i just tried it
#!/usr/bin/env raku 17:49
use v6;
my $a = False;
my $b = True;
my $c = False;
given ($a, $b, $c) {
    when (:not, :not, :not) { say "FFF"; }
    when (:not, :not, :so)  { say "FFT"; }
    when (:not, :so,  :not) { say "FTF"; }
    when (:not, :so,  :so)  { say "FTT"; }
    when (:so,  :not, :not) { say "TFF"; }
    when (:so,  :not, :so)  { say "TFT"; }
    when (:so,  :so,  :not) { say "TTF"; }
    when (:so,  :so,  :so)  { say "TTT"; }
    default {
        say "default";
    }
evalable6 default
kleb }
lizmat kleb: please use a gist for that :-)
pasting pieces of code of several lines 17:50
kleb how is that done? sorry i am new to this functionality
m: say "Test"; 17:51
camelia Test
lizmat kleb: do you have a Github account ? 17:52
kleb yes
lizmat then go to: gist.github.com
enter your code there in a gist, and then post the URL here
gist.github.com/lizmat/5315ff935c7...248ca475ed 17:53
kleb gotcha - is this preferred over pastebin? 17:54
lizmat no, pastebin is also ok
kleb i can do pastebin.com/raw/svAktZYF
lizmat any type of pastebin 17:55
yup
kleb cool! thanks for the tips!
gtg!
PlayPause9 I'm new to Linux, I'm on Linux Mint Cinnamon and I want to uninstall and reinstall Comma. Does anyone know how I do this? 18:14
lizmat sena_kun ^^ 18:16
El_Che do you use the standalone comma or the plugin for intellij?
sena_kun asks the same question
lizmat :-) 18:17
PlayPause9 Each time I want to run Comma, I have to do "./bin/comma.sh" in the terminal. I think that's standalone.
El_Che PlayPause9: just rm -rf the directory where you installed it
sena_kun El_Che++
El_Che PlayPause9: you had a problem I remember vaguely 18:19
PlayPause9 What does it mean to "rm -rf"? Can you give further details?
El_Che yes 18:20
rm is the remove file command in UNIX/Linux
the option -r means recursive (== also remove directories)
the option -f means force 18:21
you can also use a file browser like nautilus to delete the directory by selecting it and pressing delete
PlayPause9 Ah, alright. Thanks. So, how do I use "rm -rf" when trying to uninstall Comma? What would the Terminal look like? 18:33
El_Che I use Ubuntu and the terminal shortcut is ctrl+shift+t 18:35
look in applications, there should be a terminal there 18:36
dtb How are unicode characters output with the say function?
PlayPause9 Oh sorry El Che, I wasn't clear. I mean, what do I put into the terminal? 18:38
El_Che you type it, but first you need to make sure what the directory is 18:39
otherwise you'll delete other stuff
evalable6: say "😏"
evalable6 😏
raydiak PlayPause9: they mean just delete the directory where Comma is. if you aren't familiar with the terminal, you may want to just use your file manager of choice to delete the directory. I wouldn't start learning the terminal with potentially disasterous commands like "rm -rf" if I were you 18:43
PlayPause9 raydiak I see. Thank you. Thank you too El Che for trying to help me. 18:45
I assume it's okay that I use the file manager that comes with Linux Mint itself?
raydiak yes, anything that can delete the directory should work fine 18:46
PlayPause9 Alright, thanks.
raydiak just make sure you're comfortable with it and know that you're deleting the correct directory. you're welcome of course 18:47
dtb @el_che say "U+1F600"
Doesn't work.
PlayPause9 How do I do file and/or folder searches on Linux btw? 18:48
raydiak there's usually a search feature built in to the file manager, often a button that looks like a magnifying glass 18:49
El_Che dtb: docs.raku.org/language/unicode#Ent..._sequences 18:50
MasterDuke 'grep' to search inside files, 'find' to find files by name/size/date/etc
tellable6 2021-04-09T02:50:32Z #raku-dev <vrurg> MasterDuke I have updated gist.github.com/vrurg/d824dc212991...45e5c2e7be with the last blin output. This time against a26ff40 18:51
El_Che PlayPause9: the graphical programs should be pretty evident (e.g. nautilus on Ubuntu has a search bar on top)
dtb @El_Che so if I read that right you specify the unicode by decimal \c or hex \x... Why no \u to just enter the unicode value? 18:52
El_Che PlayPause9: I would suggest to read a base UNIX/LInux course for basic CLI actions.
the invested time will be won many times
japhb Looking for feedback on a design approach, any takers welcome. I'm working on an interruptable input library (meaning, that real time events can interrupt the user's input, and the library will pause, handle the realtime event (which can include writing updates somewhere on the screen) and then return to the user's input in progress). The problem is that raw communication with a TTY has an underlying 18:53
uniprocessing assumption -- querying the VT emulator involves printing a query string, then reading a query response and parsing it; this entirely breaks if you want to multitask TTY I/O. So my thought is to have a TTY controller in its own thread, with a command channel to interface with other threads. The command channel allows the rest of the program to say things like "read a raw character" or "print
this string" or "perform this query" or what have you, as indivisible operations. Operations that need a response can include a promise in the command packet that will be kept with the result. Can anyone see problems with this approach?
PlayPause9 Thanks everyone. The Linux Mint start-menu bar doesn't have anything resembling a search feature (e.g. no magnifying glass) but nonetheless, I'll use find. Thanks for your patience. 18:56
raydiak dtb: \u would be ambiguous as to whether you're specifying the codepoint in decimal (\c) or hex (\x) 18:58
dtb @raydiak but it wouldn't be ambiguous as to whether you're specifying the codepoint in unicode. 19:03
other languages provide the u+##### pathern 19:04
japhb dtb: In Raku, it's all unicode. 19:05
raydiak a unicode codepoint can be specified many ways. the hex representation you asked about initially is only one way to specify that same character
dtb @japhb Ah, now I see. say "\x1F600" works 19:06
japhb m: say "\c[BUTTERFLY]"; # dtb 19:07
camelia 🦋
dtb @japhb yeah I'm not digging the named approach.
japhb The entire unicode database is included in Rakudo.
raydiak m: say "\c128512" eq "\x1f600" 19:08
camelia True
dtb @raydiak... Thanks, I see the pattern now.
raydiak you're welcome 19:09
japhb dtb: I find the numeric approach works well when I'm dealing with a series of codepoints where their relative sequence has meaning, like the 1/8th block characters. But I prefer the named version when I just want to print some symbols/glyphs. 19:10
db48x using the names really helps when you have to make some changes 6 months or a year after writing the code 19:11
japhb It helps that I have a helper program for searching the unicode DB. :-)
db48x: Oh yeah, definitely that too.
db48x as for your architecture question, having a thread that has sole responsibility for talking to the terminal seems entirely reasonable to me 19:13
I’ve not done much work in that area, but the one relevant program that I have worked on has developed more and more towards that design 19:14
japhb db48x: Ah, thank you. 19:14
db48x some things still just call printf, but most of the output is done by sending messages to a thread 19:14
messages like “update my progress bar to 23%” 19:15
japhb OK, my idea matches someone's reality at least. :-) 19:16
db48x the only complicated thing that it does is have a synchronization message
it’s just an empty message that expects an empty reply 19:17
japhb db48x: Oh, so other parts can say "I want to know when the TTY thread is caught up with all my requests"?
db48x and we just use it to ensure that all log messages have been printed out before we exit 19:18
exactly, yea
japhb OK, that's a good thought, thanks.
db48x but aside from that, it is very crude. just barely enough code to make things work 19:19
japhb db48x: Honestly, I've been kinda working my way up from the bottom anyway. "What's the minimum I need to change to support this feature?" The jump to the architecture idea above came when my current code couldn't handle the case of a network message arriving asynchronously and needing to change the screen while the line edit routine was in its read loop. 19:21
PlayPause9 I want to report something very strange guys. I did a full search on my PC for "comma" and I never found anything that resembled a folder that Comma had been installed to. I then used the terminal to run the comma.sh file that was (amongst other stuff) extracted from the comma tarball that I'd already downloaded and then Comma loads my most recent project and file. It does seem like it is installed in some way, how else can it "remember" previous
work? I'm not running it out of the Start-Menu though so perhaps this really is the IntelliJ thing rather than a proper installation? If Comma is installed, I want to uninstall it so I can reinstall it but that might not be necessary.
japhb (Or in particular, for this to happen on *multiple* network connections) 19:22
db48x japhb: that’s my preference for how to do things as well
PlayPause9 My question then would be: do you think I installed Comma? 19:24
MasterDuke PlayPause9: it puts config files and such in a file in your home directory. '.Comma<something something>version'
it then looks for those to import settings from a previous version 19:25
PlayPause9 I see. I had to turn on "see hidden files" to find it but yeah, I found the .config folder and I found Comma. It's in an "Edument Central Europe" folder. I've never heard of Edument before but oh well. I believe I can just delete this and that'll be that. 19:27
lizmat Edument Central Europe is the company making Comma 19:28
PlayPause9 Meanwhile, Comma is FOSS? 19:29
lizmat many parts of it are
PlayPause9 I see. Despite this, Comma is still the preferred Raku IDE in the Raku community? 19:30
lizmat yes 19:30
as it is created by the current Raku architect: Jonathan Worthington 19:31
raydiak it's a very good tool, and not an evil company trying to strong-arm you into paying. I'm fairly certain that you won't find better Raku support in any other IDE in existence, free or otherwise 19:41
PlayPause9 I see. Thanks for the responses guys. I just checked the Raku Wikipedia page and it had no mention of this "Jonathan Worthington" fellow. Larry Wall is mentioned as its creator so I was of the opinion that Mr. Wall was still the lead developer for the language (I believe such people are referred to as "Benevolent Dictators"). The Wiki page makes no mention of Mr. Wall stepping down. When did this happen and when did Mr. Worthington come into the 19:52
picture?
lizmat github.com/MoarVM/MoarVM/graphs/contributors # I'd say around 2012 ? 19:57
well, actually before that 19:58
github.com/Raku/CCR/blob/main/Rema.../README.md 19:59
first recovered blog post of Jonathan from 2006
PlayPause9: Mr. Wall was never much involved in the actual implementations 20:00
lizmat still listed as #6 at github.com/rakudo/rakudo/graphs/contributors 20:01
PlayPause9 I see. It's a bit strange that Mr. Wall is credited as the creator of Raku and yet, based off of your words, was mostly uninvolved with its development. There seems to be a bit more to this than I initially expected but nonetheless, I'm sure I can read about Raku's development some other time. Thanks lizmat. 20:06
lizmat no, he was involved alright
PlayPause9 Then again, you said "implementation", rather than development. I think there's a nuance here that I'm not getting. 20:07
lizmat just not directly in the implementations
PlayPause9 Right.
lizmat design.raku.org
that was mostly Mr. Walls work
as were the apocalypses before that 20:08
PlayPause9 Alright. Thanks lizmat. 20:10
MasterDuke he did STD.pm mostly by himself, right?
softmoth "no mention of this 'Jonathan Worthington'" That is a major oversight in the Wikipedia page :)
and viv, IIRC 20:11
lizmat yes, he did 20:13
a bit before my time, really :-)
softmoth Well, maybe not a major oversight. It's a pretty terse history. Damien is mentioned, but Audrey isn't, for example
lizmat well, feel free to update those pages
lizmat is still being blocked because of ore new ISP :-(
softmoth :-/
lizmat I mean, the 500Mbit is nice 20:14
s/ore/our
japhb OK, I feel like there's a hole in my memory right now. Is there a way to detect in a *cross-platform*, *non-Nativecall* way that a standard handle (not a socket) is ready to read or write, *without blocking*? The best option I've seen so far is the epoll module, but that's not cross-platform. 21:42
moon-child japhb: possibly .Supply.Channel.poll? 21:55
japhb moon-child: Hmmm, interesting idea. Might require some work to do that with raw I/O, but I'll throw that idea in my mental blender. 21:59
japhb has a sinking feeling they're about to read a couple more chapters of Advanced Programming in the Unix Environment ... 22:00
moon-child i mean if nativecall is ok it's literally just poll({fd, POLLOUT}, 1, 0) 22:01
japhb moon-child: More to it than that ... I'm discovering that I have just crossed the threshold from "knowing a few things is good" to "not knowing All The Things will be a mess". 22:42