🦋 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.
_grenzo Which is better? rule list { '(' [ <item> ',' ]* <item> ')' } or rule list { '(' <item> [ ',' <item> ]* ')' } 15:22
vendethiel %% or % :-) 15:23
_grenzo That went right over my head 🙂 15:24
vendethiel '(' ~ ')' <item>+ %% ','
_grenzo Oh! 15:25
Thanks 15:26
antononcube The second. 16:31
roguerakudev The placeholder is nice
antononcube In this particular case the parenthesiized expression is short, so using ’(‘ ~ ‘)’ … does not make the rule definition more readable. (To me at least.) 16:34
coleman docs.raku.org sent me an alert. I'm checking on it. 18:05
scullucs Interesting. To me the '(' ~ ')' … one is much more readable. 18:11
One reads as "An opening parenthesis, followed by an <item>, followed by a block that holds a comma followed by an item, block that can appear zero or more times, followed by a closing parenthesis."
And the other one as "A parenthesized expression holding one or more items joined with commas."
Of course it only takes a short moment to see that the first one means the same as the second one, but hey, we've got a nice mechanism to express it more simply 🙂 18:13
_grenzo I had never seen that notation before. If @vendethiel hadn't said it was the same thing it would have taken me a while to figure out 18:32
scullucs Oh, the meaning is not obvious, but once learned, it kind of is. 18:34
vendethiel Outside of readibility, it helps with error messages 18:41
Certainly there are some things I’ve forgotten but I’ve been a Raku user for more than a decade :-) 18:42
scullucs I've been using Raku for a while too, and that feature, I knew it existed, but would probably have had to look up the exact syntax (if I had thought of using it instead of the original formulation). 18:43
Raku is a pretty big language 🙂
antononcube @vendethiel Hmm… how so? The syntax implies some sort of an universal error message? 18:58
Xliff \o 19:05
Xliff I think I know the answer already, but is there any way to use the '$' as a prefix operator? 19:09
m: multi sub prefix:<﹩> (Numeric $v) { say "BOO!"; $v + 3 }; say ﹩4 19:12
camelia BOO!
7
Xliff \o/
God bless unicode.
lizmat
.oO( may all your dollar prefixes be small )
19:17
Xliff lizmat: '$' is never allowed. Most of the unicode alternatives just aren't as appealing. 19:20
lizmat yeah, that would slow down parsing significantly if we made $ overrideable
Xliff Figured as much.
I can do this though.... 19:21
m: multi sub prefix:<$$> (Numeric $b) { say "BOO!"; $b }; my $a = $$14 + 2; $a.say
camelia BOO!
16
Xliff Can't have any alphas in that one, though.
m: multi sub prefix:<Z$> (Numeric $b) { say "ZIMBABWE!"; $b }; my $a = Z$14 + 2; $a.say 19:22
camelia ZIMBABWE!
16
Xliff I'm thinking about writing a module for currency symbols.
The pieces are all assembled. I just have a few other questions I want to answer. 19:23
antononcube @Xliff A certain Raku new-comer proclaimed ideas and the making of a similar package recently. 20:04
That was a few months ago. As I recall from reviewing the code, his package covered lots of bases. 20:06