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:44 Manifest0 left
el gatito (** advocate) m: my \singleton = (my class {}).new dd singleton 01:12
Raku eval Exit code: 1 ===SORRY!=== Error while compiling /home/glot/main.raku Two terms in a row across lines (missing semicolon or comma?) at /home/glot/main.raku:3 ------> my \singleton = (my class {}).new⏏<EOL> expecting any of: infix infix stopper postfix statement end statement modifier statement modifier loop
el gatito (** advocate) m: my \singleton = (my class {}).new; dd singleton;
Raku eval <anon|1>.new
el gatito (** advocate) m: sub count { say 'one'; start { sleep 1 } say 'two'; } start { count; count; count } 01:34
Raku eval one two one two one two
el gatito (** advocate) what
how do i run three async functions simultaneously like asyncio.gather 01:44
m: sub count { say "one"; Promise.in(1).then { say "two" } } my $task1 = count; my $task2 = count; $task1.result; $task2.result; 01:54
Raku eval Exit code: 1 ===SORRY!=== Error while compiling /home/glot/main.raku Unexpected block in infix position (missing statement control word before the expression?) at /home/glot/main.raku:3 ------> Promise.in(1).then⏏ { say "two" } expecting any of: infix infix stopper
el gatito (** advocate) m: sub count { say "one"; Promise.in(1).then({ say "two" }) } my $task1 = count; my $task2 = count; $task1.result; $task2.result;
Raku eval one one two two
el gatito (** advocate) m: sub count { say "one"; Promise.in(1).then({ say "two" }) } say time; my $task1 = count; my $task2 = count; $task1.result; $task2.result; say time; 01:55
Raku eval 1675994154 one one two two 1675994155
el gatito (** advocate) i thought it would take 2 seconds 01:59
elcaro You kicked off both promises before blocking. If you did my $task1 = count; $task1.result; my $task2 = count; $task2.result; then it would take 2 seconds. 04:36
el gatito (** advocate) m: sub count { say "one"; Promise.in(1).then({ say "two" }) } say time; my $task1 = count; my $task2 = count; say time; 04:47
Raku eval 1676004445 one one 1676004445
05:24 Heptite left
el gatito (** advocate) #|async sub count { start { say 'one'; sleep 1; say 'two'; }} count; count; count 08:40
m:perl #|async sub count { start { say 'one'; sleep 1; say 'two'; }} count; count; count 08:41
Raku eval one
el gatito (** advocate) what
m:perl #|async sub count { start { say 'one'; sleep 1; say 'two'; } } start count; start count; 08:43
Raku eval
el gatito (** advocate) what
m:perl #|async sub count { say 'one'; sleep 1; say 'two'; } start count; start count;
Raku eval
el gatito (** advocate) m:perl #|async sub count { start { say 'one'; sleep 1; say 'two'; } } count.result; count.result; 08:44
Raku eval one two one two
el gatito (** advocate) tfw
m:perl #|async sub count { start { say 'one'; sleep 1; say 'two'; } } .result for (count, count);
Raku eval one one two two 08:45
el gatito (** advocate) a singlehandedly turned this into #bot-testing lmao 08:46
09:01 Manifest0 joined 09:03 Heptite joined
Nemokosch there is no GIL here, mind you 09:25
09:28 Simerax joined
Simerax is there a way to find out where a grammar failed? I have not found anything on the raku website. If i define some grammar i want something like "unexpected XYZ at position 123". Something that a user of the program could use to understand where his/her input is wrong 09:30
Nemokosch Alas, I don't think so. Unless there is some module to compensate for that, it's a voluntaristic parser that will just fail should things go wrong somehow 09:33
Simerax ah okay
Nemokosch Actually I know this because of reviews 😅 apparently multiple people have missed that already 09:34
09:55 ab5tract joined 10:18 ab5tract left 10:37 Simerax left
el gatito (** advocate) means that raku can go well with os threads 10:52
Nemokosch yes, I think os threads were well utilized in 6.c as well 10:53
lizmat indeed they were, but each job was stuck on an OS thread then
so if you have max 64 OS threads, after accepting 64 connections in Cro, it couldn't accept any extra anymore 10:54
as there weren't enough OS threads for it
Nemokosch not sure if this is a good flex but it's really ridiculously easy in Raku to push the CPU to the max
but sometimes it makes a difference that you can finish in quarter of the time or sth 10:55
lizmat oh yeah, the equivalent of a fork bomb is very easily written :-)
there's even a module for it: raku.land/zef:jmaslak/App::Heater
Nemokosch 🤣 10:56
11:11 ab5tract joined
Skarsnik There is a module to help 'debug' grammar, but if you want to handle 'user' error you need to do it yourself. 11:33
You can do something like that 11:37
raku token TOP { :my Int $*line-number = 1; (<.eol>* <thing>+ <.ws> <eol>* $) || <.error> } ... token eol { $<lines> = \n[\h*\n]* { $*line-number += $<lines>.lines.elems; } } method error { say "Error parsing the ASM: Error at line: ", $*line-number; exit 1; } } 11:38
p6steve why not go something like... 12:06
grammar G { token TOP { <good> || <bad> } token good { ... } #your match here token bad { .* } #everything else } class G-actions { method bad { warn 'unexpected XYZ at position 123' } } 12:10
^^^ this is NOT anything like working code btw
of course you can make a tree of good/bad filters with different warnings
btw Grammar::Tracer is your friend ;-) (which you probably already know) 12:11
12:46 ab5tract left
el gatito (** advocate) when parsing a grammar does raku follow the longest match rule? 13:30
Skarsnik no 13:43
if you have like token plop { "blablaplop" } and token plop2 { "blabla"} you need to order then correctly on the parent token 13:44
lizmat token plopboth { blabla | blablaplop } # does follow longest match rule 13:51
Skarsnik Ho I think my issue was with proto token 13:57
so I thought that applied to normal tokens 13:58
14:25 jgaz joined 14:27 ab5tract joined 14:51 ab5tract left 15:05 ab5tract joined 15:15 ab5tract left 16:01 ab5tract joined 16:58 Guest7016 joined 17:23 Guest7016 left
el gatito (** advocate) how to perform an instanceof check in raku 17:38
Nemokosch smartmatch? 😄 17:39
lizmat as a test: isa-ok 17:40
just in code: if you accept any subclass as well: then ~~ 17:41
m: say 42 ~~ Int
camelia True
lizmat m: say "42" ~~ Int
camelia False
lizmat m: class A is Int { }; say A.new ~~ Int
camelia True
lizmat dinner&
el gatito (** advocate) ok how did i forget that 17:42
smartmatch is goat
Nemokosch dinner is good too 17:46
18:29 Guest3763 joined 19:10 Guest3763 left 20:12 Guest8086 joined 20:42 Guest8086 left 21:10 Monalika9 joined
Monalika9 Hey!! is this organization participating in outreachy right? 21:11
Nemokosch hello what is outreachy 21:12
Monalika9 Outreachy provides internship in open source and open science to individuals facing systemic bias 21:27
21:29 Monalika9 left 23:10 jgaz left