🦋 Welcome to the former MAIN() IRC channel of the Raku Programming Language (raku.org). This channel has moved to Libera (irc.libera.chat #raku)
Set by lizmat on 23 May 2021.
guifa codesections: you move too fast 00:02
I'm in the middle of typing up a like two page justification :-)
codesections ha, sorry :)
RaycatWhoDat If I wanted to create different syntax for named captures, how would I do that in Raku? 00:29
i.e. I would like to declare something like m:g/ ^ $<firstName>=.+ ' ' $<lastName>=.+ $ / as m:g/ ^ @firstName ' ' @lastName $ / 00:30
Or some sort of syntax where I can just use a container name and Raku knows to bind whatever matches that to those containers 00:31
guifa You mean something like m:g/ ^$<first>=@first $/ ? 00:44
my @first = <John Sally Bob>; say "John" ~~ / $<first>=@first /
evalable6 「John」
first => 「John」
guifa codesections: my treatise is posted ;-) 00:45
codesections: and updated to fix a few things 00:52
RaycatWhoDat guifa, not exactly. I mean, capturing everything that part of the match into a variable named such 00:57
github.com/RayMPerry/kitchen-sink/...-parse.txr 00:58
So, on line 4, given a line of a CSV file, it will take the longest match of characters and bind it to `first_name` to be used later 00:59
So, I was wondering if there was anything that could do that. If there isn't, how hard would it be to implement? 01:00
guifa If you need to use it in the regex itself, not too bad: 01:01
m: 'abcdefc' ~~ / $<foo>='c' .*? $<foo> /; say $/
camelia 「cdefc」
foo => 「c」
guifa but if you want to use it outside of the regex, you'd need to create a regex slang
And … that's hard :-) 01:02
RaycatWhoDat Gotcha 01:04
guifa also codesections given our previous discussion on infix:<eqv> 01:18
m: my $a = Date.new: :2021year, :1month, :1day, :formatter{'A'}; my $b = $a.clone: :formatter{'B'}; say $a eqv $b; 01:19
camelia True
guifa but they have different formatter attributes :-)
codesections guifa: that seems like an excellent example of why &[eqv] shouldn't work that way. 01:46
guifa ah but where it gets more interesting is
m: my $a = Date.new: :2021year, :1month, :1day, :formatter{'A'}; my $b = $a.clone: :formatter{'B'}; say $a.raku; say $b.raku
camelia Date.new(2021,1,1)
Date.new(2021,1,1)
codesections m: my $a = Date.new: :2021year, :1month, :1day, :formatter{'A'}; say $a.^attributes.map({.has_accessor}) 01:47
camelia (True True True True True)
codesections I get why the .raku output is simplified (and agree that it should be). But two objects with different public attributes shouldn't be eqv 01:48
(I don't really think they should be with different private attributes, but I see the counter argument)
guifa To be fair, I don't think the formatter for Datish is really designed to be public 01:49
codesections it seems like a public, read-only attribute to me 01:50
(e.g., set via .new, updateable via .clone, viewable with an accessor ) 01:51
m: my $dt = Date.new: '2015-12-31', :formatter{sprintf "%02d/%02d/%04d", .month, .day, .year }; say Date.new('0000-01-01').formatter.($dt) 01:55
camelia Impossible coercion from 'Date' into 'Callable': no acceptable coercion method found
in block <unit> at <tmp> line 1
codesections m: my $dt = Date.new: '2015-12-31', :formatter{sprintf "%02d/%02d/%04d", .month, .day, .year }; my $b Date.new('0000-01-01'); say $b.formatter.($dt) 01:56
camelia 5===SORRY!5=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> 3%02d/%04d", .month, .day, .year }; my $b7⏏5 Date.new('0000-01-01'); say $b.formatte
expecting any of:
infix
infix stopper
codesections m: my $dt = Date.new: '2015-12-31', :formatter{sprintf "%02d/%02d/%04d", .month, .day, .year }; my $b = Date.new('0000-01-01'); say $b.formatter.($dt)
camelia Impossible coercion from 'Date' into 'Callable': no acceptable coercion method found
in block <unit> at <tmp> line 1
codesections ohh, b/c it's a Callable:U 01:57
m: my $dt = Date.new: '2015-12-31', :formatter{sprintf "%02d/%02d/%04d", .month, .day, .year }; my $b = Date.new('0000-01-01'); say $dt.formatter($b)
camelia Too many positionals passed; expected 1 argument but got 2
in block <unit> at <tmp> line 1
codesections m: my $dt = Date.new: '2015-12-31', :formatter{sprintf "%02d/%02d/%04d", .month, .day, .year }; my $b = Date.new('0000-01-01'); say $dt.formatter.($b)
camelia 01/01/0000
guifa ^^ why I think .fmt("%m/%d%Y" would be better ;-) 02:16
codesections Fair. Though, bikeshedding a bit, I wonder if it should be .date-fmt or something and also exposed as a sub. e.g., multi date-fmt(Str $fmt, Date $date) {...}; multi date-fmt(Str $fmt, Str $date-str) {...} 02:21
then you could do something like date-fmt("%m/%d/%Y", '2021-07-17') 02:22
(and that would avoid confusion with the other .fmt methods, which all use printf fmt string) 02:23
S/(string)/$0s/
guifa Yeah, I thought about that. THe nice thing is that's a decision that can be made between writing the code and integrating it to the code base :-) 02:36
Also the one format code that's driving me made is N (for fractional seconds). It's an extension whose width clips it (unlike all the others), which basically requires special casing and destroys the elegance of my implementation =/ 02:40
elcaro some sloppy date parser/formatter I wrote a while ago: github.com/0racle/p6-dately 03:30
just playing with some ideas, but, yeah i would like some strptime/strftime functions 03:31
i've pulled them in via NativeCall somewhere
I'm no NativeCall export, so I think it's not perfect... lemme see if I can dig it up
elcaro NativeCall strftime/strptime: gist.github.com/0racle/67c4e9e8f51...1ac2162f3c 03:35
guifa elcaro: not too different in concept from what I've got (using a hash for all the different formatters), in particular 03:48
I avoided the grammar though to ramp up the speed 03:49
lemme get my posted onto Github 03:51
guifa github.com/alabamenhu/DateTimeFmt/...imeFmt.pm6 04:04
elcaro / codesections ^^ my first stab at a mostly NQP strftime. 04:07
moon-child vrurg: in vrurg.github.io/arfb-publication/0...ject-mop/, the way you describe integers as working in raku actually predates c++ by at least a decade, having first appeared in smalltalk and lisp. (And actually raku's 'meta object protocol' is taken from common lisp.) And the way you describe integers as working in c++ comes from simula, which originated in the early 1960s. 04:24
I think it would be better to change the c++ reference to simula (with maybe a reference to c++, since people may not be familiar with simula), and mention the common lisp influence
elcaro guifa: I'll take your lib for a spin when I have time. Looks good. 05:19
luk123 weekly: raku tag on stackoverflow has now reached 500 watchers 05:40
notable6 luk123, Noted! (weekly)
Altreus When I start a github issue in Raku/vim-raku it says "If it's not related to highlighting or folding" ... 12:33
vim-raku doesn't appear to implement folding at all
at least I can't find anything that will fold
I feel like I shouldn't be opening an issue about implementing folding if someone's already mentioned it in the issue template 12:35
vrurg moon-child: that section is not a historical introspection but rather outlines the path language development took. 13:27
suman m: for 1..4 {say $_} 13:29
camelia 1
2
3
4
suman I thought this would also work 13:30
m: for 4..1 {say $_}
camelia ( no output )
[Coke] m: dd 1..4; dd 4..1
camelia 1..4
4..1
lizmat m: for 4 ... 1 { .say }
camelia 4
3
2
1
lizmat .. only goes up, ... also goes down 13:31
suman Hmm I see
[Coke] docs for .. point to docs.raku.org/type/Range which mentions the ordering in the 5th paragraph. 13:32
weird that doc categories show .. as infix, but ... as routine 13:33
[Coke] wonders if the naming of ... was because ".., but moreso" 13:34
any pointers on using irssi to connect via TLS to libera? just changing the port gives an unable to connect, but no details about the actual error 13:39
moritz you need /connect -tls 13:44
moritz hopes he's not Captain Obvious 13:45
[Coke] no, I think the docs I've found assume you know way more about IRC than I do. :)
s/you know/one knows/
[Coke] gives up and will just connect unsecurely, he guesses. 13:47
[Coke] (ok, closer with wiki.archlinux.org/title/Irssi, now I'm at least getting an error related to the certs) 13:54
codesections m: &[...].candidates.say 14:04
camelia (&infix:<...> &infix:<...>)
codesections yeah, that seems like a doc error; ... is an infix 14:05
gfldex lolibloggedalittle: gfldex.wordpress.com/2021/06/18/despotting/ 14:53
Altreus o hello 15:00
I see you're using the module I cannot find the time for
You're not wrong, it is fairly spotty :D 15:01
Altreus gfldex: Many classes that are typically represented as a Str ... I take from your example you mean in the sense that a Channel is usually represented as its name? 15:03
a user is represented as @user#1234 15:04
etc
[Coke] codesections: there's probabaly already a ticket for mis-categorized things in general, but having a specific one to fix isn't a bad thing.
Altreus gfldex: I don't mind adding methods that return the string you would use to represent the thing in a message 15:05
That might not be a terrible idea
I'm not sure I'd go as far as to make it stringify itself because I find that magic always trips me up at some point 15:06
I know kawaii_ had to construct messages manually to make the bot actually link to channels or highlight people
Altreus that could be another thing I do whenever I get around to the dev stream 15:16
Xliff How can I write a subset with multiple conditions? 21:39
I've tried "our subset NonGLibPositional is Any where { $_ ~~ Positional && $_ ~~ (GLib::Array, GArray).any }" but this errors out with an LTA 21:40
Xliff m: class A {}; class B {}; our subset NonGLibPositional is Any where { $_ ~~ A && $_ ~~ B } 21:42
camelia 5===SORRY!5=== Error while compiling <tmp>
No such method 'add_parent' for invocant of type
'Perl6::Metamodel::SubsetHOW'
at <tmp>:1
Xliff m: class A {}; class B {}; our subset NonGLibPositional is Mu where { $_ ~~ A && $_ ~~ B }
camelia 5===SORRY!5=== Error while compiling <tmp>
No such method 'add_parent' for invocant of type
'Perl6::Metamodel::SubsetHOW'
at <tmp>:1
lucs I've got something like this in my notes: subset Foo of Any where * ~~ Bar | Moo | Meow;
Xliff lucs++ # Let me try that
Xliff Actually, that only catches the exclusive case. What about the inclusive? 21:43
lucs s/|/&/ ?
Xliff And the block form doesn't take kindly to *
lucs: Two logicals, inclusive AND exclusive.
Your conditional only does the inclusive
Hmmm... maybe two subsets? 21:44
lucs ... where { $_ ~~ A & B } ?
... where { $_ ~~ A & (B | C) } ? 21:46
Xliff Pisslb.e 21:46
* Possible.. (lol)
lucs :)
Xliff Nope. Using two subsets, as well as lucs' last two suggestions both result in the same error. 21:47
lucs :(
Paging the experts!
guifa isn't it "of Any" not "is Any"? 21:48
m: class A {}; class B {}; our subset NonGLibPositional of Any where { $_ ~~ A && $_ ~~ B }
camelia ( no output )
Xliff guifa++ 21:49
lucs guifa++ Careful reading :)
guifa you can also do
m: class A {}; class B {}; our subset NonGLibPositional of Any where Positional & (A|B)
camelia ( no output )
lucs takes more notes! 21:50
guifa Also, "of Any" is redudant IIRC 21:51
codesections bisect: my token paren { '(\' <tok> \')' }; my token tok { <paren>? foo }; say "(foo)foo" ~~ /<tok>/; 21:59
bisectable6 codesections, Will bisect the whole range automagically because no endpoints were provided, hang tight
codesections, ¦6c (54 commits): «「foo」␤ tok => 「foo」␤» 22:00
codesections, Nothing to bisect!
melezhik . 22:32
releasable:
releasable6 melezhik, I cannot recognize this command. See wiki for some examples: github.com/Raku/whateverable/wiki/Releasable
melezhik releasable6: status
. 22:33
Geth doc: coke self-assigned Create a helper module for testing github.com/Raku/doc/issues/1751
a29ac07008 | Coke++ | 2 files

Part of #1751
22:58