🦋 Welcome to Raku! raku.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: colabti.org/irclogger/irclogger_log/raku
Set by ChanServ on 14 October 2019.
notagoodidea timotimo: You loose the timezone information going from Instant to Datetime. 00:31
m: say DateTime.now; say DateTime.now.Instant.DateTime;
camelia 2021-01-17T01:31:23.899945+01:00
notagoodidea Getting the stat info for .IO.changed & co go through loops but come through an Instant. 00:34
00:37 linkable6 left, evalable6 left 00:39 evalable6 joined 00:40 linkable6 joined
notagoodidea And when DateTime.new get an Instant, the timezone is expected to be provided by :$timezone set to 0 by default and do not take $*TZ into account. 00:40
m: say DateTime.new(DateTime.now.Instant); say "---"; say DateTime.new(DateTime.now.Instant, timezone => $*TZ) 00:41
camelia 2021-01-17T00:41:06.349359Z
00:46 pecastro left 01:04 Kaiepi joined, Kaeipi left 01:18 lucasb left 01:24 notagoodidea left 01:30 lancew left 01:34 JRaspass joined 01:35 Black_Ribbon left, Black_Ribbon joined, mowcat left 01:47 tyilanmenyn is now known as tyil 01:48 moon-child left 01:50 moon-child joined 02:04 earnestly left 02:28 Garbanzo joined 02:35 kvw_5_ joined 02:39 kvw_5 left 02:43 mowcat joined 02:50 Sgeo left 02:53 Sgeo joined 02:54 moon-child left 03:02 Manifest0 left 03:04 Manifest0 joined 03:17 brtastic left 03:27 sono__ joined 03:28 Kaeipi joined 03:30 HarmtH joined, JRaspass left, Manifest0 left, tomaw joined, Black_Ribbon left, Kaiepi left 03:31 Manifest0 joined 03:32 ribasushi joined 03:41 moon-child joined 04:12 kini left 04:14 kini joined 04:23 __jrjsmrtn__ joined 04:26 _jrjsmrtn left 04:27 oneeggeach joined, oneeggeach left 04:29 pnu__ left, pnu__ joined 04:48 mowcat left 04:51 JRaspass joined 05:14 kini left 05:15 kini joined 05:21 JRaspass left 05:54 Sgeo left 05:58 Sgeo joined 06:32 rindolf joined 06:48 kini left 06:49 kini joined 07:07 brtastic joined 07:39 ensamvarg3 joined 07:42 parabolize left 07:45 dataangel left 08:02 brtastic1 joined 08:03 tomaw left, nine left, tomaw joined, nine joined, brtastic left, brtastic1 is now known as brtastic 08:04 rindolf left 08:05 rindolf joined 08:21 wamba joined 08:50 kini left 08:51 kini joined 09:01 sxmx left 09:17 kentnl left 09:19 kent\n joined 09:25 sono__ left 09:27 kent\n left, kentnl joined 09:30 kentnl is now known as kent\n 09:33 sjm_uk joined 09:42 earnestly joined 09:44 sena_kun joined 09:48 Garbanzo left 10:46 Sgeo left 10:54 Xliff joined 11:30 Altai-man joined 11:33 sena_kun left 11:43 murilorios joined 11:52 sjm_uk left 12:17 stoned75 joined 12:25 pecastro joined 12:27 mightypork_ joined
mightypork_ Hello! I'm doing the Raku course (course.raku.org) and finding many typos and mistakes. How can I best report / help fix these? 12:29
lizmat issues / PR's at github.com/ash/raku-course
and thank you for your interest! 12:30
mightypork_ Okay, I'll try to make a PR. Thanks 12:31
lizmat ++mightypork_ 12:33
12:43 PimDaniel joined
PimDaniel @lizmat: hi, i could resolve my problem, silly me i was stucked to the routine side but one of my callers had a constant litteral int into it. 12:45
lizmat so that was essentially binding :-)
my constant $foo = 42 is syntactic sugar for my $foo = BEGIN 42 12:46
my constant $foo = 42 is syntactic sugar for my $foo := BEGIN 42
PimDaniel May constant not CONTAIN a '$'? Je confonds peut-être avec Golang. :( 12:47
NO: constant LIBPATH = '/path/to/start'; is correct too! 12:49
lizmat It may contain a sigil, which makes it easier to interpolate constants in strings 12:54
m: my constant $foo = 42; say "the answer is $foo"
camelia the answer is 42
lizmat m: my constant foo = 42; say "the answer is {foo}"
camelia the answer is 42
PimDaniel i tried : it works! 12:56
I prefert the non $ version : this presents more the difference between variables and constants. 12:57
New question: 12:58
lizmat sure, TIMTOWTDI :-)
PimDaniel Is there a way to make a sub prototype which 1/ accept one or more parameters? 2/Each parameters is a tuple or a triplet? 13:00
lizmat m: sub foo($a, $b = 666) { dd $a, $b }; foo 42; foo 42, 378 13:02
camelia 42
lizmat by specifying a default, you make the positional parameter optional
an alternate way is to use named parameters, which are by default optional
m: sub foo($a, :$bar = 666) { dd $a, $bar }; foo 42; foo 42, bar => 378 13:03
camelia 42
PimDaniel i need to make my sub assert be able to handle this : assert ($a, '>', $b), ($c, '<=', $d), ...
lizmat ah, like that...hmmm
PimDaniel None of my questions are easy. 13:04
Probably an hash would not be weird? 13:05
Heu non!
lizmat m: sub assert(**@tests) { dd @tests }; assert <a b c> 13:06
camelia Array element = [("a", "b", "c"),]
lizmat m: sub assert(**@tests) { dd @tests }; assert <a b c>, <d e f>
camelia Array element = [("a", "b", "c"), ("d", "e", "f")]
lizmat m: sub assert(**@tests where all(@tests>>.elems) == 3) { dd @tests }; assert <a b c>, <b c d> 13:07
camelia Array element = [("a", "b", "c"), ("b", "c", "d")]
PimDaniel i'll do the job since i cat do 2 subs this one calling the other.
lizmat m: sub assert(**@tests where all(@tests>>.elems) == 3) { dd @tests }; assert <a b c>, <b c d e>
camelia Constraint type check failed in binding to parameter '@tests'; expected anonymous constraint to be met but got Array ([("a", "b", "c"), ("...)
in sub assert at <tmp> line 1
in block <unit> at <tmp> line 1
cog m: my Int @a; sub a( --> Positional[Int] ){ @a }
camelia ( no output )
PimDaniel Nice: this adds control 13:08
cog Is there a shorter way to say I return an array of Int ? This syntax gets tedious fast/
PimDaniel Well i need to try a few... 13:09
cog m: my Int @a; sub a( --> @Int ){ @a }
camelia 5===SORRY!5=== Error while compiling <tmp>
Malformed return value
at <tmp>:1
------> 3my Int @a; sub a( -->7⏏5 @Int ){ @a }
lizmat cog: how would you do a signature that accepts only an array of Int ? 13:11
but I don't think you can do this atm, but would gladly be proven wrong :-)
cog @Int ? Looks like a variable though
notandinus cog: look into subset 13:12
cog m: my Int @a; sub a( --> Int[] ){ @a } 13:15
camelia ( no output )
cog yea
lizmat m: my Int @a; sub a( --> Int[] ){ @a }; a 13:16
camelia Type check failed for return value; expected Int but got Array[Int] (Array[Int].new())
in sub a at <tmp> line 1
in block <unit> at <tmp> line 1
cog m: my Int @a; sub a( --> Int[] ){ @a }; @a = a()
camelia Type check failed for return value; expected Int but got Array[Int] (Array[Int].new())
in sub a at <tmp> line 1
in block <unit> at <tmp> line 1
lizmat it compiles, but does not doe what you want
cog Indeed
It is parametrising the Int type
I like signatures. It is part of what makes raku so better than Perl. A shorter syntax would be nice. 13:18
13:19 sjm_uk joined
cog notandinus, I looked into subset. I am not sure how it can be relevant. 13:20
notandinus m: subset Test of Array[Int]; my Int @a; sub (--> Test) { @a }; a
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared routine:
a used at line 1
notandinus m: subset Test of Array[Int]; my Int @a; sub a (--> Test) { @a }; a 13:21
camelia ( no output )
notandinus cog: ^
cog notandinus, thx
But the notion it is a Positional is lost, which was the very reason I used a signature 13:22
But for compiling check, it is good. 13:23
notandinus what does it being positional mean? 13:24
i'm not sure but you can probably do Positional[Int]
m: subset Test of Positional[Int]; my Int @a; sub a (--> Test) { @a }; a
camelia ( no output )
cog Yes, but nothing in the Test name indicates to the users it is a positional 13:25
A positional is a role of arrays btw. I would say THE role.
And the sigil conveys that. 13:26
But sigils seem to be for variable only, not types 13:27
That would confuse things, I suppose. 13:29
my @int \i # going on another tangent. 13:30
m: my Int @a; sub a( --> @[Int] ){ @a }; @a = a() 13:34
camelia 5===SORRY!5=== Error while compiling <tmp>
Malformed return value
at <tmp>:1
------> 3my Int @a; sub a( -->7⏏5 @[Int] ){ @a }; @a = a()
cog my @[Int] @a; sub a( --> @[@[Int]] ){ @a }; @a = a() # a Positional of Positionals of Ints 13:38
13:41 murilorios left 13:52 sena_kun joined
PimDaniel I realize that i can't even push a Str into an Str List using for. for <aaa bbb ccc> -> $one { push @a, $one} does not seam to work. 14:13
heu Sorry : yes it works : or @a.push($one) 14:18
14:24 Altai-man left
masak PimDaniel: also, you can usually `push @a, @an-entire-array` instead of looping and pushing per item 14:25
PimDaniel masak: Thank's, Yes, true but i receive a scalar from a sub multi-calls. 14:27
masak I see :) 14:28
PimDaniel How to chech if $x is not Nil? my $x = mysub(...); if not $x is Nil {...} does not seam to work :(. 14:37
14:37 wamba left 14:44 lucasb joined
masak m: my $x = Nil; say $x === Nil 14:45
camelia False
masak m: my $x = Nil; say $x 14:46
camelia (Any)
PimDaniel masak: i need to check if it is Nil (or not). 14:48
14:49 wamba joined
PimDaniel my Str $str; $str = 'fdsfdsf'; say $str === Nil => returns always False. :( 14:49
masak yes, I understand. however, the above two evaluations seem to indicate that Nil evaporates when stored in variables
maybe Nil isn't quite a first-class value 14:50
timotimo storing Nil into a variable resets the variable to its default value
you can use binding instead to keep the Nil around
PimDaniel timotimo : True !
masak m: for [1, Nil, 2] -> $x { say $x }
camelia 1
timotimo m: my $a is default(99); say $a; $a = 9; say $a; $a = Nil; say $a 14:51
camelia 99
14:53 aindilis` joined
PimDaniel I have a sub that returns a message, but does not even touches to its internal $msg when there's no error. Probalbly should i initialize the $str string empty? 14:53
14:57 aindilis left
PimDaniel Now how to check if a Str is empty? 15:05
15:06 murilorios joined, murilorios left
timotimo if you "has Str $.msg", the default value would be Str, i.e. the Str type object. you can check if it's === Str, or you could check that it's not ".defined" 15:11
if you're fine with empty strings also being considered "empty", then you can just boolify the string, because in raku only the empty string is false, and type objects as well 15:12
15:13 parabolize joined
PimDaniel What do you exactly mean by boolify? I just need since 2 hours to check if my string is empty. 15:15
On thing that should be simple i guess!
timotimo `if not $.msg { say "oh no its empty!" }` 15:16
PimDaniel Doesn't work! 15:20
timotimo more details please 15:23
PimDaniel Heu : Sorry ! fogot a ;
works! 15:24
tbrowder hi 15:28
back in november i asked about "include"ing a file during compulation (simlar to C/++ "include") and [Coke] suggested: colabti.org/irclogger/irclogger_lo...11-25#l149 15:29
I'm facing the problem again and wonder if a module might do the trick more safely as [Coke] suggested. 15:30
15:32 sena_kun left
tbrowder here is the situation: i have a class in module X::Y.rakumod and I autogenerate part of the methods. Currently I generate them in the proper format and copy/paste them into Y.rakumod. 15:32
I would like use a module but how can I do that so they appear to be called by the class in Y.rakumod? 15:33
*use a separate module which i can autogenerate and "use". 15:34
e.g.: use X::Y; my $c = Foo.new; $c.some-method; # where .some-method is in another physical method? 15:37
15:37 Manifest0 left
tbrowder i know i can use a wrapper for each module inside Y.rakumod, but that seems clunky and is just asking for more trouble. 15:38
*each method
*is in another module file. 15:39
back later, bye.
15:39 sjm_uk left 15:46 sena_kun joined 15:50 Garbanzo joined
PimDaniel Can't join separator from a list :(! 15:50
From an arraystr to a scalar. 15:51
Said variable returns each element by lines. :( 15:52
Where could i found example of that? 15:53
15:54 Manifest0 joined 16:04 b2gills left, japhb left 16:05 stoned75 left, b2gills joined, stoned75 joined 16:06 Garbanzo_ joined 16:07 wamba left 16:08 Garbanzo left, stoned75 left 16:09 japhb joined, stoned75 joined 16:10 wamba joined, wamba left 16:14 sena_kun left
tbrowder ah, roles or inheritance might work, just a bit more effort. however, an 16:16
"include" feature would be very useful. 16:18
timotimo roles are for code sharing, inheritance is for when one type is an acceptable substitute for another in certain circumstances (liskov substitution principle)
16:20 sena_kun joined 16:21 Garbanzo joined 16:23 Garbanzo_ left 16:30 sjm_uk joined 16:36 Garbanzo left 16:43 mhinz left 17:05 MasterDuke joined 17:36 aindilis` left 18:05 sjm_uk left 18:06 aindilis joined
PimDaniel I'm back! 18:10
perry Hi back, I'm perry! 18:11
18:11 ensamvarg3 left
PimDaniel 18:11
Suppose a sub myspersub(Int $a , Str $b, Int $c) { say $a.VAR.name; }; Suppose a list of triplet : my @list = (($inta,$str1,$intb),($intc,$str2,$intd); for @list -> $ref {my ($a,$b,$c) = @($ref); mysupersub($a,$b,$c); The problem is i need the original name not the loop ones which will allways be $a 18:23
18:24 stoned75 left
PimDaniel To say it in another style : how to call mysupersub with a kind of reference to the originals variables? 18:25
In other words : i need $inta, not $a. 18:28
18:32 natrys joined 18:37 aborazmeh joined, aborazmeh left, aborazmeh joined 18:38 Garbanzo joined 19:12 PimDaniel left 19:13 Garbanzo left, Garbanzo joined 19:15 Garbanzo_ joined 19:16 Garbanzo left, wamba joined 19:21 Garbanzo_ left, Garbanzo_ joined 19:26 Garbanzo_ left 19:30 Garbanzo joined, Altai-man joined 19:32 sena_kun left 19:34 Garbanzo_ joined 19:36 Garbanzo left 19:57 Sgeo joined 19:59 Garbanzo_ left
mightypork_ Is there some raku "etymologic dinctionary" where I could find why e.g. '.so 20:00
.so is called .so as in "say $value.so; # True"?
or why .WHAT isn't .type 20:01
El_Che so true and so false? 20:03
mightypork_ yeah. The only thing I can come up with is it being an obscure reference to Picard's "Make it so" 20:04
El_Che so is also a routine 20:05
so $foo => true
mightypork_ I'm doing the Course and it was introduced here as a kind of operator course.raku.org/essentials/coercion/prefixes/ 20:06
20:10 thundergnat joined, mightypork_ is now known as MightyPork 20:11 JRaspass joined
thundergnat MightyPork: We have a glossary of terms somewhere. 20:11
github.com/Raku/old-design-docs/bl...ossary.pod May not be the most recent link.
and .so isn't in there anyway 20:12
MightyPork this is a better link probably but yeah it ain't there - docs.raku.org/language/glossary
thundergnat It's a play on the question: "Is that not so? It is not. or It is so. 20:13
20:13 stoned75 joined
thundergnat It's the opposite of not 20:13
El_Che design.raku.org/S03.html#Loose_unary_precedence 20:14
MightyPork Oh, that makes sense. If the course introduced .not, I would have probably connected the dots
thundergnat Coerces the result of an expression to a Boolean
MightyPork 'so' and 'not' are the same as the prefix operators ? and !?, right? 20:16
thundergnat They perform the same function but are (I believe) looser precedence. 20:17
MightyPork dont actually need the question mark in the second case
thundergnat Similar to && and and, and || and or. 20:18
Geth doc/master: 8 commits pushed by (Stoned Elipot)++ 20:19
20:22 b2gills left 20:23 b2gills joined, sxmx joined 20:31 thundergnat left 20:38 aborazmeh left 20:39 aborazmeh joined, aborazmeh left, aborazmeh joined 20:44 aborazmeh left 20:58 notagoodidea joined
notagoodidea m: use nqp; say nqp::time_n(); 21:00
camelia 1610917205.0564768
notagoodidea m: use nqp; say DateTime.new(nqp::time_n(), timezone => $*TZ); 21:06
camelia 2021-01-17T22:06:33.298770+01:00
21:15 notagoodidea left
gfldex lolibloggedalittle: gfldex.wordpress.com/2021/01/17/in...-labeling/ 21:15
notandinus: ^^^ this one is for you
lizmat feels a PR coming :-) 21:18
perry Introspective labelling? Who told you the name of my secret band? 21:19
21:20 brtastic left
perry (Er, actually on topic): wow, I didn't actually know Raku had such a fancy Label-thingy. That's really neat. 21:21
El_Che perry: wasn't "distesctive libel"? 21:22
disrespective 21:23
perry No, but they opened for us.
(Whom they were opening for considering the band was secret, I can't say)
Er, whom they were opening to* 21:29
21:39 natrys left 21:42 MasterDuke left 22:02 Garbanzo joined 22:06 vrurg left, telex left, vrurg_ joined 22:07 Altai-man left, telex joined
[Coke] m: FOO: say 'hi' ; goto FOO 22:14
camelia hi
Label.goto() not yet implemented. Sorry.
in block <unit> at <tmp> line 1
22:16 rindolf left, xelxebar left, tejr left, asymptotically left
MightyPork say "{$x.WHAT}"; # says 'Use of uninitialized value of type Int in string context.'. 22:20
why cant I do this? Also, what is uninitialized? 22:21
$x is a Int
El_Che $x is uninitialized? 22:22
22:22 xelxebar joined
tadzik m: my $x = 5; say $x.WHAT.defined 22:22
camelia False
22:22 asymptotically joined
MightyPork it's not, my Int $a = 156; 22:22
tadzik ^ maybe that's what it's complaining about 22:23
MightyPork and it works fine without doing the string interpolation
tadzik though it's arguable whether or not a type object is initialized or not ;)
m: my $x = 5; say "{$x.WHAT.^name}"
camelia Int
El_Che m: $x=156; say "{$x.WHAT}";
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable '$x' is not declared
at <tmp>:1
------> 3<BOL>7⏏5$x=156; say "{$x.WHAT}";
El_Che m: my $x=156; say "{$x.WHAT}"; 22:24
camelia Use of uninitialized value of type Int in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.

in block <unit> at <tmp> line 1
tadzik ah yes, it's all in the error message :)
El_Che m: my $x=156; say $x.WHAT;
camelia (Int)
22:24 aborazmeh joined, aborazmeh left, aborazmeh joined
El_Che indeed: great error 22:24
MightyPork I don't understand
22:25 tejr joined
El_Che it's complaining you are casting something undefined to string 22:25
tadzik m: say "{Int}"
camelia Use of uninitialized value of type Int in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.

in block <unit> at <tmp> line 1
tadzik ^ that's what you're effectively doing
El_Che in other languages you would get a panic
MightyPork but why is it not undefined if you just `say $x.WHAT`. you get (Int)
El_Che that's the type not the value 22:26
you cast values, not types
tadzik it is a good question why wrapping it in quotes "silences" the error, seemingly
erm, unwrapping &
vrurg_ m: say Int.gist; 22:27
camelia (Int)
tadzik I'd say the non-quoted form kind of works by accident
vrurg_ m: say Int.Str
camelia Use of uninitialized value of type Int in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.

in block <unit> at <tmp> line 1
tadzik ah, there we go
vrurg_ This is what happens.
MightyPork if I do say $x.WHAT.WHAT, it's still (Int). Does .WHAT return some kind of "typed undefined"?
tadzik where's FROGGS when we need to make a "what what" joke again :(
vrurg_ docs.raku.org/routine/say#(IO::Han...method_say – this is where it's explained what `say` actually does. 22:28
22:29 vrurg_ is now known as vrurg
MightyPork ah its like the debug print in rust, {:?}. say "{$x.WHAT.gist}" works perfectly 22:29
vrurg tadzik: It's certainly not by accident. It's on purpose. :)
tadzik so when you say() something, it does its best to turn it into a meaningful string: so it calls a .gist on it, and you don't see an error. If you interpolate it in a string, it tries to treat it as a Str, which triggers the error, even though the end result is pretty much the same
vrurg: right, I see it now :) 22:30
MightyPork so .WHAT gives me the "class" of the object? until now I obviously mistakenly thought it's a string 22:31
tadzik yes, it gives you the type object
MightyPork but that doesnt explain why chained WHAT is still the same
tadzik ^name on that gives you a name, as a string (I think) 22:32
m: 5.WHAT.^name.WHAT.say
camelia (Str)
tadzik yep
m: 5.WHAT.WHAT.WHAT.WHAT.^name.say
camelia Int
vrurg MightyPork: because Int is an Int, event it's not instantiated yet/undefined. 22:33
22:33 Sgeo left
MightyPork can I think of it as javascript prototype? 22:33
El_Che www.youtube.com/watch?v=_3PUu88nOcw
vrurg MightyPork: no way. Not even close. Don't. Forget. Wipe your brain! :D
MightyPork ok ok going back to the Course lol 22:34
vrurg Cerberus remains calm as he knows no Closure. 22:35
22:38 Sgeo joined 23:01 aborazmeh left 23:10 wamba left 23:19 asy joined 23:21 asymptotically left, b2gills left, tomaw_ joined, tomaw left, JRaspass left 23:22 b2gills joined 23:33 Sgeo left 23:35 Sgeo joined