|
This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html Set by lizmat on 8 June 2022. |
|||
| lizmat | it's a meta-op, just like += or *= | 00:17 | |
|
00:37
deoac joined
|
|||
| deoac | m: say 'abcde' ~~ m:ex/ \w ** 2..4/ | 00:37 | |
| camelia | (「abcd」 「abc」 「ab」 「bcde」 「bcd」 「bc」 「cde」 「cd」 「de」) | ||
| deoac | m: my $min = 2; my $max = 4; say 'abcde' ~~ m:ex/ \w ** {$min..$max} / | 00:38 | |
| camelia | (「abcd」 「abc」 「ab」 「a」 「bcde」 「bcd」 「bc」 「b」 「cde」 「cd」 「c」 「de」 「d」) | ||
| deoac | Why the difference? Why does the latter match a single character? | 00:39 | |
| guifa_ | that's definitely an error | 00:43 | |
| And it goes back a good ways | |||
| deoac | Is it expected to be corrected in v6.e? | 00:46 | |
| guifa_ | No idea -- is there a bug report for it? | 00:47 | |
| There are a lot of weird optimizations for regex and I'd bet that the range one somehow trips it up when ex is activated | 00:49 | ||
| deoac | Bug reports are above my pay grade! | 00:57 | |
| guifa_ will try to remember to make one | |||
|
01:01
Heptite joined
|
|||
| Anton Antonov | @deoac Filing or fixing? | 01:29 | |
| deoac | Both. How do I file a bug report? | 01:40 | |
| Anton Antonov | @deoac So, you want pay-raise? | 01:42 | |
| @deoac Hmm... you want for file core Raku / rakudo bug report, right? | 01:43 | ||
| deoac | Yes. Are there other kinds of bug reports. | 01:44 | |
| ? | |||
| Anton Antonov | @deoac Yeah for packages, etc. It seems the you could / should file an issue at GitHub : github.com/rakudo/rakudo/issues . | 01:46 | |
| @deoac Here are the related guidelines : github.com/rakudo/rakudo/blob/95e0...IBUTING.md . | 01:48 | ||
| deoac | Thanks, I'll look into that tomorrow. | 01:49 | |
| How would I find out if this bug report already exists? | 01:50 | ||
| Anton Antonov | Well, please go to github.com/rakudo/rakudo/issues and search. (Both open and closed.) | 01:51 | |
| deoac | I'll let you know what I find/do | 01:55 | |
|
02:05
Manifest0 left
|
|||
| rf | How can I combine 2 slips | 02:44 | |
| m: my @a = 1,2,3,4; my @b = 5,6,7,8; my @c = Array.new(|@a, |@b); | |||
| camelia | ( no output ) | ||
| rf | m: my @a = 1,2,3,4; my @b = 5,6,7,8; my @c = Array.new(|@a, |@b); say @c; | ||
| camelia | [1 2 3 4 5 6 7 8] | ||
| rf | Ok this isn't working for me for some reason in my code | ||
| MasterDuke | you can't/don't want to use .append? | 02:48 | |
| Anton Antonov | @rf maybe just [|@a, |@b] . | 02:53 | |
| rf | I can't use append because I need one to be immutable | 02:54 | |
| Well.. immutable in this certain circumstance. Yeah the error was in a different part of the code, for some reason I thought it was this. | 02:55 | ||
|
02:59
deoac left
04:16
rf left
06:34
MasterDuke left
10:10
Manifest0 joined
|
|||
| snonux | hey, how can i pass an Int to MAIN from the command line? sub MAIN (Int :$foo = 13) { $foo.say; } doesn't seem to work when in run my script with 'raku foo.raku --foo 42'; I think it's because 42 is interpreted as a Str, and therefore the MAIN signature doesn't match! The example works when I change the signature to sub MAIL (Str :$foo = '13') { $foo.say }; | 11:43 | |
| s/MAIL/MAIN/ | |||
| el gatito (** advocate) | you need to coerce it to Int | 11:45 | |
| snonux | i can cast it to Int afterwards. or is there a way to do it directly in the MAIN signature? | 11:47 | |
| ab5tract | snonux: you can coerce in the signature with Int() | ||
| that way if the candidate can coerce to Int, it will | 11:48 | ||
| you can also make it targeted against a single candidate class, such as Int(Str), but that is a bit less common | |||
| el gatito (** advocate) | ``` sub MAIN(Int(Str) :$foo = 13) { $foo.say } | 11:49 | |
| ab5stract: i thought its the opposite | |||
| ab5tract | what, that it's less frequent to leave the candidate open? | 11:52 | |
| gfldex | Since MAIN will always be called with Str-arguments, Int(Str) is redundant. | 11:53 | |
| If at all, use Int(Str:D) or you may end up with a 0 you don't want. | |||
| snonux | ❯ /bin/cat foo.raku | 11:54 | |
| sub MAIN(Int(Str) :$foo = 13) { | |||
| say $foo; | |||
| say $foo.WHAT; | |||
| } | |||
| paul in earth in /tmp | |||
| ❯ raku foo.raku --foo=121212 | |||
| ab5tract | It's more of a gradual typing approach to just use Int(), but that's really a matter of personal preference | ||
| snonux | 121212 | ||
| (IntStr) | |||
| yeah, seems to work. i guess IntStr is a type which is both, Int and Str. | 11:55 | ||
| ab5tract | yeah, that's correct. It's an allomorph. You can safely use `$foo` in both numeric and string contexts without anything complaining | ||
| snonux | nice, thanks ab5tract | ||
| Int() seems better, as Int(Str) is redundant. thanks! | 11:56 | ||
| Nemokosch | can't you just use Int? | 11:57 | |
| and if you can't, that's arguably a bug | |||
| el gatito (** advocate) | no i mean i thought the syntax is Str(Int) | 11:58 | |
| Nemokosch | Str(Int) = "get me a Str from an Int" | ||
| ab5tract | It's the other way around. | 11:59 | |
| Int() = coerce all candidates that implement an Int coercion to Int | |||
| el gatito (** advocate) | Int = no coercion | 12:00 | |
| ab5tract | Int(Str) = coerce only Str candidates to Int | ||
| Nemokosch | yes, it should work with no coercion | ||
| ab5tract | Nemokosch: hard disagree | 12:01 | |
| Nemokosch | I mean, it literally does work when it's not bugged | ||
| this is not a matter of opinion | |||
| ab5tract | what are you talking about? | ||
| Nemokosch | you can just use Int parameters in the MAIN | 12:02 | |
| ab5tract | m: sub f(Int $i) { dd $i}; f(5); f("5") | ||
| camelia | ===SORRY!=== Error while compiling <tmp> Calling f(Str) will never work with declared signature (Int $i) at <tmp>:1 ------> sub f(Int $i) { dd $i}; f(5); ⏏f("5") |
||
| Nemokosch | that's not MAIN | ||
| ab5tract | Yeah, but what you are suggesting is wrong. MAIN inputs are always strings | 12:03 | |
| nothing is special-cased about its handling except for that it runs when you run the script | |||
| otherwise it would be broken | |||
| Nemokosch | from the perspective of the callee, they are not | ||
| ab5tract | they clearly are | ||
| Nemokosch | m: sub MAIN(Int $foo, Str $) { dd $foo } @*ARGS=<42 11>; | 12:04 | |
| Raku eval | IntStr.new(42, "42") | ||
| Nemokosch | BRUH | ||
| yes, it does work with Int, like it always did | 12:05 | ||
| ab5tract | chill, please | ||
| Nemokosch | then please at least check what you are saying before you get confident about it | ||
| ab5tract | we can all be wrong without being rude to each other | 12:06 | |
| Nemokosch | or we can be humble about something we aren't actually sure of... | 12:07 | |
| ab5tract | I can see now why people say you make this all a lot less fun | 12:08 | |
| Nemokosch | you just made a blatantly wrong statement with full confidence, why make this about me? | 12:09 | |
| ab5tract | I made an error. I'll admit it. I'd ask why you have to be so aggressive but I don't think I will continue responding to you | 12:10 | |
| Nemokosch | well it does happen that somebody loses patience when somebody denies commonsensical reality in the most declarative way, sorry if this hurts so much | 12:11 | |
| ab5tract | If no one can be wrong without being attacked and belittled by you, there will necessarily be a chilling effect in every channel you are in | 12:13 | |
| lizmat | Zephyr | 12:15 | |
| Nemokosch | I don't think it's an attack to say that somebody was too wrong for this amount of confidence | 12:16 | |
| lizmat | Nemokosch your amount of right becomes meaningless if nobody wants to interact with you anymore | 12:17 | |
| and you appear to have a way of behaving online that is perceived by people as attacks | 12:18 | ||
| that *should* make you wonder | |||
| Nemokosch | It shouldn't even be necessary to say that one needs to check their facts before getting protective about them | ||
| should I also take it as an attack that I said something true and it was discarded with little reasoning? does that change a lot? | 12:19 | ||
| lizmat | I'm not getting into an argument with you | 12:20 | |
| I won't be the frog in en.wikipedia.org/wiki/The_Scorpion_and_the_Frog | |||
| Nemokosch | You don't have to. Just please, if you know how to tell somebody kindly that they are wrong, go ahead and do so, for everyone's benefit. | 12:22 | |
| lizmat | this isn't about content, this is about your online behaviour | ||
| Nemokosch | and I'm not gonna engage in another lesson like that. Have a nice day | 12:23 | |
| lizmat | You too | 12:26 | |
| el gatito (** advocate) | why all MAIN inputs are strings | 12:27 | |
| lizmat | well, the situation is slightly more complicated | ||
| yes, the command line only supplies strings | 12:28 | ||
| however each string is processed by val() before given to MAIN dispatch docs.raku.org/routine/val | |||
| which, BTW, is also what <foo bar> does by default | 12:29 | ||
| m: dd <foo 42 bar> | |||
| camelia | ("foo", IntStr.new(42, "42"), "bar") | ||
| lizmat | note that the "42" turned into an allomorph | ||
| and that *will* dispatch correctly to a Int candidate | 12:30 | ||
| and it will dispatch to a Str if there is no Int | |||
| m: sub a(Int $a) { dd $a }; a "42" | 12:31 | ||
| camelia | ===SORRY!=== Error while compiling <tmp> Calling a(Str) will never work with declared signature (Int $a) at <tmp>:1 ------> sub a(Int $a) { dd $a }; ⏏a "42" |
||
| lizmat | m: sub a(Int $a) { dd $a }; a <42> | ||
| camelia | IntStr.new(42, "42") | ||
| lizmat | m: sub a(Str $a) { dd $a }; a <42> | ||
| camelia | IntStr.new(42, "42") | ||
| lizmat | so Nemokosch example was dubious, as it supplied allomorphs, rather than Ints | 12:32 | |
| m: sub MAIN(Int $foo, Str $) { dd $foo } @*ARGS="42",11 | |||
| camelia | ===SORRY!=== Error while compiling <tmp> Strange text after block (missing semicolon or comma?) at <tmp>:1 ------> sub MAIN(Int $foo, Str $) { dd $foo }⏏ @*ARGS="42",11 expecting any of: infix infix stopp… |
||
| lizmat | m: sub MAIN(Int $foo, Str $) { dd $foo }; @*ARGS="42",11 | ||
| camelia | This type cannot unbox to a native string: P6opaque, Int in block <unit> at <tmp> line 1 |
||
| lizmat | m: sub MAIN(Int $foo) { dd $foo }; @*ARGS="42" | 12:33 | |
| camelia | IntStr.new(42, "42") | ||
| lizmat | intriguing | ||
| el gatito (** advocate) | allomorphs be like | 12:34 | |
| lizmat | yeah... ok, looks like &RUN-MAIN by default does coercion to allomorphs | 12:35 | |
| ab5tract | I wonder how hard it would be to wire up the val behavior for named arguments. I almost always use named arguments, especially with type constraints, so I don't remember encountering this case before | ||
| lizmat | doesn't it do so already? | 12:36 | |
| ab5tract | Which led to my (wrong) assumption that dispatch to MAIN is the same as to any old sub | ||
| lizmat: nppe, that's how we got into this discussion :) | 12:37 | ||
| el gatito (** advocate) | yet another weak typing Str coercing to Int via IntStr when you don’t want to | ||
| lizmat | m: sub MAIN(|c) { dd c }; @*ARGS="--foo=42" | ||
| camelia | \(:foo(IntStr.new(42, "42"))) | ||
| lizmat | nameds are already converted to allomorphs ? | ||
| ab5tract | m: sub MAIN(|c) { dd c }; @*ARGS="--foo 42" | 12:38 | |
| camelia | \("foo 42" => Bool::True) | ||
| ab5tract | maybe it was because he didn't use an equals sign | ||
| lizmat | yes, you need an equal sign in default RAKU arg passing | 12:39 | |
| el gatito (** advocate) | what happened with raku argparsing | ||
| ab5tract | m: sub MAIN(Int :$foo) { dd $foo }; @*ARGS="--foo 42" | ||
| camelia | Usage: <tmp> [--foo[=Int]] |
||
| ab5tract | m: sub MAIN(Int :$foo) { dd $foo }; @*ARGS="--foo=42" | ||
| camelia | IntStr.new(42, "42") | ||
| ab5tract | yup, that must have been it | ||
| snonux: ^^ | |||
| el gatito (** advocate) | it should be parsed as (42, foo => True) | ||
| lizmat | m: m: sub MAIN(Int :$foo) { dd $foo }; @*ARGS="--foo","42" | 12:40 | |
| camelia | Usage: <tmp> [--foo[=Int]] |
||
| lizmat | m: m: sub MAIN(|c) { dd c }; @*ARGS="--foo","42" | ||
| camelia | \(IntStr.new(42, "42"), :foo(Bool::True)) | ||
| lizmat | like that ? | ||
| in standard arg parsing, a variable name cannot have a space in it | |||
| ab5tract | el gattito: yeah, my example was a bit broken | 12:41 | |
| snonux | paul in earth in /tmp took 4s | ||
| ❯ raku foo.raku --foo=121212 | |||
| 121212 | |||
| (IntStr) | |||
| paul in earth in /tmp | |||
| ❯ raku foo.raku --foo 121212 | |||
| Usage: | |||
| foo.raku [--foo[=Int]] | |||
| lizmat | so if you set up @*ARGS incorrectly in these examples... | ||
| snonux | zsh: exit 2 raku foo.raku --foo 121212 | ||
| okay, the '=' has to be added | |||
| Nemokosch | consider checking out the Getopt::Long module | 12:42 | |
| lizmat | if you want more "standard" arg passing, have a look at raku.land/cpan:LEONT/Getopt::Long | ||
| afk for a bit again& | |||
| el gatito (** advocate) | raku argparse is not standard lmao | ||
| snonux | i like the raku built-in, the fewer external dependencies, the better :-) | ||
| i think the getopt long is following a GNU standard. but i don't persist on GNU standards. | 12:45 | ||
| el gatito (** advocate) | funi C:\Users\jack9\Documents\raku>raku argparse.raku 42 --foo \(IntStr.new(42, "42"), "--foo") | 13:02 | |
| ab5tract | el gatito: does your argparse.raku use `named-anywhere` ? docs.raku.org/language/create-cli#...d-anywhere | 13:06 | |
| el gatito (** advocate) | no | 13:12 | |
| ab5tract | that's the first thing I setup if I'm mixing positional and named arguments | 13:15 | |
| el gatito (** advocate) | short options is not treated differently smh PS C:\Users\jack9\Documents\raku> raku argparse.raku -abc \(:abc(Bool::True)) | ||
| you have to enable it in %*SUB-MAIN-OPTS | |||
| ab5tract | yeah, bundling | 13:16 | |
| el gatito (** advocate) | with that enabled it just introduce another issue PS C:\Users\jack9\Documents\raku> raku argparse.raku --abc \(:abc(Bool::True)) | 13:19 | |
| -abc is the same as --abc somehow | |||
|
15:31
rf joined
19:25
theesm left
19:27
theesm joined
19:35
deoac joined
19:40
ab5tract left
20:05
deoac left
23:39
deoac joined
|
|||