🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel! Set by lizmat on 6 September 2022. |
|||
00:45
yewscion joined
00:48
yewscion left
|
|||
elcaro | Someone in another language community just posted a screenshot examples.raku.org/categories/cookb...mming.html | 00:54 | |
None of those old cookbook examples appear to work... In fact, that whole Examples page is outdated and possible should be removed | |||
Or at least put behind a link stating that it's legacy information and may be out of date | 00:55 | ||
Rather than linked from the main raku.org page | |||
Not to mention the header says "Perl 6 Examples" | 01:08 | ||
01:13
wbooze joined
01:23
wbooze left
01:40
comborico1611 joined
02:30
SrainUser left
02:43
JimmyZhuo joined
02:52
kylese left
02:53
kylese joined
03:02
JimmyZhuo left
03:05
JimmyZhuo joined
03:15
kylese left,
kylese joined
04:13
Aedil joined
05:37
JimmyZhuo left
07:08
comborico1611 left
07:29
kst joined
07:56
yewscion joined
07:59
yewscion left
08:09
derpydoo joined
08:21
jjido joined
08:39
jjido left
08:43
Sgeo left
09:28
jpn joined
09:29
sena_kun joined
09:45
sena_kun left
09:54
euandreh left
|
|||
itsrakanott | That's okay. I actually just didn't name my file .rakumod, Huh. | 09:58 | |
But that got me interested, WHEN is it a file length issue? | 09:59 | ||
lizmat | for clarity: the length of the path of a file has been an issue on Windows before 2025.02, *not* the length of the file afaik | 10:08 | |
itsrakanott | dang | 10:13 | |
10:15
derpydoo left
10:17
JimmyZhuo joined
10:56
derpydoo joined
11:12
melezhik joined
|
|||
melezhik | o/ | 11:12 | |
dropped some experemental feature called "replace" that might turn Sparrow into awk/sed reaplacement - if someone is interested - github.com/melezhik/Sparrow6/blob/...l-features | 11:13 | ||
reaplacement sounds funny ) buy I meant replacement )) | 11:14 | ||
11:17
Aedil left
11:28
melezhik left
|
|||
itsrakanott | i think that was me in Uiua server LOL | 11:38 | |
Such a small world | |||
11:46
melezhik joined
11:56
melezhik left
12:08
peder left
12:15
peder joined
12:21
derpydoo left
12:33
jpn left
|
|||
tbrowder | hi, need some clarity on number handling. "0b1111" can be turned into its decimal equiv with .=Numeric but it doesn't show True with testing with ~~ as a NumStr or ~~ Numeric. is there a Rakuis way to show that Numeriic attribute? | 12:34 | |
12:34
melezhik joined
|
|||
tbrowder | all i can get is it is a Str | 12:34 | |
melezhik | . | 12:35 | |
tbrowder | m: my $b = "0b11111"; $b.= Numeric | ||
camelia | ( no output ) | ||
tbrowder | m: my $b="0b11111"; say $b.=Numeric | 12:36 | |
camelia | 31 | 12:37 | |
lizmat | m: my $b = "0b11111"; $b .= Numeric; dd $b ~~ Numeric | ||
camelia | Bool::True | ||
lizmat | m: my $b = "0b11111"; dd ($b .= Numeric) ~~ Numeric | ||
camelia | Bool::True | ||
lizmat | precedence issue maybe ? | 12:38 | |
tbrowder | hm, i tried ($b ~~ Numeric).so and got False | 12:39 | |
lizmat | m: my $b = "0b11111"; dd ($b .= Numeric).so | 12:40 | |
camelia | Bool::True | ||
tbrowder | m: my $b="0b1111"; say ($b .= Numeric).so | 12:41 | |
camelia | True | ||
12:44
jpn joined
|
|||
tbrowder | maybe i'm going about it the wrong way. what i would like is to have $b as an arg to a sub and i would like a type in front that would test for its Numeric potential as a Str | 12:45 | |
in other words, the arg should be a NumStr. duh, maybe k | 12:46 | ||
maybe i haven't actually tried that yet... | |||
lizmat | m: sub a(Str:D $a where *.Numeric) { dd }; a "0b111" | 12:48 | |
camelia | sub a(Str:D $a where { ... }) | ||
lizmat | m: sub a(Str:D $a where *.Numeric) { dd }; a "foo" | ||
camelia | Constraint type check failed in binding to parameter '$a'; expected anonymous constraint to be met but got Str ("foo") in sub a at <tmp> line 1 in block <unit> at <tmp> line 1 |
||
12:49
jpn left
|
|||
lizmat | m: subset LooksLikeNumeric of Str where *.Numeric; sub a(LooksLikeNumeric:D $a) { dd }; a "0b111" # using a subset | 12:50 | |
camelia | sub a(Str:D $a where { ... }) | ||
tbrowder | i just got this to work...$arg is copy where ($arg .= Numeric) | 12:54 | |
melezhik | another intersting feature of Sparrow Task Check DSL is soft checks - github.com/melezhik/Sparrow6/blob/...oft-checks | ||
tbrowder | thank you! | 12:55 | |
12:59
grondilu left
|
|||
tbrowder | m: subset StrNum of Str where *.Numeric; sub a(StrNum:D $a) { dd }; a "0b11"; a "z" | 13:15 | |
camelia | sub a(Str:D $a where { ... }) Constraint type check failed in binding to parameter '$a'; expected StrNum but got Str ("z") in sub a at <tmp> line 1 in block <unit> at <tmp> line 1 |
||
13:18
yewscion joined
|
|||
timo | m: sub a(Numeric(Str) $a) { dd }; say try a("0b11"); say try a(99); say try a("z"); say try a(Str); | 13:27 | |
camelia | sub a(Numeric(Str) $a) Nil Nil Nil Nil sub a(Numeric(Str) $a) sub a(Numeric(Str) $a) Use of uninitialized value of type Str in numeric context in sub a at <tmp> line 1 sub a(Numeric(Str) $a) |
||
timo | m: sub a(Numeric(Str:D) $a) { dd }; say try a("0b11"); say try a(99); say try a("z"); say try a(Str); | 13:28 | |
camelia | sub a(Numeric(Str:D) $a) Nil Nil Nil Nil sub a(Numeric(Str:D) $a) sub a(Numeric(Str:D) $a) |
||
timo | m: sub a(Numeric(Str:D) $a) { dd; dd $a }; say try a("0b11"); say try a(99); say try a("z"); say try a(Str); | ||
camelia | sub a(Numeric(Str:D) $a) Nil Nil Nil Nil 3 sub a(Numeric(Str:D) $a) 99 sub a(Numeric(Str:D) $a) Failure.new(exception => X::Str::Numeric.new(source => "z", pos => 0, reason => "base-10 number must begin with valid digits or '.'")) |
||
timo | ah, not quite what i wanted, i see. | ||
13:39
jpn joined
13:41
melezhik left
13:44
jpn left
13:49
jpn joined
|
|||
tbrowder | timo: i came back to explore further as you have already done. can we define a complex subset with a complicated where clause? | 14:02 | |
14:03
melezhik joined
|
|||
melezhik | . | 14:03 | |
tbrowder | something like: subset X of Str where { my $a = $a ~~ /.../. | 14:05 | |
} | |||
itsrakanott | Can subsets do http requests? lol | ||
tbrowder | anyhow, you know what i mean | 14:07 | |
cover the case of the optional prefix for bin, oct, dec, and hex, plus a regex for the allowed chars in the nunber part, etc. | 14:09 | ||
sounds like a speclalized number class now.... | 14:10 | ||
or role | |||
14:13
yewscion left
|
|||
timo | the where clause can be as complicated as you like, but be aware that it might have to be executed more often than you might expect | 14:13 | |
and yes, subsets can do http requests | |||
with the meta-object protocol, you can make your types and classes and stuff as silly as you could possibly want | 14:14 | ||
how about multi candidates that dispatch based on the current moon phase? | 14:15 | ||
tbrowder | ok, now i remenber yr prev warning LOL | ||
timo | classes where methods are present or absent based on a JWT looked up from a dynamic variable | ||
tbrowder | thnx | ||
timo | type checks that have a 1/1000 chance to randomly give the opposite result as expected | 14:16 | |
tbrowder | 👍 | 14:17 | |
14:20
JimmyZhuo left
14:21
abraxxa-home joined
14:53
melezhik left
15:02
Sgeo joined
15:33
abraxxa-home left
15:35
abraxxa-home joined
15:40
yewscion joined
15:53
abraxxa-home left
15:54
yewscion left
16:06
yewscion joined
16:08
Aedil joined
16:34
yewscion left
16:53
jrjsmrtn left
17:00
jrjsmrtn joined
|
|||
tbrowder | another question: is there any advantage (or disadvantage) of having a sub modifying its single arg in place over returning the result? | 17:06 | |
(with $arg is rw) | |||
ugexe | do you like functions that mutate their inputs? | 17:12 | |
its largely a question of the type of api you want to provide | 17:13 | ||
generally using $arg is rw and modifying that directly should be faster, but i suspect you are not working on a project where that benefit would be relevant | 17:14 | ||
tbrowder | i went down that path and now am reconsidering based on the questions earlier about defining input constraints. | ||
ugexe | it is usually easier to reason about code that does not mutate its inputs | ||
tbrowder | for sure. | 17:15 | |
i have been dealing with number base translation and i probably caused some of my problems with the rw arg | 17:16 | ||
anyhow, good point, i will stick with my revised code (return vs rw), thanks! | 17:18 | ||
17:34
MyNetAz left
17:35
jjido joined
17:45
jjido left
17:49
MyNetAz joined
17:54
jjido joined
18:37
wayland76 joined
|
|||
wayland76 | Hi all! Just noticed that OpenFormula has % as a Postfix Unary operator that divides by 100 :) | 18:38 | |
18:44
jjido left
|
|||
lizmat | m: sub postfix:<%>($a) { $a / 100 }; say 100% | 18:49 | |
camelia | 1 | ||
18:50
sena_kun joined
18:51
jpn left
|
|||
wayland76 | Nice :) | 18:53 | |
I figured we could do it too, I just hadn't run across the idea before. | 18:54 | ||
19:00
tejr left
19:01
tejr joined
|
|||
Voldenet | timo: Yeah, C# uses (void*)0 for null more specifically, idk if any implementation could do it differently | 19:09 | |
I think unsafe context pretty much requires it, but in other contexts null could probably be class-specific pointer | 19:10 | ||
19:39
Aedil left
19:46
yewscion joined
19:58
yewscion left
|
|||
wayland76 | I know with a lot of things. we can call .Int or .Str to get them as a number or string. Is there a generic .Scalar that will get called if neither .Int nor .Str exist? | 19:58 | |
librasteve | wayland76: github.com/librasteve/raku-Physics.../issues/69 ... make % a first class export is a todo | ||
... meantime you can go something like `use Physics::Measure; say ♎️'3%'; | 19:59 | ||
wayland76 | librasteve: Nice! | ||
Hi! Regarding irclogs.raku.org/raku/2025-02-22.html#11:08 , I'm guessing I'd need to make a Slang that recognises ⪪body (ie. ⪪ plus characters allowed in a name). Would that be correct? And if so, are there any Slangs that already do this kind of thing? | 20:07 | ||
20:10
[Coke] left
20:23
abraxxa-home joined
20:28
jjido joined
20:30
yewscion joined
|
|||
wayland76 | Do we have a good writeup on how to create a Slang? | 20:32 | |
librasteve | you said html⪪body⪪h1{.id eq "red"} - i think you have a couple of options - (i) a full on slang suggest you check out raku.land/zef:lizmat/Slangify | 20:33 | |
then check reverse dependenices and see eg raku.land/zef:raku-community-modul...ang::Roman as a short example | 20:35 | ||
(ii) you could try something likemulti infix:<⪪>($a, $b) {...} which I guess would imply that html, body are something like nodes defined as my \html = Node.new: :id<1234> | 20:38 | ||
SmokeMachine | Is it something like this what you want? github.com/FCO/p6-react | 20:42 | |
librasteve | (iii) you could also consider where html, body are subs and then do the standard raku sub syntax like html( ⪪( body( ⪪( blah blah )))) that can be written as html ⪪ body ⪪ blah blah which needs to be space separated | ||
SmokeMachine | wayland76: ^^ | ||
wayland76 | librasteve: Thanks! Knowing what (ii) and (iii) would do is helping to push me towards (i) :) | 20:44 | |
SmokeMachine: Interesting! I'm more after an XPath equivalent, but that module looks interesting anyway :) . | 20:45 | ||
SmokeMachine | wayland76: sorry… I should have read more before answering… | 20:46 | |
librasteve | yeah - i need to get a slang under my belt | 20:47 | |
SmokeMachine | wayland76: I like that too… but that’s 7 years old… my most recent try on raku web components is this one: github.com/FCO/Cromponent (but I do have a few tries… :( ) | 20:54 | |
wayland76 | SmokeMachine: I'll be more interested in web components when I'm happier with tables, and trees; at the moment, I'm just keeping an eye towards, them, but not doing anything. | 21:00 | |
I think last time I just used Cro | |||
And Vue + PrimeVue | |||
21:09
yewscion left
21:11
yewscion joined
21:15
yewscion left
|
|||
Voldenet | tbh. wouldn't it be rather nice to simply support html through a slang? | 21:22 | |
plain `<div><b>hell</b>o world</div>` converting into `html("div", {}, [html("b", {}, ["hell"]), "o world"])` or something similar | 21:25 | ||
21:26
librasteve_ joined
|
|||
librasteve | Voldenet: I have been making some progress on HTML as a functional library ... | 21:28 | |
librasteve_ | www.irccloud.com/pastebin/fsW1sThs | 21:29 | |
Voldenet | I've seen this already | ||
It's ok, I'm not sure if not superior to html | |||
but html can be written in static context (jsfiddle) and then copied to the file, I think that makes it a lot easier | 21:30 | ||
otoh converting html to any format isn't really a challenge | |||
but syntax is less foreign for most people | 21:31 | ||
elm lang for example has nice and useful syntax, but quite foreign until you get used to it | 21:32 | ||
librasteve | yes, elmlang in raku is my initial direction | 21:34 | |
tbh, when I started this was an experiment as much to see what felt nicest to write web sites (give that I like to write stuff in raku and that for me HTML can be very hard to read | 21:36 | ||
librasteve_ | www.irccloud.com/pastebin/wzWUL4Hq | 21:39 | |
librasteve | so far, my feeling is that the functional style is generally an improvement on HTML by suppressing the "tag noise", but this is a matter of taste for "bulk HTML" and the tooling for HTML is very good (jsfiddle) and there are good ways to do "near HTML" eg Cro templates | 21:42 | |
Voldenet | `Safe.new: '☰'` feels a bit weird | 21:43 | |
librasteve | BUT ... (see that pastebin ^^) ... when you need to mix HTML and real code then functional is an awesome way to express the intent without needing to drop into string concat, angle brackets and so on | 21:44 | |
Voldenet | also, the component tree probably renders to Str fully, it's fine until you want speed | 21:46 | |
wouldn't it be better to render it to component tree (so static parts can get optimized) and then produce one render sub doing a few concats? | 21:47 | ||
that's what I assume because "self.style.HTML ~ (…) ~ self.script.HTML" exist | 21:48 | ||
and it's all inside HTML method | |||
21:49
jjido left
|
|||
Voldenet | in the trivial case it'd be slower, but on next runs it could get faster | 21:49 | |
and component could have .is-dynamic trait telling whether any external property is accepted, making the whole "cached static path" optimized | 21:52 | ||
librasteve | well, maybe a component tree would be better, but in the initial version I wanted to try out ideas to get to a point where the code style felt best - certainly this is early days | 21:53 | |
Voldenet | s/trait/attribute/ | ||
yeah, it wouldn't change the syntax that much | |||
it'd change the parts where "Safe.new" or .HTML is needed | 21:54 | ||
or ~ op | |||
librasteve | you are welcome to look at the library repo (github.com/librasteve/Air) and the examples (github.com/librasteve/Air-Play) - these are already (WIP) zef modules also ... the code I shared is from the Air::Base module which consumes all standard HTML tags as sub and then exports some of these as overrides and some additional subs such as safe() so at the example level you can go safe '☰' - to | 22:00 | |
avoid html escaping | |||
22:00
jpn joined
22:06
[Coke] joined
|
|||
the Air::Functional module is an improved version of HTML::Functional ... since I am quite a meat & potatoes coder it will probably be quite painful for me to write a component tree alternative --- so please do offer up a simple prototype for that componet tree idea and I can get a better idea of what that would look like and rewrite what i have so far | 22:11 | ||
wayland76 | Voldenet: I think the first link from SmokeMachine ( github.com/FCO/p6-react ) was supporting HTML through a Slang. | 22:22 | |
librasteve_: Your plans to make a Slang will be glad to hear I've just put together a bare-bones Slang tutorial. It's not much at the moment, but will hopefully be improved either by me as I learn, or by others. | 22:23 | ||
Voldenet | I'll see if using components tree in Air::Functional would be feasible | 22:28 | |
it'd require some rewrite | |||
but maybe not that much | |||
SmokeMachine | wayland76: yes, that’s the module I implemented the “rakux” (in opposition to react’s jsx) | ||
Voldenet | wow, that p6x (rakux) slang is pretty neat | 22:32 | |
wayland76 | Voldenet: Glad you like SmokeMachine's work :) I was worried I was hammering the obvious. | 22:36 | |
Voldenet | np, I've missed the link | 22:37 | |
23:27
silug joined
23:31
sadomei joined,
sadomei left
23:32
jpn left
23:33
sadomei joined
23:39
sena_kun left,
sadomei left,
sadomei joined
23:40
sadomei left
23:42
sadomei joined,
sadomei left,
sadomei joined
23:47
xinming left
23:49
abraxxa-home left
|