This channel is intended for people just starting with the Raku Programming Language ( Logs are available at
Set by lizmat on 8 June 2022.
00:05 NemokoschKiwi joined 00:07 NemokoschKiwi left 00:36 Manifest0 left 04:57 tbrowder__ left, tbrowder__ joined 07:39 Manifest0 joined 07:58 dakkar joined 08:22 teatwo joined 08:25 teatime left 16:25 swaggboi joined 16:36 dakkar left
librasteve on sigils, the story is $ is a container for any type of thing - Int, Str, List, Array, Hash, Map, Bag, your custom class and so on - @ is a special sigil for Array that brings in (the confusingly named) list assignment and works with Array literals - % is a special sigil for Hash that brings in list assignment and works with Hash literals 17:19
this typegraph is a handy way to see how Array and Hash are assembled from classes and roles so they are the most functionally rich - I guess the raku design concept was to take the perl notions of @array and %hash and to reconstruct from more pure classes and roles 17:23
crag-of-the-week crag '"#ffffff".subst("#").comb(/(..)/).map({:16($_)}).say' 18:05
#(255 255 255)
^^ this is an atypical "crag" in that it does not use Physics::Measure objects .(eg. dimensions and units of measure and so on) ... but I felt that any command line calculator based on raku should be able to help me do colour math for CSS (having said that I think that there is a gap for a new module that does color math in a more concise way) 18:16
lizmat m: '"#ffffff".substr(1).comb(2).map({:16($_)}).say 18:19
camelia ===SORRY!=== Error while compiling <tmp>
Unable to parse expression in single quotes; couldn't find final "'" (corresponding starter was at line 1)
at <tmp>:1
------> ff".substr(1).comb(2).map({:16($_)}).say⏏<EOL>
expecting …
lizmat m: "#ffffff".substr(1).comb(2).map({:16($_)}).say
camelia (255 255 255)
nemokosch @symbol can default to Lists, like in the case of constants 18:21
same with %symbols and Maps
20:00 cleo left 20:01 cleo joined
librasteve m: my @a = (1,2); say @a.WHAT 20:17
Raku eval (Array)
librasteve m: my %h = (a=>1,b=>2).Map; say %h.WHAT 20:18
Raku eval (Hash)
librasteve sure it may be possible to force @ to List and % to Map - but that would be pretty unusual 20:19
nemokosch m: constant @a = (1,2); say @a.WHAT
Raku eval (List)
nemokosch depends on what you count unusual 20:20
librasteve well a constant is not a variable - so i count that as unusual
nemokosch by a similar reasoning, @symbols are by definition unusual 20:21
librasteve bollocks
nemokosch because they don't have containers
librasteve double bollocks
antononcube @librasteve So, four all together? 20:22
20:22 tea3po joined
nemokosch I would say the ratio of "unusualness" is similar for constants among symbols and containerless, "fake" variables among all variables 20:22
20:25 teatwo left 20:27 tea3po left 20:28 tea3po joined 20:29 tea3po left, tea3po joined 20:54 tea3po left 20:55 tea3po joined
gfldex m: constant @lolwut = [1,2]; @lolwut[3] = 42; say „@lolwut[]‼“; 21:09
camelia Use of uninitialized value of type Any in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.
1 2 42‼
in block <unit> at <tmp> line 1
gfldex @librasteve Please note that the declarator ‘constant’ does not create constants. 21:10
nemokosch it's actually crazy how true that is, huh 21:12
m: constant @lolwut = [1,2]; @lolwut = 1; @lolwut.say 21:13
Raku eval [1]
nemokosch even assignment can work on it
m: constant @a = 1,2; say @a.WHAT 21:14
Raku eval (List)
nemokosch hmm
so does binding have low precedence or is it also split into two precedence groups? 🤔 21:15
because pretty sure constants are set up with binding 21:16
lizmat m: my constant %h = a => 42; dd %h.^name
camelia "Pair"
lizmat m: my constant %h = a => 42, b => 666; dd %h.^name
camelia "Map"
lizmat m: my constant %h = { a => 42, b => 666 }; dd %h.^name
camelia "Hash"
nemokosch well. Can a constant be unassigned? Does it even make sense to talk about a "default value" here? 21:17
m: constant @x;
Raku eval Exit code: 1 ===SORRY!=== Error while compiling /home/glot/main.raku Missing initializer on constant declaration at /home/glot/main.raku:1 ------> constant @x⏏;
nemokosch perhaps not
lizmat the problem is that with "my constant @a = [1,2,3]"
you're binding an array at compile time 21:18
with: my constant @a = 1,2,3
you would be initializing a List at compile time
m: my constant @a = 1,2,3; dd @a.^name
camelia "List"
lizmat both have their uses 21:19
gfldex `constant` exists so we can avoid creating Scalar containers with $-sigiled symbols (without using term:<>).
nemokosch isn't that what bindings achieve by default? 21:20
lizmat afk again&
nemokosch anyway, this was surprising:
m: my $true-list := 1, 2, 3; dd $true-list
Raku eval (1, 2, 3)
nemokosch it actually has this low precedence level 21:21
23:40 Manifest0 left