🦋 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.
[Coke] there's no self during the end. if you save it into a lexical, that might work. 00:07
[Coke] not sure why it would work in non-first runs. 00:07
[Coke] ... I mean, assuming my guess is right. 00:07
tonyo Is it being precomped? 01:06
deoac ``` 01:30
my Rat $r = 1.0;
my Int $i = 1;
try $i = $r;
say $! if $!;
try $r = $i;
say $! if $!;
#OUTPUT:
#Type check failed in assignment to $i; expected Int but got Rat (1.0)
# in block <unit> at deleteme.raku line 5
#
#Type check failed in assignment to $r; expected Rat but got Int (1) 01:31
# in block <unit> at deleteme.raku line 7
```
Why aren't Ints coerced into Rats?
guifa Assignment doesn't automatically coerce in Raku (unless you have a coercion type) 01:37
So you could do, for instance 01:38
m: my Rat() $r = 1.0; my Int $i = 1; $r = $i; say "r is $r and is a ", $r.WHAT; 01:39
camelia r is 1 and is a (Rat)
deoac Thanks, I didn't know about the Int() syntax. 02:01
But the question remains, why aren't Ints automatically coerced to Rats?  It's certainly DWIM. 02:02
MasterDuke raku is strongly typed and they're different types 02:04
they can coerce if you request that, but it doesn't happen automatically 02:05
m: say Int.^mro; say Rat.^mro 02:07
camelia ((Int) (Cool) (Any) (Mu))
((Rat) (Cool) (Any) (Mu))
Xliff gist.github.com/Xliff/69b7bccf1f74...e27abe8657 05:34
\o
tellable6 2022-10-05T11:00:55Z #raku <gfldex> Xliff gist.github.com/b1a3eb9f870cb7c6af...63f2fa2a80
Kernspin Good morning. 07:52
Nemokosch sup 07:53
lizmat hythm: END try self.some-method() 09:30
tellable6 lizmat, I'll pass your message to hythm
Nemokosch deoac: the point you went down from the track of DWIM was when you assigned a self-declared Int to a self-declared Rat. Basically, you were the one who explicitly asked it to fail 09:44
I'm often under the impression Raku type annotations weren't meant for what people are trying to use them 09:46
And this is the rare case where I think people could be "fixed" instead of the language
ironically enough, the type annotation could rightfully claim "I do what I mean", as in meaning 09:48
guifa There's a reason Real and Numeric types exist, fwiw 10:06
Those are broader and will take Rats and Ints alike
Xliff \o 10:10
gist.github.com/Xliff/69b7bccf1f74...e27abe8657
Nemokosch The naming of types could be better, if anything, Real being "outside" of Num 10:14
Xliff: what does `does` do, and are you sure it shouldn't be `but`? 10:23
both are absolute magic to me tbh
lizmat Nemokosch: do you grok roles ? 10:32
tellable6 lizmat, I'll pass your message to Nemokosch1
Nemokosch Nemokosch1 is back... 10:46
lizmat: no, I don't think so 10:51
lizmat and you've read docs.raku.org/language/objects#Roles ?
in any case, you could think of "does" as the "but-rw" version of "but" 10:53
a does b is sorta like a = a but b
Nemokosch I only read it superficially. Honestly, the time just hasn't come when it's useful for me. 10:58
lizmat have you used inheritance in classes, and where annoyed by its deficiencies ? read up on roles :-) 10:59
*were
tbrowder .tell tonyo i'm not yet using yr code as basis for formatter, the trick is getting two or more different formatters in the same program that actually work with DateTime to produce, e.g., "2022-10-11T00:00:00 CST" or "2023-06-01T00:00:00 CDT". i can do that with my hack, but can't with yrs. 11:05
tellable6 tbrowder, I'll pass your message to tonyo
Nemokosch I'm pretty sure HTML::Tag itself uses roles but I haven't needed to alter them much yet 😄 11:07
tbrowder melezhik: i just added a feature request for Cromtit 11:24
tellable6 tbrowder, I'll pass your message to melezhik
tonyo tbrowder: do you have a usage or repo I can peek at? 11:25
tellable6 hey tonyo, you have a message: gist.github.com/288f3ee903a034bcd1...5eba5d6f43
tbrowder tonyo: yes - github.com/tbrowder/LocalTime/ 12:39
Xliff Did anyone get the chance to look at my gist? 13:28
Or can tell me how I can get values from a Parameter object? 13:29
lizmat_ Parameter.get_value ? 13:30
Xliff lizmat: Can you tell me why my gist doesn't work? 13:30
lizmat not without looking deeper into it, and I need to go afk in a few minutes
will look into it when back in a few hours 13:31
Xliff lizmat: Isn't that Attribute.get_value?
Xliff lizmat: *sigh* -- OK, thanks. 13:31
lizmat ah.. yes...
oops, you're right
Xliff :)
lizmat hmmm. off the top of my head, there's no interface to the Parameter object to do that 13:32
Xliff Ah. Why not? 13:33
I guess I can see why, though.
I'd like to write a Parameter::Also
The existing syntax is bothering me. :)
lizmat creating Method::Also originally was just syntactic sugar for .^add_method 13:34
so there was metamodel support for it
Xliff I know. We've had that conversation, I think. :)
lizmat could well be :-) 13:35
Xliff I was hoping that all I needed to do was override Parameter.named_names, but that turns out to not be the case.
I guess I'll delve into the source if I get some time today. Thanks. 13:36
lizmat could be just named_names, but at compile time 13:37
Xliff Aren't traits done at compile time? 13:37
lizmat true
afk&
vrurg Xliff: a lot of work is done by parameter binding code. Not sure how does aliasing work, I was mostly focusing on different things. But I could guess it's not using metamodel. 13:58
vrurg Xliff: yep, that's the case. Grep for named_names through Actions.nqp. It's not using parameter's object. 14:23
tbrowder tonyo: check my prog in the dev directory: tonyo-v2.raku
that's where i started experimenting with your lag 14:24
*latest
[Coke] updated to HEAD recently, ran a script on windows, got a segfault. 15:03
will see if I can track it down.
melezhik o/ 15:05
tellable6 2022-10-12T11:24:04Z #raku <tbrowder> melezhik: i just added a feature request for Cromtit
melezhik .tell tbrowder - cool! - github.com/melezhik/Cromtit/blob/m...che-server
tellable6 melezhik, I'll pass your message to tbrowder 15:06
tbrowder melezhik: hi, thnx, gotta go, bye 15:07
melezhik tbrowder , sure, thanks again!
[Coke] segfault was occuring loading an old .precomp :( 16:13
I removed the .precomp dir in question, script started working again
wish I had saved the old directory for diagnostics, sorry. 16:14
is a newer version of rakudo enough to trigger re-compilation? (if so, is it just when the bytecode format changes, or when a version is released, or...) 16:16
tonyo tbrowder: should this be converting the time to the right timezone? 16:38
tbrowder no, i take care of that. just handle various text inputs that go after the time string. they are constant strings inside the formatter. 16:47
tonyo tbrowder: gist.github.com/tonyo-tatari/2c567...8651d62ae9
tbrowder look at my method gen-fmt-class 17:35
tonyo I see, I'll modify for that ^ 18:13
ugexe [Coke]: should be, but yeah for some reason deleting the precomp folder fixes things for unknown reasons 18:48
i often think it might be related more to runtime module loading but i dont really have any proof of that
[Coke] Thanks 18:58
ugexe m: my %*SUB-MAIN-OPTS = :allow-no; sub MAIN(:$foo, :$no-foo) { say $foo; say $no-foo }; BEGIN @*ARGS = <--foo --no-foo>; 19:55
camelia [True False]
(Any)
ugexe why im not a fan of having all these MAIN options
Nemokosch what is this SUB-MAIN-OPTS at all? 19:57
ugexe it changes the parsing of sub MAIN. it also pretty much guarantees the current implementation can never be replaced due to so much of the tacked on functionality not having much cohesiveness or or consistency 19:58
our descendants will use `sub MAIN2 {...}` 20:02
Nemokosch maybe in version 7 😂 20:03
ugexe i though larry said there couldnt be a version 7 because that would imply it was perfect or some such
Nemokosch and they will never know where that 2 came from
like X11, forever 11 20:05
ugexe: fair point; guess that's why Perl5 folks had to back up from releasing Perl 7
on a more serious tone: I personally think that it's hard to further improve the situation around CLI argument parsing - simply because it's superior to everything I have seen or heard of 20:08
ugexe m: sub MAIN(Str :$mystr) { say so $mystr; say $mystr }; BEGIN @*ARGS = <--mystr=False> 20:10
camelia Usage:
<tmp> [--mystr=<Str>]
ugexe like i cant think of a single situation where someone wants to pass a boolean false as the string "False" 20:11
m: sub MAIN(Str :$mystr) { say so $mystr; say $mystr }; BEGIN @*ARGS = <--mystr=FalseXXX>
camelia True
FalseXXX
Nemokosch I have seen this with enums 20:13
more precisely: `Label` failed to be parsed as an enum value because of the existing `Label` class 20:14
ugexe its at least consistent in its own way. afterall is --mystr=1 an in or a str?
int or a str^
but beyond numerical stuff it doesn't seem useful
Nemokosch Is there even a way to force passing False as a string? 20:17
ugexe m: my %*SUB-MAIN-OPTS = :coerce-allomorphs-to(Str); sub MAIN(Str :$mystr) { say so $mystr; say $mystr }; BEGIN @*ARGS = <--mystr=False> 20:20
camelia Usage:
<tmp> [--mystr=<Str>]
ugexe i would intuitively expect that to do so, but obviously doesnt
m: my %*SUB-MAIN-OPTS = :coerce-allomorphs-to(Version); sub MAIN(Str :$mystr) { say so $mystr; say $mystr }; BEGIN @*ARGS = <--mystr=False> 20:22
camelia Unsupported allomorph coercion: Version
in block <unit> at <tmp> line 1
ugexe i guess because string "False" is a bool, not an allmorph of False|"False" 20:23
which seems inconsistent 20:24
ugexe but an Allmorph of boolean False and string "False" would make no sense outside of dispatching for MAIN 20:25
Nemokosch m: enum Element<Entity Label>; sub MAIN(Element :$choice) { dd $choice; }; BEGIN @ARGS = <--choice=Label> 20:27
camelia ===SORRY!=== Error while compiling <tmp>
Variable '@ARGS' is not declared. Perhaps you forgot a 'sub' if this
was intended to be part of a signature?
at <tmp>:1
------> lement :$choice) { dd $choice; }; BEGIN ⏏@ARGS = <--choice=…
tellable6 2022-10-12T10:32:16Z #raku <lizmat> Nemokosch: do you grok roles ?
Nemokosch oops copypaste fail 20:28
m: enum Element<Entity Label>; sub MAIN(Element :$choice) { dd $choice; }; BEGIN @*ARGS = <--choice=Label>
camelia Usage:
<tmp> [--choice=<Element> (Entity Label)]
Nemokosch m: enum Element<Entity Label>; sub MAIN(Element :$choice) { dd $choice; }; BEGIN @ARGS = <--choice=Entity>
camelia ===SORRY!=== Error while compiling <tmp>
Variable '@ARGS' is not declared. Perhaps you forgot a 'sub' if this
was intended to be part of a signature?
at <tmp>:1
------> lement :$choice) { dd $choice; }; BEGIN ⏏@ARGS = <--choice=…
Nemokosch aaaa
m: enum Element<Entity Label>; sub MAIN(Element :$choice) { dd $choice; }; BEGIN @*ARGS = <--choice=Element>
camelia Usage:
<tmp> [--choice=<Element> (Entity Label)]
Nemokosch It's ridiculous that I just can't get this right
m: enum Element<Entity Label>; sub MAIN(Element :$choice) { dd $choice; }; BEGIN @*ARGS = <--choice=Entity> 20:29
camelia Element::Entity
Nemokosch so yes, eventually I succeeded at reproducing it...
let's try with Array instead of Label 20:30
m: enum Element<Button Array>; sub MAIN(Element :$choice) { dd $choice; }; BEGIN @*ARGS = <--choice=Array> 20:31
camelia Usage:
<tmp> [--choice=<Element> (Array Button)]
Nemokosch m: enum Element<Button Array>; sub MAIN(Element :$choice) { dd $choice; }; BEGIN @*ARGS = <--choice=Button>
camelia Element::Button
Nemokosch same thing
[Coke] I once worked in a language where the country code "NO" was interpreted as False. 22:05
guifa lol 22:07
Xliff vrurg: Thanks for the update. How does parameter binding occur? 22:10
vrurg Xliff: see lower_signature in Actions. 22:11
Xliff vrurg: That one is ... quite large. 22:18
I do see that it's a hash, however.
vrurg Should be possible to replace with Param object though. 22:19
It is being used in some locations of the sub.
Xliff Hmmm... good thought. I'll make a note of it. 22:20
Actually, I'll look at the rakuast branch of this and see what's going on there, too. 22:21
lizmat weekly: dev.to/lizmat/dont-fear-the-grepper-1-1k3e 22:34
notable6 lizmat, Noted! (weekly)
lizmat afk&
[Coke] lizmat: you have an extra \ in one of the snippets as \* 23:16
er, \* %% 2