🦋 Welcome to Raku! raku.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: colabti.org/irclogger/irclogger_log/raku
Set by ChanServ on 14 October 2019.
Guest75570 Hello World 00:04
p6: say 3; 00:06
camelia 3
liubianshi p6: say 3; 04:02
camelia 3
liubianshi p6: say "";
camelia
Voldenet p6: say "".uniname 04:03
camelia <private-use-E62B>
Voldenet huh
jmerelo .tell tbrowder apparently raku-advent.blog is already working, but it redirects to the old address 06:20
tellable6 jmerelo, I'll pass your message to tbrowder
no-n I installed vim-raku with Vundle and it does not seem to be doing any highlighting. 07:53
(for .raku files) 07:54
Not sure if it's doing anything at all, but it is installed. 07:55
AlexDaniel no-n: maybe .raku extension is not supported yet? 11:30
moritz no-n: you can do things like try :set filetype=raku 11:37
:syntax on
Tirifto lizmat: I think I get how your mixin example works now, but I’ll probably get a class for my use case, since I’m not sure that ‘:=’ being a compile time operator wouldn’t be a problem. And I also noticed something else in regard to the operator… 14:46
p6: class A {has $.msg is rw = “Meow!”}; role R {method msg () {callsame}}; my $a := A.new; my $b := $a but R; $b.msg.say; $a.msg = “Woof!”; $b.msg.say;
camelia Meow!
Meow!
jnthn `but` works on a copy; try `does` instead 14:49
Tirifto p6: class A {has $.msg is rw = “Meow!”}; role R {method msg () {callsame}}; my $a := A.new; my $b does R := $a; $b.msg.say; $a.msg = “Woof!”; $b.msg.say; 14:51
camelia Meow!
Woof!
Tirifto jnthn: Does ‘my $b := $a but R;’ bind $b to a copy of $a which does R, basically? 14:54
jnthn It's like `my $b := $a.clone does R;` 14:55
It really changes the type of the object 14:56
Tirifto Ah, I guess I got the wrong idea about precedence at first. 14:57
jnthn Ah, yes; does and but bind tigheter than := 14:58
Tirifto (I was thinking $b would refer to $a and just get enriched with methods, but it makes sense that the ‘but’ would apply to $a and return something for $b to get bound to…)
Thank you jnthn! 15:00
Ulti so I just had a bit of a thought experiment on how one might think about Python context managers in Raku... and I suspect there is a hidden phaser GIVEN_ENTER and GIVEN_LEAVE on a class definition 15:33
thats sort of where one might hang it without essentially reimplementing given with some special method names similar to Python 15:34
Xliff m: my @a = flat('a'..'z', 'A'..'Z', 0..9, '_'); @a.roll(20).say 15:55
camelia (6 2 r 2 n A S 0 z q X I p U t W k h C 0)
Xliff m: my @a = flat('a'..'z', 'A'..'Z', 0..9, '_'); @a.roll(20).join.say
camelia r4tdOpEpHU6n2hH1loPs
Xliff m: my @a = flat('a'..'z', 'A'..'Z', 0..9, '_'); @a.roll(20).join.say
camelia 5xrW_64rgd2x_XhlCZpy
Xliff m: my @a = flat('a'..'z', 'A'..'Z', 0..9, '_'); @a.roll(20).join.say
camelia uFMPs44384Gsg31Q_Jd2
Xliff m: my @a = flat('a'..'z', 'A'..'Z', 0..9, '_'); @a.roll(20).join.say
camelia 6bRYAKhRC4tX2RAF6_aj
pedr0 Hi there, I am struggling in defining a simple grammar which given the token "one two three" for instance, parse the token and take the appropriate actions to print "1 2 3" 18:29
Altai-man_ pedr0, hi! Can you provide an example of your grammar so we could help to tweak it?
pedr0 pastebin.com/Cmjbx9SB 18:30
pedr0 I am used to Flex/Bisont/C but I must admit I am pretty new to perl 18:30
lil hello
pedr0 so do not be surprised if it seems completely unreasoable
how do I make the token "ONE" return the numerical value 1 and how do I make use of it > 18:31
?
Altai-man_ pedr0, 1)rules (tokens regexes as well) are different from tokens in flex/bison, in a way they are not literal, but regexes as well 18:32
and thus you need to call them as well
pedr0, to translate your tree into something else you want to use a thing called "actions"
pedr0, have you read docs.perl6.org/language/grammar_tutorial ?
lil, hi! 18:33
pedr0 wait I just realized I sent you the half backed example
pastebin.com/caDkDJhw 18:34
there should be actions there
Altai-man_ pedr0, I believe you are assuming flex/bison syntax, but it is very different from raku grammars. I'd recommend you to read the tutorial I linked. 18:35
pedr0 sorry about that - I had to strip off some bits from the original file
docs.perl6.org/language/grammar_tu...th_actions 18:37
go at the bottom to that web page and you will find something similar to what I am trying to do, I am not a complete fool ! LoL
lil When I tried to translate all the file extensions in the cro project to .raku, my files were no longer “located”. I changed the database file back to .pm6 and it became located again. Meta6 file changed. To repeat the error, you need to write cro run. Repository github.com/Lenin1917/rakunews 18:38
Altai-man_ pedr0, sure, the task is reasonable, I mean the syntax is wrong. Something that you want will be, let me see...
lil can i fix this problem?
Altai-man_ lil, new extensions are not yet supported _everywhere_ and so there is a transition period taking action. it is not really recommended to jump into new extensions unless you 100% know what you're doing. 18:39
lil (( 18:40
Altai-man_ lil, also, a working extension for raku module is rakumod, while .raku is for scripts.
lil, so it is worth trying out if with rakumod you'll have more success. ;)
lil, by the way, I don't see META6.json in your repo at all, which is... odd to see. kind of valid, but odd. 18:41
lil yay!! it`s works! 18:42
pedr0 I think I am getting completely wrong the action 18:43
Altai-man_ m: grammar Number { token TOP { <scalar> }; token scalar { 'one' | 'two' } }; class Actions { method TOP($/) { make $<scalar>.made; }; method scalar($/) { with $/.Str { when 'one' { make 1 }; when 'two' { make 2 }; } } }; Number.parse('one', actions => Actions).say;
camelia 「one」
scalar => 「one」
Altai-man_ m: grammar Number { token TOP { <scalar> }; token scalar { 'one' | 'two' } }; class Actions { method TOP($/) { make $<scalar>.made; }; method scalar($/) { with $/.Str { when 'one' { make 1 }; when 'two' { make 2 }; } } }; Number.parse('one', actions => Actions).made.say; 18:44
camelia 1
Altai-man_ pedr0, ^ this is a simplified solution for what you want to do
lil, \o/
lil altai-man_ thats why Meta6 in rakunews directory
pedr0 thanks A LOT - let me try to put my head there 18:45
Altai-man_ lil, oh, I am silly, sorry. was also thinking "and there are no service file nor .cro.yml, odd but ok" and somehow didn't notice there is a subdirectory just for this stuff. :) 18:46
maybe because I usually put keep the website repo flat, but that's a matter of preference
s/put// 18:47
pedr0 is it supposed to work if I "inline" the actions in the tokens' definition ? 18:53
without having to define another class for actions
Altai-man_ pedr0, no, it isn't 18:54
that's the difference that confused you, I guess
pedr0 Yeah, am I getting the tutorial completely wrong then ? The last part uses those stuff
Altai-man_ grammars are used simply as a quck way to create parsers which produce parsing trees 18:55
pedr0, where? In "Grammars by example with actions" section you linked to both grammar and an actions class are used
nothing is inlined there
pedr0 the bottom of this link 18:56
docs.perl6.org/language/grammar_tutorial#___top
are those inlined actions ?
Altai-man_ pedr0, I see what you mean... indeed, it is possible, but so rare I didn't know about this after a couple of years of active raku usage. :S 18:58
sorry for the confusion 18:59
then something like this:
Altai-man_ m: grammar Number { token TOP { <scalar> { make $<scalar>.made } }; token scalar { 'one' | 'two' { make $/.Str eq 'one' ?? 1 !! 2 } } }; class Actions { method TOP($/) { make $<scalar>.made; }; Number.parse('one').say; 19:00
camelia 5===SORRY!5=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> 3calar>.made; }; Number.parse('one').say;7⏏5<EOL>
Altai-man_ m: grammar Number { token TOP { <scalar> { make $<scalar>.made } }; token scalar { 'one' | 'two' { make $/.Str eq 'one' ?? 1 !! 2 } } }; Number.parse('one').say;
camelia 「one」
scalar => 「one」
Altai-man_ m: grammar Number { token TOP { <scalar> { make $<scalar>.made } }; token scalar { 'one' | 'two' { make ($/.Str eq 'one' ?? 1 !! 2) } } }; Number.parse('one').say;
camelia 「one」
scalar => 「one」
Altai-man_ hmmm 19:01
pedr0 I am better off with a different class I reckon 19:02
overall ... it is better coding I think, as it could be too concise otherwise
Altai-man_ yes, I'd suggest that. The thing is that it is much cleaner this way to separate the format and the translation. 19:03
and if your grammar is not really tiny, it'll become big and hard to comprehend fast
pedr0 yeah
I see
Another thing if I can is 19:04
let's suppose I have the production
TOP -> SCALAR | SCALAR SCALAR
how do I account for that in the action method ?
shred_alert Isn't it just less work to learn how to use a parser generator, when grammars get really big?
pedr0 that's a parser generator I suppose
do I need to check for the number of arguments "by hand" within the action's method ? 19:05
Altai-man_ m: grammar Number { token TOP { <scalar> { make $<scalar>.made } }; token scalar { [ 'one' | 'two' ] { make ($/.Str eq 'one' ?? 1 !! 2) } } }; Number.parse('two').made.say;
camelia 2
Altai-man_ m: grammar Number { token TOP { <scalar> { make $<scalar>.made } }; token scalar { [ 'one' | 'two' ] { make ($/.Str eq 'one' ?? 1 !! 2) } } }; Number.parse('one').made.say;
camelia 1
Altai-man_ made inlined actions work. \o/
pedr0, the second branch won't be executed, since the first one always match it 19:06
no?
pedr0 sorry, I owe you an apology - very silly example 19:07
Altai-man_ shred_alert, it depends on number of things
pedr0 SCALAR -> TOKEN0 | TOKENX TOKENY
method SCALAR($/) { do I need to check the number of paramters to understand the production I've been called from ? } 19:08
Altai-man_ pedr0, ok, so in a method in actions for the rule you get the `$/` variable and you can access parts of this rule by either index ($/[0], $/[1] etc, or shortcuts $0, $1 etc) or a name if it is a named capture
so you can check if the named capture is present and if yes, it's one branch, otherwise - another one
like... 19:09
m: my regex foo-or-bar { $<foo>='foo' | $<bar>='bar' }; my $match = 'foo' ~~ /<foo-or-bar>/; say $match 19:10
camelia 「foo」
foo-or-bar => 「foo」
foo => 「foo」
19:10
Altai-man_ m: my regex foo-or-bar { $<foo>='foo' | $<bar>='bar' }; my $match = 'foo' ~~ /<foo-or-bar>/; with $match<foo> { say "Foo was matched!" } orwith $match<bar> { say "Bar was matched!" } 19:11
camelia ( no output )
Altai-man_ oops
shred_alert "Token methods are faster than regex methods and ignore whitespace." Wouldn't it be a nice addition to say 'tokens don't backtrack'?
Altai-man_ m: my regex foo-or-bar { $<foo>='foo' | $<bar>='bar' }; my $match = 'foo' ~~ /<foo-or-bar>/; with $match<foo-or-bar><foo> { say "Foo was matched!" } orwith $match<foo-or-bar><bar> { say "Bar was matched!" } 19:12
camelia Foo was matched!
Altai-man_ pedr0, ^
pedr0 I see
shred_alert I feel like that would clear up a lot. Say tokens don't backtrack and are lazy regexes.
pedr0 great 19:13
thanks a lot indeed
Altai-man_ shred_alert, "tokens do not backtrack" is mentioned clearly at docs.perl6.org/language/grammars#Named_Regexes
shred_alert Oh. I was just talking about the grammar tutorial 19:15
:P
Sorry
Should have been more clear
Altai-man_ shred_alert, well, you can't mention all the info everywhere so that it'd be accessible everywhere, so a line should be drawn somewhere... 19:16
shred_alert It's just one tiny line though. I feel it would really add to the tutorial.
And it's a pretty important detail. 19:17
Altai-man_ shred_alert, can't argue with that. do you want to write it up or file a ticket?
shred_alert I can submit something on GitHub after dinner.
Altai-man_ ++shred_alert 19:18
thanks!
shred_alert No worries :)
How does "They don't backtrack. They give up after the first possible match." sound? 19:21
pedr0 last one ;) 19:23
what if I want to return the value of an operation
can I write
make $<ONE> * $<TWO>
to return the product of two tokens 19:24
I meant
make $<ONE>.made * $<TWO>.made
Altai-man_ pedr0, you can write that
guifa thinks he’s got the strongly typed Raku doc draft mostly done. 19:52
Any thoughts? Am I missing anything or need any extra examples? gist.github.com/alabamenhu/3877fa6...d1661f69f9
lizmat guifaL could you give a use case for a parameterizable Pair ? 20:02
guifa lizmat: not off the top of my head. In the example, I was thinking I could do something like 20:09
*%hash where .pairs.all ~~ Pair[Value,Key]
Aha! I found one 20:12
guifa Well, maybe 20:13
It seems the error oddly holds even for hash assignment 20:14
p6: my Associative[Str,Int] $foo = Hash[Str,Int].new(a => 1) 20:15
camelia Type check failed in assignment to $foo; expected Associative[Str,Int] but got Hash[Str,Int] ($(my Str %{Int}))
in block <unit> at <tmp> line 1
guifa but that’s not a problem for positional 20:16
p6: my Positional[Str] $foo = Array[Str].new("a","b")
camelia ( no output )
lizmat guifa: the Associative role in core carries this comment:
# These methods must be implemented by any object performing the Associative role. The reason this is not actually activated, is that there are some chicken-and-egg issues with building the core if we do. 20:17
i think that's the reason Associative vs Hash doesn't work
guifa I can’t imagine people using that one too often, thankfully. I tried to cover the most common use cases and gotchas (and I hope my slurpy section scared people away from using them haha) 20:19
Oh, this works, though, maybe I’ll mention it somewhere
p6: my Associative[Str,Int] $foo = Hash.new(a => 1) does Associative[Str,Int]; say $foo.WHAT
camelia (Hash+{Associative[Str,Int]})
guifa There’s no problem doubling it up, with Hash[Str,Int] does Associative[Str,Int], so it can type match both levels 20:20
Geth doc: alexandrianlibrarian++ created pull request #3153:
Add note that token methods don't backtrack and what that means.This …
20:30
shred_alert Oh cool 20:32
Git activity shows up here
lizmat AlexDaniel: RT#128092 is NOT in the mapping gist, but RT redirects it to 5252 20:40
that ticket is referenced in Stringy 20:41
same for 128318 redirecting to 4999 (which is 127168 in RT) 20:48
cpan-raku New module released to CPAN! Gnome::GObject (0.15.9) by 03MARTIMM 20:51
Geth doc: facd93dcbb | alexandrianlibrarian++ | doc/Language/grammar_tutorial.pod6
Add note that token methods don't backtrack and what that means.This should be helpful to newcomers.
20:55
doc: f5b7405db7 | (Juan Julián Merelo Guervós)++ (committed using GitHub Web editor) | doc/Language/grammar_tutorial.pod6
Merge pull request #3153 from alexandrianlibrarian/master

Add note that token methods don't backtrack and what that means.This … Thanks!
AlexDaniel lizmat: I have a feeling that it's a merged ticket 20:59
lizmat ahhh... ok, so you're saying the redirect is correct ? 21:00
AlexDaniel lizmat: yeah, the redirect itself is correct: rt-archive.perl.org/perl6/Ticket/D...?id=127951
lizmat ok, I'll take those in the second round: I'm going through the setting replacing all RT references to new URLs now 21:01
AlexDaniel is there a need to do that?
lizmat yes, because RT will not stay around indefinitely 21:02
AlexDaniel hmm
lizmat so those references need to be updated
AlexDaniel but maybe delay it for a bit?
lizmat why?
AlexDaniel or… I don't know
thing is, some of these tickets will move
for example, some were already moved to raku/doc
cpan-raku New module released to CPAN! Gnome::Gtk3::Glade (0.8.8.1) by 03MARTIMM
lizmat well, I'm checking them all now
AlexDaniel at least the open ones will
lizmat so if I run into a moved ticket, i'll let you know 21:03
in any case, RT wouldn't know about a moved ticket anyway, right?
AlexDaniel it's not an issue, it'll be just one more redirect away
lizmat does GH redirect moved tickets ?
AlexDaniel RT will redirect to github and then github will redirect to another repo
lizmat ok
AlexDaniel let me find an example…
lizmat and when RT goes down, we're stuck 21:04
note the use of "when" gere
*here
Grinnz has anyone said RT will go down?
AlexDaniel rt.perl.org/Ticket/Display.html?id=126459
Grinnz my understanding was the read-only site would stay up indefinitely 21:05
lizmat Grinnz: no, but I think the chance of RT becoming unavailable is orders of magnitude larger than of GH going down 21:05
Grinnz (I did just update references all over the perl source though)
lizmat right, which makes sense
Grinnz: and why did you do that ? 21:06
Grinnz because new users won't understand what RT is
i updated links, haven't updated casual references yet but i plan on that too
lizmat right, :-) 21:07
Grinnz no matter what i update though, links to RT for perl are permanently all over the internet, maybe that's less of a problem for raku
but personally, i'm relying on it being up forever :P 21:08
AlexDaniel lizmat: I guess links to github tickets are better anyway because they're clickable :) 21:09
lizmat indeed :-)
Grinnz yes, many integration benefits
AlexDaniel Grinnz: it's not so much about the integration, we use full links generally 21:10
Grinnz: github.com/perl6/roast/blob/aa4994...ess.t#L143
compare that to RT references above :)
Grinnz as you might expect, it's completely inconsistent what is used in perl source ;) 21:11
Geth ecosystem/JJ-patch-7: 01e95542a1 | (Juan Julián Merelo Guervós)++ (committed using GitHub Web editor) | META.list
Adds Array::Shaped::Console

A shaped-array console-rendering function.
21:28
Geth ecosystem: JJ++ created pull request #478:
Adds Array::Shaped::Console
21:28
ecosystem: 01e95542a1 | (Juan Julián Merelo Guervós)++ (committed using GitHub Web editor) | META.list
Adds Array::Shaped::Console

A shaped-array console-rendering function.
21:35
ecosystem: 0b1a10b5a4 | (Juan Julián Merelo Guervós)++ (committed using GitHub Web editor) | META.list
Merge pull request #478 from perl6/JJ-patch-7

Adds Array::Shaped::Console
unclechu hey, do you know whether distros are going to replace or add a new package called "raku" instead of "perl6"? 22:02
in nix package database "rakudo" still provides "perl6": nixos.org/nixos/packages.html?chan...query=raku 22:03
the same for fedora the distro
Grinnz the fedora packager is fedoraproject.org/wiki/User:Gerd, it would be up to them 22:05
or a new packager could help of course
shred_alert Has the name changed in the rakudo source yet? 22:10
guifa Yay! just sent off my PerlCon proposal. 22:17