[00:25] *** getimiskon left [01:22] m: say my $hey-raku-what-kind-of-problems-can-i-solve-with-you; [01:30] m:``` [01:30] sub postfix:(\p) { p } [01:30] say my $hey-raku-what-kind-of-problems-can-i-solve-with-you?; [01:30] ``` [01:31] I will be damned if I can't put that into a blog post. :) [02:57] *** mjgardner left [02:58] *** mjgardner joined [08:03] hey folks, I'm playing with grammars, and I have a problem: I want to match a pascal-style string, where the length of the string is an int at the prefix, e.g. 1a 3abc 5abcde. I think I could do by defining [08:05] a rule that takes a parameter e.g. ``` grammar Pascal { [08:05] token TOP { )> } [08:05] token length { <[0..9]> } [08:05] token payload($length) { 'x' x { $length.Int } } [08:05] } [08:05] ``` [08:05] but I always seem to ge Nil as $length in [08:05] did I imagine this syntax? [08:05] a rule that takes a parameter e.g. ``` grammar Pascal { [08:05] token TOP { )> } [08:05] token length { <[0..9]> } [08:05] token payload($length) { 'x' x { $length.Int } } [08:05] } [08:05] ``` [08:05] but I always seem to get Nil as $length in [08:05] hey folks, I'm playing with grammars, and I have a problem: I want to match a pascal-style string, where the length of the string is an int at the prefix, e.g. 1a 3abc 5abcde. I think I could do this by defining [09:15] in Pascal? [09:15] I've never seen anything like this in Pascal [09:29] AFAIR it was the way strings were represented, with prefix length, rather than being null terminated like in C [09:30] https://stackoverflow.com/questions/25068903/what-are-pascal-strings#25079998 [09:30] https://stackoverflow.com/questions/25068903/what-are-pascal-strings#25079998 [09:50] The issue afaik is that at the time you are trying to do the call, $/ is unset [09:51] Try })> [10:25] represented internally, not in the language though [10:25] sure [12:25] is there a way to pass a factory to `is default(BagHash.new)` for example. If you give it a sub, it just calls the sub, but this way all defaults share the same BagHash [12:35] are you going to mutate the default value? [12:35] yes [12:35] why? [12:38] in this specific example, I need an array which contains more arrays [12:40] i eventually figured out you can just the `:U` variants of .push etc, but it would be nice to be able to set a default [12:40] default function argument or default type value? [12:52] default type value [12:52] sth like `my @a is default([])` [12:52] sth like `my @a is default([]);` [13:00] I don't know a language that has mutability and this would work [13:00] C in a way [13:02] python has a defaultdict which takes a function that produces the default values, and I believe julia has a similar features with its macros [13:02] python has a defaultdict which takes a function that produces the default values, and I believe julia has a similar feature with its macros [13:03] well, that's not a part of the language [13:04] one could implement a defaultdict in many languages [13:04] maybe even in Java these days [13:05] hmm, yeah, seems is default can't do this [13:05] well, IG just handrolling a defaultdict is the way to go [13:06] > Sets the default value with which a variable is initialized, and to which it is reset when Nil is assigned to it. Trait arguments are evaluated at compile time. Closures won't do what you expect: they are stored as is and need to be called by hand. [13:06] sounds like a rip [13:33] *** TempIRCLogger left [13:37] *** TempIRCLogger joined [13:41] *** TempIRCLogger left [13:41] *** TempIRCLogger joined [13:45] *** TempIRCLogger left [13:46] *** TempIRCLogger joined [15:23] Is there no check if a string is uppercase, or a character, or would I have to use a regex? [15:50] well it seems using the `<:Lu>` regex pattern is my best bet and works well [16:55] m: say "Abc".&{ .uc eq .Str }; [17:05] ah alright, thanks! [18:26] *** getimiskon joined