Raku Conference Day 2 on Youtube: www.youtube.com/watch?v=BL9-XdC9WYI 🦋 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 14 August 2022.
00:06 reportable6 left 00:07 reportable6 joined 00:55 epony left 01:27 sftp left 01:30 sftp joined 01:56 frost joined 01:59 Xliff left 02:00 epony joined 03:00 notable6 left, committable6 left, squashable6 left, statisfiable6 left, linkable6 left, evalable6 left, benchable6 left, nativecallable6 left, unicodable6 left, bloatable6 left, shareable6 left, greppable6 left, releasable6 left, sourceable6 left, reportable6 left, quotable6 left, bisectable6 left, tellable6 left, coverable6 left 03:01 statisfiable6 joined, committable6 joined, notable6 joined, bloatable6 joined, quotable6 joined, squashable6 joined 03:02 benchable6 joined, sourceable6 joined, evalable6 joined, unicodable6 joined, releasable6 joined 03:03 reportable6 joined, coverable6 joined, nativecallable6 joined, greppable6 joined, shareable6 joined, linkable6 joined, tellable6 joined 03:04 bisectable6 joined 03:26 Sgeo_ joined 03:27 Sgeo left 03:30 Kaiepi left 03:31 Kaiepi joined 04:16 Sgeo__ joined 04:19 Sgeo_ left 05:05 Oshawott left 06:05 quotable6 left, bisectable6 left, nativecallable6 left, evalable6 left, unicodable6 left, releasable6 left, sourceable6 left, bloatable6 left, linkable6 left, coverable6 left, notable6 left, statisfiable6 left, squashable6 left, greppable6 left, tellable6 left, benchable6 left, shareable6 left, committable6 left, reportable6 left, committable6 joined, linkable6 joined, unicodable6 joined, greppable6 joined 06:06 coverable6 joined, releasable6 joined, bloatable6 joined, quotable6 joined, bisectable6 joined, shareable6 joined, nativecallable6 joined 06:07 statisfiable6 joined, tellable6 joined, reportable6 joined 06:08 evalable6 joined, notable6 joined, squashable6 joined, sourceable6 joined, benchable6 joined 07:08 shareable6 left, reportable6 left, squashable6 left, sourceable6 left, statisfiable6 left, bisectable6 left, quotable6 left, bloatable6 left, evalable6 left, tellable6 left, unicodable6 left, nativecallable6 left, releasable6 left, committable6 left, notable6 left, benchable6 left, coverable6 left, greppable6 left, linkable6 left, bloatable6 joined, quotable6 joined, linkable6 joined 07:09 sourceable6 joined, greppable6 joined, tellable6 joined, nativecallable6 joined, evalable6 joined, Sgeo__ left 07:10 notable6 joined, epony left, squashable6 joined, committable6 joined, releasable6 joined, bisectable6 joined, coverable6 joined 07:11 statisfiable6 joined, benchable6 joined, shareable6 joined, reportable6 joined, unicodable6 joined 07:41 sena_kun joined 07:54 razetime joined
SmokeMachine lizmat: It seems there is something wrong on rak... While running `rak '/[has_[many|one]|belongs_to] \( /' $(find path/to/dbic/schema/source -type f -name \*.pm)` I got this error: usercontent.irccloud-cdn.com/file/...2%402x.png 08:25
lizmat grrr... if you run with MVM_SPESH_DISABLE+1 ? 08:26
grrr... if you run with MVM_SPESH_DISABLE=1 ?
08:33 nine left, m_athias left, nine joined, nine left 08:34 nine joined, nine left, nine joined 08:35 m_athias joined
xinming m: my Int sub test (Str) { }; sub t (Int(Str) $arg) { $arg.WHAT.say; $arg.say; }; t("3"); 08:38
camelia (Int)
3
xinming In this example, What is the best practise to achieve the type auto convertion?
m: my Int sub test (Str $s) { $s.Int }; sub t (Int(Str) $arg) { $arg.WHAT.say; $arg.say; }; t("3"); 08:39
camelia (Int)
3
xinming m: my Int sub test (Str $s) { $s.Int + 2 }; sub t (Int(Str) $arg) { $arg.WHAT.say; $arg.say; }; t("3"); 08:40
camelia (Int)
3
xinming Seems the test sub is not in effect
Nemokosch what do you mean?
xinming possible to add customized auto type convertion in this example please?
08:43 discord-raku-bot left, discord-raku-bot joined
Nemokosch where do you call the test sub? 08:43
xinming Neokosch: I want to make the arg auto converted. 08:45
Something like, sub my-sub (MyType1(MyType2) $arg) { ... } 08:46
SmokeMachine lizmat: no errors if setting MVM_SPESH_DISABLE=1 08:56
lizmat yeah, feared as much... looks like rak code is tickling a bug :-(
which I haven't been able to golf so far... 08:57
Nemokosch It is converted though?
What does this have to do with a test sub?
lizmat afaics, it has to do with a native int being referenced from within a wrapped Callable
09:00 frost left 09:03 frost joined 09:19 sena_kun left
xinming Nemokosch: I try to figure out how to do implicit type convertion, so I want to write a test sub. :-) 09:36
tellable6 xinming, I'll pass your message to Nemokosch
09:59 razetime left 10:00 razetime joined 10:10 sena_kun joined
lizmat SmokeMachine: App::Rak 0.91 on zef now, should fix the error you saw 10:16
turned out to be a case of "" but True being handled incorrectly by spesh, apparently 10:17
Nemokosch xinming: there is a good presentation by guifa iirc 10:20
www.youtube.com/watch?v=1-KV8oiOSZA
11:10 evalable6 left, linkable6 left 11:11 linkable6 joined, evalable6 joined
leont: good sir, I remember your remarks about CLI 11:11
do you know something about actually giving more accurate feedback on argument parsing failures?
SmokeMachine lizmat: thanks! 11:38
leont That question is very open and vague 11:43
Nemokosch This didn't sound like a "no" at least 11:45
Can the CLI be modified in a way that it can report a missing/wrong argument? 11:46
leont The difficulty with the default argument handling is that it essentially converts the given arguments into a capture without any knowledge of the sub MAIN, and then tries to fix things up. That makes it very difficult to give good errors because you find out about the problem too late. 11:48
You get a (multi) dispatch error, but those aren't terribly specific. 11:49
Missing arguments, duplicate arguments and type mismatches all get the same non-descriptive error.
Nemokosch so there is no known way to fix that in the MAIN context? 11:55
12:01 Colere left 12:06 reportable6 left
xinming Nemokosch: thanks. 12:06
tellable6 xinming, I'll pass your message to Nemokosch
12:07 reportable6 joined
xinming I think as long as time goes, when Nemokosch try to come here with irc client, He'll get a lot of messages. :-) 12:08
12:11 Nemokosch joined
Nemokosch let's see 12:11
Nemokosch .
Nemokosch yes...
tellable6 2022-08-30T18:19:12Z #raku <tonyo> nemokosch: looking for samecase in the rakudo source will lead you to the entry point and then eventually to the implementation which will lead you to some nqp
2022-08-31T09:36:45Z #raku <xinming> Nemokosch: I try to figure out how to do implicit type convertion, so I want to write a test sub. :-)
2022-08-31T12:06:59Z #raku <xinming> Nemokosch: thanks.
12:11 Nemokosch left
leont That depends on the specific issue, really. I'm not saying impossible but things can get annoying. 12:17
12:31 Colere joined
Voldenet it's pretty easy to get good error handling in arguments in console apps 12:32
> sub MAIN(|c) { }
I just do this whenever I need something advanced
Nemokosch I mean... yes 12:34
or just using Perl
who needs function signatures anyway 😄
Voldenet :D
but it's rare that I do need this 12:38
leont That's why I wrote Getopt::Long, it gives clear errors like «Unknown option --foobar» 12:39
Nemokosch The question is related to that as well 12:40
how much Getopt::Long can help with reponses, not just changing the syntax 12:41
leont Or «Cannot convert --foo argument "a" to number: base-10 number must begin with valid digits or '.'»
12:43 discord-raku-bot left, discord-raku-bot joined
Voldenet for the most complex cases I prefer creating json and passing filename 12:44
Nemokosch what do I need to do to unlock these superpowers?
Voldenet > this probably raku.land/cpan:LEONT/Getopt::Long 12:45
leont Just «use Getopt::Long
Nemokosch I'm definitely trying this, it's time 12:48
I can use my own scripts but others keep messing it up
nine I don't see a reason why command line argument and MAIN dispatch has to go through the normal multi dispatcher. That was probably just the cheapest way to implement it. The startup code could instead inspect the MAIN signatures and do the dispatch by itself, retaining full information for helpful error messages. 12:49
This wouldn't require a re-implementation of the full dispatch logic (that would be horrible). For example, it can simply assume that all input types are allomorphs of strings and numbers. There are no native types or complex objects involved. 12:50
Voldenet while there are no complex objects involved, there's use for them in console apps IMO 12:54
> class Something { has Str $.a; has Int $.b; }; sub MAIN(Something :$something) { say $something }
for example things like these are useful, I'm just using json for it… but it's theoretically possible to say something like `–something.a=foo –something.b=42' 12:55
> use JSON::Unmarshal; class Something { has Str $.a; has Int $.b; method COERCE(Str $s) { unmarshal($s, Something) } }; sub MAIN(Something() :$something) { say $something } 12:59
the alternative is pretty sad, `–something='{"a":"foo","b":42}'` in args is also sad format 13:00
leont Voldenet: Getopt::Long supports hash parameters, so you can do «foo --config a=1 --config b=42» and it will DWIM 13:29
nine: Getopt::Subcommands was my first attempt at not using the normal multi-dispatcher, but I'm not sure I got that one right. Probably should make something that looks more conventional. 13:30
13:31 frost left
Voldenet > raku -e 'use Getopt::Long; class Something { has Str $.a; has Int $.b; }; sub MAIN(Something :$something) { say $something }' –something a=foo –something b=42 13:32
> No argument conversion known for parameter $something argument (type Something)
That's not fully DWIM
leont Well, you have a different DWIM than I do I guess. It can accept those arguments and turn it into a hash, it can't convert that to Something 13:35
Voldenet I know, I know. Every time I need to solve such problems I end up writing customized parsing because it's hard to make something truly universal 13:36
re subcommands: I really like how ManyConsole project in csharp does that – it isn't nearly as succinct and nested arguments are still not that nice 13:40
the nice thing is that you can use lambdas for arg assignment and thanks to impreative style you can fake nested classes 13:44
leont raku -Ilib -e 'use Getopt::Long; class Something { has Str $.a; has Int $.b; method COERCE(Hash (Str :$a, Int(Str) :$b)) { self.new(:$a, :$b) } }; sub MAIN(Something() :$something is option<=s%>) { say $something }' --something a=foo --something b=42
Possibly I should add something that would allow me push that «is option<=s%>» into Something itself, but I think this is a workable approach 13:46
Voldenet > use Getopt::Long; class Something { has Str $.a; has Int() $.b; method COERCE(Hash (|h)) { self.new(|h) } }; sub MAIN(Something() :$something is option<=s%>) { say $something }
leont Yeah, that better
Voldenet that's probably less painful than defining all fields in COERCE
iirc slower, but not by much 13:47
leont Slightly, but if argument parsing is your bottle neck you're probably not doing anything interesting
Voldenet true
Geth doc: tbrowder++ created pull request #4105:
Add a practical example of augmenting class IO::Path
13:51
13:56 bigdata left
tbrowder Howdy. I'm looking for suggestions for the best book for introducing young people to computer programming, Raku (instead of Python), and, indirectly, Linux. I think Laurent Rosenfeld's book, "Think Perl 6" (now "Think Raku") is a good candidate. What say you? 13:59
Voldenet imo raku/python are not the best languages to start with, best languages are probably js and maybe php 14:01
the thing is that js is extremely easy to visualise and needs almost no tools 14:02
El_Che js has a lot of gotchas 14:07
Voldenet Sure it does, but for newcomers commandline toolchain is more painful than the language itself 14:08
that's just my opinion though, I've got no basis for it 14:09
14:24 jgaz joined 14:30 xinming left 14:32 xinming joined
tbrowder my problem with js is not having used it much, also doesn't "feel" good 14:34
but i do have the YUGE js book (600+ pp) for reference! 14:35
Voldenet probably my opinion comes from knowing js for over 20 years, might be a bit skewed ;)
tbrowder the tutorial situation is a linux laptop will be provided in a youth center or school library along with a book. mostly self-help with a volunteer avaibale to help sometime. only the inquisitive kids are expected to try it. 14:39
maybe with parent/teacher encouragement
*available 14:40
Voldenet If the toolchain would be already up, then I'm betting it makes things easy 14:41
tbrowder and there is still the linux foundation online linux course to help wean windows ppl
i will have the machine pretty well set for at least CLI use, and some choice of editors. 14:42
Voldenet maybe some IDE with "run" button would be nice 14:43
(Comma is nice, but I'm not sure if easy enough)
tbrowder yeah, i don't like its interface personally, but that's just me 14:44
i wish i could get around that but i never seem to have the patience 14:45
so, what else has a "run" button, VS code for linux? 14:46
Voldenet I mostly use tmux+nano+inotifywatch for scripting, which is probably not the ideal IDE… :)
tbrowder the VSC may work esp. for those with only Win experience 14:47
14:47 Xliff joined
Voldenet VSC is extensible and nice for programmers, but without proper configs it could be too difficult for the target audience 14:49
xinming m: enum T <a b c>; multi COERCE (Str $s) { T::{$s} }; sub t (T(Str) $v) { $v.say; }; t("a");
camelia No value 'a' found in enum T
in sub t at <tmp> line 1
in block <unit> at <tmp> line 1
xinming In this example, how can we make the sub t work as expected?
I konw the T::<a> to resolve to the enum value, But how to do the convertion with sub signatures? 14:50
14:51 Xliff left
tbrowder i use emacs for desktop and vi with terminal. 14:52
ant would be ok but config problem also
i just saw "tabnine" , new to me but no raku ... 14:53
oops, tabnine is an addon to ide's 14:55
Voldenet xinming: this COERCE is never used 14:57
tbrowder and...atom is being archived... 14:58
surely some raku person has settings for VSC to share? 14:59
Voldenet m: enum T <a b c>; use MONKEY-TYPING; augment class T { multi method COERCE(Str $s) { T::{$s} }}; sub t (T(Str) $v) { $v.say; }; say t("a");
camelia a
True
Voldenet ^ this works, but the uppercase scares me, I don't know how to add coercing to an enum otherwise 15:00
15:04 razetime left
xinming tonyo: I know, It's just trying to attach multi to the enum type, so hope it worked. 15:12
Voldenet: Thanks, That's what I want
15:14 sena_kun left
Nemokosch I do think Raku is a good language to start with, simply because it's so big, you can illustrate anything with it 15:22
but it's a good point that CLI stuff is just not cool these days
15:35 epony joined 15:45 sftp left 15:51 MoC joined 15:52 epony left, epony joined
tbrowder so what editor (IDE) do you recommend for linux? 16:03
leont still thinks Raku could be a great GUI language if we put the effort into it, and should really make a blogpost about the GIR idea they mentioned at the conference 16:04
xinming m: my $t = enum <a b c>; constant T = $t; $t does role :: { multi method COERCE (Str $s) { T::{$s} } }; sub t (T(Str) $v) { $v.say; }; t("a"); 16:18
camelia a
xinming Voldenet: I just found a way to achieve this without using augment.
tonyo xinming: ? 16:19
Nemokosch amazing 👏
leont xinming: nice! 16:23
Though it doesn't actually seem to work for me 16:27
Nemokosch something is suspicious? 16:30
16:31 sftp joined
leont If you apply dd to that, instead of say, you'll see it doesn't work 16:35
Nemokosch so you say it didn't convert? 16:44
Voldenet …this seems like a suspicious thing to do 16:55
Currently it works, but I'm not sure if it's guaranteed to work
lizmat if instead of dd foo, you'd do note foo.rak 16:56
if instead of dd foo, you'd do note foo.raku
would that work ?
dd is essentially that, but with some bells and whistles, and maybe those are messing up things?
tonyo m: my \t = enum <a b c>; dd t<a>; note t<a>; 16:57
camelia 0
0
Voldenet m: my $t = enum <a b c>; constant T = $t; $t does role :: { multi method COERCE (Str $s) { T::{$s} } }; sub t (T(Str) $v) { $v.WHAT.say; }; t("a");
camelia (Str)
Voldenet …huh
leont Enum.^add_method also doesn't work because it already has a method and apparently it doesn't allow for overriding that. 17:03
Possibly we should invent a trait to turn that off first
Voldenet every language I know invents enum classes sooner or later 17:04
Nemokosch perhaps using an enum is not the best type to work with coercions 17:12
leont Currently not, no 17:16
But I don't see any reason why it has to be this difficult 17:17
xinming <Nemokosch> do you have any ideas to achive it with other type? access with hash key is easy, It's just want to have more way to do it. 17:20
tonyo leont: iirc there's another way to add a multi 17:27
17:31 linkable6 left, evalable6 left
tonyo .^add_multi_method 17:32
still doesn't dispatch to COERCE though
17:33 evalable6 joined, linkable6 joined 17:41 HvszrStykp joined 18:07 reportable6 left 18:08 reportable6 joined 18:19 sena_kun joined
Nemokosch leont: Getopt::Long contains $*PERL 18:43
which generates an ugly warning message into my script, "contact the author to change that to $*RAKU so that message will disappear" 18:44
😅
leont I should probably just cut that entire check, because it's only needed for compatibility with raku < 2018.06. No one should be using a Raku that old
Voldenet …except debian stable enjoyers 18:54
or oldstable
Nemokosch could you please publish a version without the warning? 18:55
19:14 Guest99 joined 19:15 Guest99 left
leont Nemokosch, just uploaded it 19:39
tonyo what version of raku is warning on $*PERL usage? 19:40
20:15 linkable6 left, evalable6 left 20:16 linkable6 joined 20:18 evalable6 joined 20:56 jgaz left
Nemokosch thankies 20:57
tonyo: I'm using 2022.04 in this environment 20:59
21:29 epony left
japhb Not even Debian oldstable is back in the world of 2018.05. See gist.github.com/japhb/88322d76326d...108c90e567 21:46
21:50 sena_kun left 21:54 epony joined
Voldenet I was only joking, but 2018.12 is painfully close 22:01
22:04 Grrrr joined
epony did you have an accident then? 22:13
Voldenet …that made me laugh, but no, the line above was this link gist.github.com/japhb/88322d76326d...108c90e567 and we were talking about raku releases on debian oldstable :D 22:14
22:18 melezhik joined
melezhik how to know that a string is binary in Raku? 22:18
Voldenet m: my $s = "010101"; say so "0b$s".Int ~~ Int 22:19
camelia True
Voldenet m: my $s = "010101not binary"; say so "0b$s".Int ~~ Int 22:20
camelia False
melezhik so $s.Int ~~ Int ? 22:22
Voldenet > "0b$s".Int ~~ Int 22:23
the 0b part is important
melezhik ah, ok 22:24
Voldenet or ~~ Failure 22:26
22:33 Sgeo joined 22:35 melezhik left 23:03 Geth left, RakuIRCLogger left 23:04 lizmat left
Nemokosch something broke testing with zef 23:19
was it Test::Output? 23:20
was it naively running mi6 test? 23:23
23:25 MoC left
could be TAP as well... 23:25
one thing is sure: if I run tests by hand, they all pass 23:28
and yet I get
```===> Testing: HTML::Tag:ver<0.0.6>:auth<zef:2colours>
===> Testing [FAIL]: HTML::Tag:ver<0.0.6>:auth<zef:2colours>
Aborting due to test failure: HTML::Tag:ver<0.0.6>:auth<zef:2colours> (use --force-test to override)
```
ugexe does the test output using --debug give any more info? 23:29
you can also try testing with `--/tap-harness` to try without using TAP 23:30
23:39 Geth joined 23:50 discord-raku-bot left, discord-raku-bot joined