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.
00:02 frost joined 01:30 m_athias left 01:31 m_athias joined 01:36 frost left 03:22 reol left, reol joined, reol left 03:24 frost joined 03:33 frost left
elcaro `{S:g/./$/$//}` is a little shorter 03:56
04:01 Heptite left
South see here 04:29
elcaro oh, I missed that 04:33
04:36 discord-raku-bot left, discord-raku-bot joined
yabobay if you have "if" at the end of a statement, is there no way to have an else? 05:19
South nope you cannot 05:20
its the same case in ruby
you can read more about that here <docs.raku.org/syntax/if#else/elsif> 05:21
there are ternaries that do this but depending on how you like your code some things might better be served with an actual if/else block, like modifying variables 05:23
05:25 discord-raku-bot left 05:26 discord-raku-bot joined
elcaro Yeah, you want a ternary 05:29
`my $y = $x > 3 ?? 'big' !! 'smol';`
Or you know... maybe not
`my $y = (if $x > 3 { 'big' } else { 'smol' });`
yabobay ooo
actually yes
South for that particular case i would definitely go with the ternary 05:31
elcaro yeah... but if you feel like you wanna nest ternarys... it's usually a recipe for poor readability, and an `if/else` block is probably better 05:35
South this is very trye
this is very true
and i have been known to do such things in the name of wickedness
yabobay ```perl
$c < $_.chars ?? $_.substr($c, 1).uc !! ' '
```
this is fine then?
elcaro haha yes! I've sometimes started with a ternary, then expanded it with another condition or two before I realise what a monstrosity it is
Even trying to format it logically, this is ugly 05:36
```
say $x > 5
?? $x %% 2
?? $x == 10
?? 'big-ten'
!! 'big-even'
!! 'big-odd'
!! 'smol'
```
South yeah definitely lmfao 05:37
elcaro yeah this is fine. Ternarys are good for short if/else with simple expressions.
yabobay im trynna figure out why ?? and !! 05:39
is it?? then do this thing
its not!! well then do something else
South `cond ?? if_true !! if_false`
yabobay i know this is not from raku or from perl but it just looks funny to me
South tho usually youll see `cond ? if_true : if_false` in other languages like ruby/java/c++(iirc) 05:40
elcaro As <@768182477449592832> said, ternary in C, Perl (and other C-like langues) is written `cond ? if_true : if_false`... but since ternary is not really used much, it was decided that the `:` was too valuable to waste on it. 06:37
If anything `??` and `!!` make a little more sense in Raku, since `?` prefix boolifies something, and `!` does negative-boolification 06:38
```
[0] > ?'yes'
True
[1] > !'no'
False
[2] > ?0
False
[3] > !0
```
If anything `??` and `!!` make a little more sense in Raku, since `?` prefix boolifies something, and `!` does negative-boolification
```
[0] > ?'yes'
True
[1] > !'no'
False
[2] > ?0
False
[3] > !0
True
```
07:43 frost joined 08:30 archenoth left
One final footnote... For a brief period of time, raku ternary syntax supported the use of `⁇` and `‼` (eg. `$x > 5 ⁇ 'big' ‼ 'smol'`, but it was reverted for various reasons (poor font support/displaying as emoji‼, and weird error messages) 09:06
One final footnote... For a brief period of time, raku ternary syntax supported the use of Unicode characters `⁇` and `‼` (eg. `$x > 5 ⁇ 'big' ‼ 'smol'`, but it was reverted for various reasons (poor font support/displaying as emoji‼️, and weird error messages) 09:17
10:29 archenoth joined 11:13 reol joined 12:06 frost left 12:57 Kaiepi left
yabobay but if it was optional, why did it matter 13:52
if you could still do it the ascii way
13:58 reol left
elcaro You could probably dig up the commit... but from what I recall, there wasn't really much enthusiasm for them in the first place... but they were added "just because" 14:00
I think the ternary is a special case in the parser (I may be wrong on this) which might explain why there was confusing error messages when you had a syntax error in the ternary.
Plus the font/rendering issues...the main takeaway was "maybe we shouldn't add unicode ops "just because"
You could probably dig up the commit... but from what I recall, there wasn't really much enthusiasm for them in the first place... but they were added "just because"
I think the ternary is a special case in the parser (I may be wrong on this) which might explain why there was confusing error messages when you had a syntax error in the ternary. Plus the font/rendering issues.
The main takeaway was "maybe we shouldn't add unicode ops "just because"
You could probably dig up the commit... but from what I recall, there wasn't really much enthusiasm for them in the first place... but they were added "just because"
I think the ternary is a special case in the parser (I may be wrong on this) which might explain why there was confusing error messages when you had a syntax error in the ternary... Plus the font/rendering issues.
The main takeaway was "maybe we shouldn't add unicode ops "just because"
yabobay but there's enthusiasm for digits in random languages? 14:02
like tibetan or what was it?
elcaro Well, I don't think it requires much effort to support them. Anything in the `Nd` block (Number, Decimal digit) gets parsed as a number. 14:12
Also, what you call a "random language" could be someone's native language. Those _numbers_ are valid digits, just as valid as Arabic numerals.
yabobay yeah, but raku itself is in english 14:14
and why support some languages but not others?
i tried chinese digits, they didn't work
elcaro Probably because they do not have the Unicode property (Nd) that defines them as a digit? 14:21
```
[4] > '六'.uniprops
(Lo)
[5] > '८'.uniprops
(Nd)
```
14:32 Heptite joined
logs.liz.nl/perl6/2017-03-14.html#14:26-0003 15:54
glancing at some of those messages, I seems to me that it represented an additional maintenance burden for comparatively little benefit. 16:00
glancing at some of those messages, it seems to me that it represented an additional maintenance burden for comparatively little benefit.
If you really must have them... font ligatures may satiate you.
16:03 Kaiepi joined
stevied anyone know where an updated version of this page is? docs.raku.org/perl6.html 16:27
yabobay i don't really want them at all, i think having unicode characters *anywhere* outside of a string literal is weird 16:35
16:36 razetime joined
elcaro All the characters you just typed are Unicode 😀 16:43
But I know what you mean... you mean you only want ASCII... but that is a very Anglo-centric view of language. ASCII is also very limiting in terms of operators. Raku is implicitly trying to push against these restrictions and limitations.
yabobay what kinda operator would you want that's not doable with ascii? 16:44
and also, the planet is anglo-centric too 16:48
elcaro You can use ASCII, for all your operators, but you either need to overload your operators, or make digraphs like J (where, eg. sort is `/:~`). 16:54
Raku also borrows an idea from Perl. In Perl, it is often said "they types are in the operators". That's why in Perl `1 + '2'` is not as insane as it seems, because `+` means numeric addition. In Python, `+` might be numeric addtion, or it might be string concat.
Having unique operators means you can do automatic coercion. You run out of unique operators with just ASCII. Everyone agrees operator overloading is perilous... but what's the solution? Raku provides a alternative to operator overloading (in the traditional sense)
yabobay i think that typing 3 characters on the keyboard is faster than googling the character and copying and pasting it
it's also more readable than a white rectangle, cause i don't have the fontset for some random unicode character 16:56
elcaro You don't need to copy/paste. You've got options. 17:00
There's various methods on how to imput Unicode characters, I think there's a page about it in the docs.
I use the vim digraphs feature, so I hit a key and then `-:` gives me `÷`, or `>>` gives me `»`. Most the symbols I like to use have easy to remember digraphs.
Or... don't use any of these symbols... just use the ASCII variants.
docs.raku.org/language/unicode_entry 17:02
yabobay ive got compose key
it's the thing you said but it's everywhere in x11
so how do i type the equivalent of (elem)
elcaro in Vim, the digraph is `(-` (which gives `∈`) 17:06
I've also customised/created some of my own digraphs to make them easier to remember, eg `(!` does `∉` 17:07
Kaiepi digraphs... i use the vim-raku mappings but they're kind of a PITA
yabobay {
this is what i got when i typed that
elcaro yeah, i've turned on that feature twice in my life... both times I turned it off within a few mins 17:08
Sorry, replied to the wrong message
Meant to reply to Kaiepi
yabobay yeah
elcaro Meant to reply to <@210313526928080896>
so yeah, the vim digraphs don't map exactly to compose-key combos
yabobay and i can't really find a list of compose keys 17:10
gfldex I ended up to define my own digraphs. A list of characters useful for Raku can be found at: github.com/gfldex/digraphs/blob/ma...igraphs.pl 17:25
yabobay and this just becomes one more thing for text editors to have to implement 17:27
making them more complicated to develop and more complicated to learn
if raku for example were to have mass adoption
gfldex Actually, that is not true in my case. I use screen and vim. vim never sees the digraphs. 17:28
yabobay what do you mean? 17:29
gfldex I use GNU Screen and start the digraphs from there. As such I can use them in any terminal application. I use them in bash, irrsi and vim. So I'm well covered for my typing needs. :)
yabobay yes, but what if someone is using a GUI editor like a normal person?
gfldex Then you can convert digraph tables to xinput config files. And yes, there is xinput for Windows. 17:31
yabobay what's xinput? 17:33
gfldex The window manager input layer in X11.
yabobay got it
what's that? 17:34
gfldex en.wikipedia.org/wiki/X_Window_System
yabobay what's this supposed to tell 17:35
*me
do you want me to read the whole thing?
gfldex The frist 2 lined should do.
The frist 2 lines should do. 17:36
yabobay i know what xorg is
elcaro If you want to input non-ASCII characters reliably, and it's not something you're familiar with... you will need to do some light learning. 17:37
For some people around the world, entering non-ASCII/non-Latin1 characters is an everyday occurence
yabobay yah, like myself
βλέπεις;
elcaro And I would assume that people who use a particular setup are "normal" and people who don't are "other". Pretty sure gfldex and myself are normal people. Well, fairly normal.
And I wouldn't assume that people who use a particular setup are "normal" and people who don't are "other". Pretty sure gfldex and myself are normal people. Well, fairly normal.
yabobay i'm just saying that vim is not most usecases 17:38
gfldex Given that I know Raku and Raku gives one super powers, I consider myself supernormal. :-> 17:39
I didn't like unicode chars in Perl 6 at the beginning either. Then I made them easy to type and now I would badly miss them. 17:40
m: say „Look mom, no "quote escape"!“; 17:41
yabobay why not just use single quotes 17:42
gfldex Finding a good terminal font was the tricky part, actually. But that way 10 years ago (or so).
yabobay instead of googling both of those characters
gfldex m: But what if you got both 'single quote' and "quote" in your HEREDOC? 17:43
yabobay just escape one of them? 17:44
gfldex m: say ‘But what if you got both 'single quote' and "quote" in your HEREDOC?’;
I _can_ do that, but I like it this way better. 17:45
You are free to quote as you like, ofc.
yabobay what is a heredoc anyway 17:50
gfldex m:``` 17:52
my $data = q:to/EOH/;
2022-08-01, 20
2022-08-09, 10
2022-08-03, 19
2022-08-06, 24
2022-08-05, 22
2022-08-10, 28
2022-08-07, 20
2022-08-04, 18
2022-08-08, 21
2022-08-02, 25
EOH
say $data;
````
m:```
my $data = q:to/EOH/;
2022-08-01, 20
2022-08-09, 10
2022-08-03, 19
2022-08-06, 24
2022-08-05, 22
2022-08-10, 28
2022-08-07, 20
2022-08-04, 18
2022-08-08, 21
2022-08-02, 25
EOH
17:52 discord-raku-bot left 17:53 discord-raku-bot joined
yabobay very cool feature 17:53
the power of raku at display here
super powers!!!
gfldex In contrast to other languages that support HEREDOCs, Raku does the right thing when you indent them. In other languages they have to be left-aligned. 17:55
yabobay that didnt even compile
gfldex m:```
my $data = q:to/EOH/;
2022-08-01, 20
2022-08-09, 10
2022-08-03, 19
2022-08-06, 24
2022-08-05, 22
2022-08-10, 28
2022-08-07, 20
2022-08-04, 18
2022-08-08, 21
2022-08-02, 25
EOH
say $data; #
```
Not our invention tho. Larry stole that with Perl 5 from some unix shell. 17:57
yabobay i thought i'd learn raku because it looked like fun
in retrospect that was very extremely stupid 17:59
programming skill isnt memorising all of the features in a language
its actually knowing how to write instructions that do what you want
whats the point of raku existing anyway
gfldex m:```
my $text = qq:to/WORD/;
Sometimes you got more text then { ‘edoc’.flip }, here HEREDOCs shine.
WORD
say $text;
```
lizmat yabobay: how many programming languages do you know? 18:00
gfldex Why invent C then? Macro assemblers worked just fine! 18:01
yabobay its fine if the number of features isn't literally infinite 18:02
lizmat then I suggest you learn C, there's not a lot of syntax there to learn, and the number of features is limited 18:03
yabobay lizmat: none really
lizmat learning the standard lib is another matter though :-)
gfldex The list of features of any programming language is infinite. Most of them just hide them in external libraries.
yabobay ive heard multiple say that nobodys gonna know everything about raku
the thing about C is that there isn't even any real support for strings
just syntactic sugar 18:04
lizmat yabobay: I've been able to tell people some feature of Perl that they didn't know about, while having worked with Perl daily for 25+ years
so I think just about any programming language has corners that you'd not know about for a loooong time 18:05
yabobay thats what im saying
thats not a good thing
is it?
lizmat just as natural languages for that matter
yabobay well we dont have control over natural languages 18:06
learning a natural language is famously a difficult and long process 18:07
elcaro You can use ASCII, for all your operators, but you either need to overload your operators, or make digraphs like J (where, eg. sort is `/:~`). 18:08
Raku also borrows an idea from Perl. In Perl, it is often said "the types are in the operators". That's why in Perl `1 + '2'` is not as insane as it seems, because `+` means numeric addition. In Python, `+` might be numeric addtion, or it might be string concat.
Having unique operators means you can do automatic coercion. You run out of unique operators with just ASCII. Everyone agrees operator overloading is perilous... but what's the solution? Raku provides a alternative to operator overloading (in the traditional sense)
yabobay anyway, im sorry for being a massive idiot with everything i've said today up to now 18:09
18:11 razetime left
gfldex I had the same feelings when I started to learn the language. Nowadays I love to compose a _nice_ Raku program, even if a simple one would have done the job too. 18:11
lizmat
.oO( ah you youngsters, in my time there was hardly any documentation :-)
18:13
18:14 discord-raku-bot left, discord-raku-bot joined
yabobay as a programming beginner , it feels bad not to be able to feel good about implementing some simple functionality because theres already a function for that 18:14
lizmat but but: you *should* feel good if your learned something from it 18:22
independent of whether the functionality existed already or not 18:23
yabobay but i dont need to do those things because they already exist 18:24
gfldex Don't worry, you will quickly hit the limits of the buildins and then you will have to compose with primitives. 18:26
yabobay i hope so 18:29
maybe i should try really using raku for something 18:30
i had a python script that i think would be quite good to re-make in raku
21:41 lizmat left, lizmat joined
Rog Doesn’t look like it 21:50
There’s gotta be something equally nice though surely…
21:53 RakuIRCLogger left
South the phasers seem much more powerful 21:57
less noise too
yabobay out of context, youre talking bout a space ship
South lol 21:59
23:51 kjp left, kjp joined