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.
01:30 m_athias left 01:31 m_athias joined 02:31 razetime joined 02:56 Kaipei joined 02:57 Kaiepi left 03:03 Kaiepi joined 03:05 Kaipei left 03:21 Kaiepi left 03:55 razetime left 04:49 razetime joined 05:21 Kaiepi joined 05:23 frost joined 05:54 deoac left 07:04 razetime left 07:05 razetime joined 07:10 razetime left 07:26 razetime joined 07:30 razetime_ joined 07:40 razetime left, razetime_ left 11:55 frost left 12:27 deoac joined
deoac Is there any way to turn off autovivication?  Especially with regard to hash keys? 15:20
lizmat make it a Map ? 15:22
m: my %m is Map = a => 42, b => 666; 15:23
camelia ( no output )
lizmat m: my %m is Map = a => 42, b => 666; dd %m
camelia Map.new((:a(42),:b(666)))
deoac Good idea, but the values need to be mutable. 15:27
15:28 razetime joined, razetime_ joined
deoac Too many of my bugs are caused by a mistake in the key. 15:28
lizmat One of my Perl ports has that functionality, I think 15:29
15:29 razetime left, razetime_ left 15:30 razetime joined
lizmat raku.land/zef:lizmat/Hash::Restricted deoac 15:42
17:37 razetime left
deoac m: my $x='42'; $x = +$x; say $x.^name; 19:11
camelia Int
deoac m: my $x='Foo'; $x = +$x; say $x.^name; 19:12
camelia Failure
deoac How can I get this code to work without a Failure that I need to CATCH?
Nemokosch the "catch" (haha) is that you don't necessarily need to catch Failures 19:15
they don't throw if you coerce them to Bool for example
or you can use a try prefix on the expression that might return a Failure - it will turn them into Nil's
deoac That is, I don't know the contents of $x beforehand.  If it's Numeric, I want to convert it to a number. 19:16
What do you mean by a prefix?
Nemokosch docs.raku.org/language/statement-p...refix)-try 19:17
m: my $x='Foo'; $x //= try +$x; say $x.^name; 19:18
deoac using try (w/o. CATCH!) did the trick!  Thank you 19:19
Nemokosch m: my $x='42'; $x //= +$x; say $x.^name;
oops
m: my $x='42'; $x //= try +$x; say $x.^name;
I think this can work, for example
// for nullish coalescing (like ?? in modern Javascript), try to silence the error
also, I messed up the order
$x = try +$x // $x 19:20
deoac Is there a more 'rakuish' way of $x = +$x?  To avoid the repetition?
Nemokosch might need parens as well
deoac `try $x = +$x;`  worked perfectly
Nemokosch $x .= Int probably 19:21
well fair enough 😅 overthinking is a hell of a drug
deoac $x .= Int probably. <-- that's great to know.  Thanks again. 19:27
Nemokosch 🍬 19:30
19:32 lizmat left 19:33 lizmat joined
gfldex <@297037173541175296> for the last 6 month or so I avoid the term "variable" in my blog and use "symbol", "value" or "container". I have come to the conclusion that any Raku tutorial that doesn't do the same, will be misleading. Which means all of them. 19:36
Nemokosch 😂
I mean, makes sense some way
guifa_ Actually 19:37
.Numeric
Nemokosch perhaps I have said this already but if you come from any language remotely similar to C, "variable" will mean what is basically "scalar container" in Raku 19:38
^ fair
I routinely forget about fractionals because I basically never use them...
gfldex I disagree. C-like languages only have binding. They don't make the distinction between assignment and binding as Raku does. So as soon as you hit Nil, that mental picture breaks down. Containers are objects with a fairly special interface, variables in other languages are much simpler. 19:42
Nemokosch C-like languages don't have binding, rather. There is only passing-by-value, everything is copied 19:44
C++ is essentially built around dealing with these constraints
I also don't get what about "hitting Nil"; in Raku there is both binding and assignment so that doesn't say a thing, in those languages, even if there is something "Nil-ish", it's just a special value, something you can... copy 19:47
gfldex What I meant is, that for a Raku beginner, Nil is confusing. 19:54
Nemokosch that's for sure 😅 20:15