🦋 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.
frost Is there a way to determine whether a string contains Unicode characters? 09:29
lizmat say True 09:31
aren't all characters Unicode ?
frost yeah, but how can I match non ASCII characters in a string? 09:34
moon-child <-[\x00 .. \x127]> ? 09:39
hmm, apparently this doesn't work; not sure why? 09:43
oh no I'm stupid
should be \x7f
lizmat PSA: there will not be a Rakudo Weekly News this week on account of good weather during Easter 09:59
frost moon-child: straight and useful, thanks 10:26
Nemokosch :DD 10:45
Xliff \o 11:38
tellable6 2022-01-06T19:31:00Z #raku-dev <lizmat> .tell Xliff I would put Debian on a 2021 MacMini :-)
2021-01-15T10:38:00Z #moarvm <jnthn> .tell Xliff I assume you're talking about Cro::WebApp? In which case a) no, b) there's a #cro that's good for such questions :)
2021-04-29T13:35:00Z #moarvm <jnthn> .tell Xliff Can't see it happening before Q4 this year; even when most features are there, we'll want all the opts to be too, plus there'll be lots of little details to do (and bug compat with the current compiler frontend)
Xliff m: sub a ( *@a ($a, $b, $c) ) { $b *= 2; @a.say }; a(1, 2, 3) 11:39
camelia Cannot assign to a readonly variable or a value
in sub a at <tmp> line 1
in block <unit> at <tmp> line 1
Xliff Wouldn't it make more sense for decomp variables to be bound to the indicies, here?>
Or is that against spec? 11:40
m: sub a ( *@a ($a, $b is rw, $c) ) { $b *= 2; @a.say }; a(1, 2, 3)
camelia Parameter '$b' expects a writable container (variable) as an argument,
but got '2' (Int) as a value without a container.
in sub a at <tmp> line 1
in block <unit> at <tmp> line 1
Xliff m: sub a ( *@a ($a, $b is rw, $c) ) { $b *= 2; @a.say }; $b = 2; a(1, $b, 3) 11:40
camelia ===SORRY!=== Error while compiling <tmp>
Variable '$b' is not declared. Perhaps you forgot a 'sub' if this was
intended to be part of a signature?
at <tmp>:1
------> a, $b is rw, $c) ) { $b *= 2; @a.say }; ⏏$b = 2; a(1, $b, 3)
Xliff m: sub a ( *@a ($a, $b is rw, $c) ) { $b *= 2; @a.say }; my $b = 2; a(1, $b, 3)
camelia [1 4 3]
Xliff Is there a way to accomplish the above without a writeable container? 11:41
lizmat don't think so?
Xliff lizmat: OK, so why are the decomp elements not bound? 11:50
lizmat because you have 2 $b's in that example ? 11:52
Xliff m: sub a ( *@a ($a, $b, $c) ) { $b *= 2; @a.say }; a(1, 2, 3)
camelia Cannot assign to a readonly variable or a value
in sub a at <tmp> line 1
in block <unit> at <tmp> line 1
Xliff lizmat: ^^
lizmat m: sub a ( *@a ($a, $b is rw, $c) ) { $b *= 2; @a.say }; a(1, 2, 3) 11:53
camelia Parameter '$b' expects a writable container (variable) as an argument,
but got '2' (Int) as a value without a container.
in sub a at <tmp> line 1
in block <unit> at <tmp> line 1
lizmat m: sub a ( *@a ($a, $b is copy, $c) ) { $b *= 2; @a.say }; a(1, 2, 3)
camelia [1 2 3]
lizmat hmmmm
Xliff Yah
lizmat feels meh 11:54
Xliff Hehehe
melezhik . 12:21
melezhik . 12:21
gfldex A cunning individual solved PWC161 in JavaScript, Kotlin, Lua, Postscript, Python, Ruby and Rust. 12:22
gfldex I did read all those implementations and consider myself lucky. :-> 12:23
CIAvash frost: `$str.contains: /<-:Block('Basic Latin')>/` 13:34
tellable6 CIAvash, I'll pass your message to frost
[Coke] .seen sergot 14:06
tellable6 [Coke], I saw sergot 2021-07-20T15:59:00Z in #raku: <sergot> I mean, raku modules :)
[Coke] re-ask: do we have any HTTP request modules that let you pass in auth info? 14:41
HTTP::UserAgent and LWP::Simple don't document any auth parameters that I see 14:42
ah, it's just a documentation issue, found something in t/ that shows me. 14:43
oh, it's using URL based info, not attributes, looks like. OK. 14:44
[Coke] (looks like Cro::HTTP::Client is better for this) 14:52
[Coke] ... and that module is broken on windows (original bug opened 2018) 15:19
*sigh*
japhb [Coke]: What's the bug link? 15:30
[Coke] github.com/raku-community-modules/...e/issues/3
japhb Oh I see -- Cro isn't working on Windows because the dependency IO-Path-ChildSecure is broken there. I was going to say that I didn't expect there was much in Cro itself that should be broken, but I get the dependency issue. 15:32
[Coke] changing the broken test to use '..\\' on windows instead of "../x[308]" passes 15:34
japhb [Coke]: Isn't that testing for insecurity of combining marks, given the difference between utf8 and utf8-c8? 15:36
[Coke] yes; it assumes the path separator is /, though. 15:38
how do we get the correct IO::Spec instance at runtime? there is a method dir-sep which should be called
but it looks like you need to know ahead of time if it's Unix or Win32
m: say IO::Path.dir-sep 15:39
camelia No such method 'dir-sep' for invocant of type 'IO::Path'
in block <unit> at <tmp> line 1
[Coke] m: say IO::Spec::Unix.dir-sep
camelia /
japhb m: say IO::Spec.dir-sep
camelia No such method 'dir-sep' for invocant of type 'IO::Spec'
in block <unit> at <tmp> line 1
japhb Hmmm
[Coke] m: say IO::Path.SPEC.dir-sep 15:39
camelia Cannot look up attributes in a IO::Path type object. Did you forget a '.new'?
in block <unit> at <tmp> line 1
[Coke] m: say IO::Path.new.SPEC.dir-sep 15:40
camelia Must specify a non-empty string as a path
in block <unit> at <tmp> line 1
[Coke] m: say IO::Path.new('.').SPEC.dir-sep
camelia /
[Coke] there we go.
japhb Seems roundabout, but at least more reliable than introspecting $*KERNEL or so 15:41
Oh for heaven's sake
m: say $*SPEC.dir-sep
camelia /
japhb It's kept in a dynvar
[Coke] ah, thanks.
japhb: added comment to ticket, thanks for the simpler version! 15:42
there, one bug from 2018 down.
I'm guessing that using '/' by itself usually "just works" but that by adding the combiner, it skirted the normal checks. 15:43
s/skirted/failed/
japhb [Coke]: Yeah, wouldn't be surprised 15:55
f-a hello folks 16:15
when I try to run a raku program I get
f@mkiii:~/download/power-seeker$ ./power-seeker
Segmentation fault (core dumped)
is there anything I can do to help upstream diagnose this?
[Coke] what version of rakudo are you using? 16:16
And what OS?
f-a Implementing the Raku(tm) programming language v6.d.
Built on MoarVM version 2020.12.
[Coke] japhb: next blocker: Aborting due to test failure: CBOR::Simple:ver<0.1.1>:auth<zef:japhb>
f-a debian stable
[Coke] 2020.12 is ancient, any segfaults there aren't going to be fixed. 16:17
latest release is 2022.03, I think; please update and see if the issue persists?
japhb: github.com/japhb/CBOR-Simple/issues/2 16:20
looks like one of the 127s is a 255 16:21
f-a thanks [Coke] it worked
japhb [Coke]: Bah, OK, will take a look
[Coke] f-a: nice! 16:26
japhb It's NaN. Windows NaN is non-standard, in a way that is not a problem for the CPU, but makes a difference when you want bit-identical output. I thought I handled that everywhere, but I bet I forgot the case of packed numeric arrays. 16:29
[Coke] let me know if you need me to test something locally, happy to 16:32
japhb [Coke]: OK, will do. Multitasking a bit, but will get on this. 16:35
japhb [Coke]: Can you do the test verbosely, using `zef -v test .`, and add that to the GH issue? 16:52
japhb [Coke]: Please try the branch I just pushed: github.com/japhb/CBOR-Simple/tree/...ed-nan-fix 18:12
[Coke] japhb: just got back, will try in a bit 18:15
[Coke] weird. I'm timing out trying to hit github 18:56
japhb That's goofy. 18:57
[Coke] ah, this windows laptop really gets confused when the wifi drops out 19:01
had to forget and re-add
[Coke] tests pass on that branch 19:03
japhb \o/ 19:05
OK, will merge and release that one
[Coke] (&@#$. OK, now getting failures on Log::Timeline
japhb [Coke]: CBOR::Simple 0.1.2 released with the fix 19:19
What's wrong with Log::Timeline?
somebody hi. can I use rakudo-j (jvm backend) with java GUI libs? maybe I can find some topics about it? 19:28
moon-child yes 19:29
somebody ok. I need write something like [10k lines of code and than $dial.show()] or something simpler? hadnt 19:30
moon-child pretty straightforward. I don't remember the details but I did a basic poc a while ago, seemed to work fine 19:31
somebody I have working HelloFX on my Mac. how I should use JavaFX from Raku? 19:37
El_Che somebody: your question does not make any sense 19:41
[Coke] japhb: github.com/jnthn/p6-log-timeline/issues/13 19:53
are you trying to call java from rakudo-j?
.tell somebody stackoverflow.com/questions/271563...from-perl6 19:54
tellable6 [Coke], I'll pass your message to somebody
japhb [Coke]: Ooof, that one's going to be hard to diagnose without a Windows system. :-( 19:56
Tirifto m: say ‘👁’.ords».base(16); say ‘👁️’.ords».base(16); 20:18
camelia (1F441)
(1F441 FE0F)
Tirifto m: say (‘👁’ ~~ /<[ \x[21] .. \x[10FFFF]]>+/); say (‘👁️’ ~~ /<[ \x[21] .. \x[10FFFF]]>+/);
camelia 「👁」
Nil
[Coke] japhb: I'm looking to golf it now. 20:19
Tirifto Does anyone know why the explicitly emoji eye (second string) doesn’t match, when both signs used should be in the provided range?
japhb Tirifto: I suspect it is because the emoji eye grapheme cluster internally gets a synthetic codepoint
Tirifto japhb, something with an out-of-bounds codepoint value? `o` 20:20
drakonis hmm, how do i iterate through a code block object to access each of the lines of code stored inside? 20:21
japhb Tirifto: Yeah, when MoarVM needs to make a grapheme cluster into a single "character" it does it internally by assigning a negative codepoint, which is thus easy to distinguish from a "real" codepoint.
Tirifto: You might have more luck using a different canonicalization, like NFKD. 20:22
drakonis: The code block is opaque, and the lines inside have likely been optimized and rearranged. 20:24
Tirifto m: my $s = Uni.new(‘👁️’.ords); say ($_ ~~ /<[ \x[21] .. \x[10FFFF]]>+/) for $s.NFC, $s.NFD, $s.NFKC, $s.NFKD 20:29
camelia Nil
Nil
Nil
Nil
Tirifto Either that doesn’t help or I’m using them wrong. :/ 20:30
Xliff lizmat: Any thoughts on the decomp issue from earlier?
drakonis ah i see 20:31
okay
Xliff drakonis: The only way to do something like that is a ways off.
drakonis rakuast still too far 20:32
Xliff drakonis, exactly.
drakonis it does make it harder to build the design i had in mind 20:34
trying to make a composable automation system that takes closures 20:35
take one and operate on its insides to send ssh commands 20:36
Tirifto drakonis, I’m guessing a list of blocks wouldn’t do the trick? 20:37
drakonis not really 20:45
it needs a lot of ast manipulation 20:46
a list of blocks isn't particularly ergonomic 20:47
japhb m: say ‘👁️’.NFD.all ~~ (0x21 .. 0x10FFFF) # Tirifto
camelia True
japhb regexes work on Str, not on Uni.
Tirifto Oh, I thought Uni would do its own thing there. 20:48
japhb Tirifto: There have been discussions about allowing regex-like things to work on Uni and Blob directly, but that was NYI last time I checked 20:49
Tirifto japhb, I see. So it seems my best bet would be comparing each individual codepoint to a range, rather than matching Raku’s Str against a Regex? 20:50
japhb There are people who would really like to use a Grammar to take apart an IP datagram, but no such functionality currently exists
Tirifto: Well, what problem are you actually trying to solve?
If you're just wondering if a Str contains valid Unicode codepoints, the answer is yes -- because you can't make an invalid string. 20:51
(Well, without reaching down into the guts of the VM, or scribbling across the memory, I guess.)
Every operation you do on Str's automatically normalizes. 20:52
Tirifto japhb, I’m trying to write a parser for KDL (document language akin to JSON or XML) in Raku, and the specification states which codepoints are allowed for certain parts of it. I’ve been attempting to write a grammar for it. 20:53
drakonis anyways, the gist is that i'm using raku both to write and use the framework 20:54
Tirifto I put an emoji including the eye into a test to see if it would match correctly (since by my understanding it ought to be valid)… and it wouldn’t. :-) 20:55
drakonis the lack of ast macros is certainly a pain in my backside 20:57
because i like the language
japhb Tirifto: I understand if you're trying to make a *strict* parser ... but you can get started making a loose parser instead, and get that working before fighting the battle about codepoints. You could also make a helper function that converts to NFD or so and call that at the appropriate places in your regex using <?{ ... }> 20:58
drakonis: Planned, and actually worked out fairly well by masak, just not ready yet because we want RakuAST first so we can make it Raku-official, rather than just Rakudo-internal. 20:59
drakonis oh yes, i'm waiting for it already 21:00
Voldenet when parsing anything, ignore the spec
drakonis now for a different question, is there a health check on raku's community? 21:01
japhb Huh?
drakonis it always seems like it is one or two accidents from losing the folks that do the heavy lifting 21:02
Tirifto japhb, I’m in the process of finding how far along I am now. Ignoring the tough details at first seems like a good idea, though, as does using <?{…}>. Thank you for the tips! :D 21:03
[Coke] If you're concerned, folks on the RSC are a good resource to talk to.
(for drakonis)
japhb Tirifto: Sure! :-)
drakonis: Best we can do there is encourage folks to learn those heavy lifting tasks. :-) 21:04
drakonis ha, indeed.
Tirifto Voldenet, implying it’s good to write only correct data and parse both correct and incorrect data if that works?
Voldenet Well yes, accept everything in a predictable way (unless you're writing a validator) 21:05
[Coke] I would recommend parsing incorrect data only if it's for diagnostics. "be liberal in what you accept" makes for challening maintenance. 21:06
japhb Tirifto: Yeah, that's "Postel's Law". It has been shown to be a problem if *all* parsers for a format are loose and also different -- HTML showed this. But it's notable that HTML5 is *very* loose but just has a very well-defined junk recovery algorithm, because >90% of HTML on the web is broken.
[Coke] *challenging
japhb++
drakonis the community seems to be comprised mainly of folks that have been around since the very beginning 21:07
but the only way to shift that is through writing useful libraries and projects
japhb drakonis: Can confirm that is *not* true, but there are a few of us old hands still around.
drakonis hm 21:08
that's good to know then
raku could probably use a big announcement post when rakuast lands 21:09
japhb In many communities, you'll find that the people who do the heavy lifting and the "old hands" are heavily-overlapping sets, simply as a matter of having had enough time to learn the harder bits.
drakonis drum up some excitement
japhb Oh yeah, RakuAST is the single biggest blocker for the 6.e language release, which we can indeed celebrate. 21:10
Voldenet I didn't mean being liberal and accepting any incorrect output, only being liberal if it means being able to make the parser easier to maintain – . is acceptable replacement for a-z character class ;) 21:11
Tirifto Thank you, everyone, for your advice! I’ll be choosing a bit of looseness over complexity then, and save the latter for validating. :-) 21:12
japhb Tirifto++ 21:13
drakonis it is always pleasant to see newcomers to the community 21:14
even if i'm one myself
that said, it'd make a fine replacement for something like julia 21:16
minus scientific libraries i guess
Voldenet (Oh, and there has been a lot of security problems because of looseness, but only when parser is expected to be strict - it's important to know whether parser can be used for validation) 21:17
(tons of url-related vulnerabilities were started by using loose parsers to validate urls in proxies)
Tirifto (I guess that if I’m ever going to implement validation separately, it should be possible to make it an optional part of the parsing. `o`) 21:20
drakonis a dumb question 21:31
doesn't grammars also come with a feature to serialize it back to its original format?
or is information related to the structure lost when the parsing is done?
its an awful question 21:32
japhb drakonis: A match object contains references to the original parsed string, along with position information that can tell you where each rule matched within that string. So yes, you can serialize back to the original format trivially, because the original is still hanging around. 21:39
drakonis beautiful.
so you get the serializer for free 21:40
moon-child not really
japhb drakonis: And it runs in O(1) time! ;-)
moon-child you can't make an arbitrary syntax tree and synthesise strings from it without doing any work
but yes, you can identify which sections of source a given match corresponds to 21:41
japhb There is a different problem which is to create exemplars for a Grammar (various random strings that are known to successfully parse). There was a module created for that a while back, but I doubt it's been kept up to date.
drakonis quite a lot of power there 21:42
Voldenet actually, there's two ways 21:44
.orig gives you original string and .Str serializes it
(.Str.WHERE has different address than .orig.WHERE, I'm not sure if it's just a copy)
Xliff Trifito: A bit of advanced processing with grammars would involve a loose match with a subsequent code block which you could use for more advanced tests. 22:02
You might want to keep that in mind.
melezhik . 22:45