🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 6 September 2022.
xinming github.com/rakudo/rakudo/issues/4132 06:52
m: my %h; |%h{}:p.Seq
camelia ===SORRY!===
MVMArray: Can't pop from an empty array
xinming for this issue has no response over a long time, Does it mean it won't be fixed? or no need to fix anyway? :-) 06:53
lizmat weekly: dev.to/finanalyst/rakudoc-revision...mment-4hjb 07:44
notable6 lizmat, Noted! (weekly)
tellable6 hey lizmat, you have a message: gist.github.com/af3259b8eaaa60adc4...af2e39b699
Geth planet.raku.org: c1abf17b62 | (Elizabeth Mattijsen)++ | perlanetrc
Add feed ffor finanalyst, correct feed for bbkr
08:10
nemokosch dev.to is really not bad 09:45
I mostly mean it from Raku content creator perspective; it's not a bad place to have presence at 09:51
lizmat I agree :-) 09:52
patrickb o/ There is currently no way to receive a native callback from a library that spaws its own threads, right 10:57
?
"MoarVM panic: native callback ran in thread (12345) unknown to MoarVM" is the corresponding error... 10:58
lizmat perhaps ask on #moarvm? 11:01
patrickb will do!
lizmat clickbaits rakudoweekly.blog/2023/07/31/2023-...explained/ 13:55
wafflus how can test be an Int?;  $test = 5.WHAT; $test.^name; p.s i know this is contrived' i'm just trying to understand things; 16:11
like for instance if you do the same thing in powershell it is a not a number at all but a typeinfo object which makes more sense to me 16:13
tonyo m: say 5 ~~ Int; # wafflus 16:15
camelia True
wafflus m: say 4 16:17
camelia 4
wafflus looks a bit weird to have something be an int and not be at the same time 16:18
m: my $test = 5.WHAT; given $test {when Int {say "{5+ $test}"}} 16:27
camelia Use of uninitialized value of type Int in numeric context
in block at <tmp> line 1
in block <unit> at <tmp> line 1
tonyo m: m: my $test = 5; given $test {when Int {say "{5+ $test}"}} 16:29
camelia 10
tonyo not sure what you mean by be an int and not at the same time
in your test, `$test` == Int, not 5 16:30
wafflus its says it is an int but what is it's value? how can it be an int?
what is the logic behind allowing it and could it be a potential source of bugs and misunderstandings in less ridiculous examples ? or will it never matter? 16:32
tonyo it's an undefined type when you use `.WHAT` 16:33
m: my $type = 5.WHAT; say $type.new(6) + 10
camelia 16
wafflus it undefiend but it still says it's an int? 16:34
tonyo yes 16:35
if you are more familiar with another language i may be able to make an analogy
wafflus i use powershell quite alot and i also use js. the logic behind it does not make sense to me 16:37
like i said in powersehll it is a typeinfo object it's not a number or undefined
or both
i haven't used js in a while all i remeber is the typeof object which just returns a string 16:38
operator i mean
tonyo yea, so calling .WHAT is like using the `typeof` in js 16:39
but the semantics for testing if a type is something in raku doesn't track with js.. so doing `say 5 ~~ Int` is equivalent to js: `console.log(typeof(5) === 'number' ? 'True' : 'False')` 16:40
in js, you'd also have to test that the number floored or ceiled is the same to also check for an int but that better shows the syntax difference 16:41
wafflus it not the same though is it your checking against string values and also your not assigning them to a variable
tonyo in raku: `my $a = 5; say $a ~~ Int; # True` in js: `const a = 5; console.log(typeof(a) === 'number' && Math.floor(a) == a ? 'True' : 'False'); // True` 16:43
if you wanted the exact same syntax in raku you could use: `my $a = 5; say $a.^name eq Int.^name; # True` 16:44
wafflus thanks not sure I understand what your getting at (plus you changed the question) 16:54
nemokosch so the primary motive is to allow for typed undefined values 17:09
Raku takes a big leap and says "okay, the undefined value of type T will be the type object of T itself"
I'm inclined to agree that it is strange but it's not very complicated 17:10
wafflus it certainly is strange :) 17:12
nemokosch this also means that if you create a variable my Int $apples, the default value of $apples will be Int, that is, the type object 17:13
not zero or any concrete value
[Coke] m: my Int $a; dd $a; my Int $b = 3; dd $b 17:14
camelia Int $a = Int
Int $b = 3
[Coke] (dd is data dumper, a rakudo-specific debugging tool)
that way you don't get the extra confusion of 'say $x', where say is transparently calling a method on the thing to get a printable string. 17:15
tonyo ++
[Coke] s/confusion/layer/
nemokosch the problem is rather the syntactic burden that now Int both needs to play a type constraint and a value, and these are not always interchangable 17:18
type smileys kind of help, Int:D clearly means "a concrete Int value expected here" 17:19
while Int:U actually means "a type object kind of Int expected here", so in normal cases the Int type object itself (could be a derived type in theory) 17:20
wafflus is this something I need to check for? or is it something that won't ever come up unless deliberately trying to do so? 17:23
[Coke] with gradual typing, you can add those restrictions in when you find they are important, and ignore them until then. 17:24
basically you can write very strict signatures and type everything, or not. 17:25
nemokosch I don't think you will be passing type objects around a lot, except for the "default value" use case
if you want to forbid default values, you can add this Type:D kind of annotation
default as in undefined 17:26
the important thing to know is that by default, your variables will start off having these "non-values" 17:28
sometimes they coerce to something meaningful but most of the time they will emit a warning at the very least 17:28
Ven_de_Thiel o/
nemokosch m: my Int $foo; say 5 ~~ $foo; 17:35
Raku eval True
wafflus is there a way to check something is an actual number and not some int type object thing? 17:37
so that it does not try to do mathematical operations on it and failing 17:38
tonyo you're asking if you can check if it is defined? 17:39
you can use `.defined` so: `5.defined # True` and `Int.defined # False`
[Coke] but if you're writing a sub that needs args that are defined, you can do that in the signature. 17:40
nemokosch This is a fractal of a topic 17:41
[Coke] m: sub zz (Int:D $x) { say $x+3}; zz(4)
camelia 7
[Coke] m: sub zz (Int:D $x) { say $x+3}; zz(Int)
camelia Parameter '$x' of routine 'zz' must be an object instance of type
'Int', not a type object of type 'Int'. Did you forget a '.new'?
in sub zz at <tmp> line 1
in block <unit> at <tmp> line 1
[Coke] rather than doing an explicit check in code, use the syntax where possible.
nemokosch One day you realize that there is method DEFINITE and method defined
[Coke] but also: 17:42
nemokosch The 😄 smileys rely on DEFINITE
[Coke] Note: you're getting a firehose of information here. beginners don't need to know about some of this. :)
nemokosch Damn... :D
It's enough to get bitten once, and you two immediately said two things that do not quite work the same 17:44
wafflus thanks I may not understand some of it or agree but am always grateful 17:45
btw who is in control of the bot or is it somekind of AI?
grateful sounds like a word used for someone who likes grating cheese 17:46
nemokosch Let's say, the moderators are 17:47
[Coke] It's not AI. there's a repo that has the code driving it. 17:48
nemokosch Or you mean the bridge? 😄 17:50
[Coke] ah. discord-raku-bot is one thing, camelia is another. there are *many* bots here 17:55
librasteve ie. one day you may want to use the raku Meta Object Protocol (MOP) where DEFINITE is a thing for core devs and maybe yes this is used under the hood to implement smileys ... BUT the general level raku coder will only need to use .definite - the clue is that it's ALL CAPS 22:21
nemokosch The problem is that things that look roughly equally important, use different things. Type:D is as much idiomatic as using with or //. It's hard to say that you don't care about one or the other 22:24