[00:36] <:(*@args, *%kwargs)> what are .^ methods? [00:36] metamethods - they act upon the objects of the metamodel [00:37] mostly used for introspection [00:53] <:(*@args, *%kwargs)> m: class Foo {} say Foo.new.^name; [00:54] m: class Foo {} say Foo.new.HOW.name; [00:54] mhm [00:54] m: class Foo {} say .name($_) given Foo.new.HOW; [00:54] this is what .^ is a shorthand for, from what I know [00:55] calling a method on .HOW, while also passing it as the first argument [01:57] <:(*@args, *%kwargs)> m: class Foo {} say Any.HOW.name(Foo.new); [01:57] <:(*@args, *%kwargs)> what [02:56] *** MasterDuke joined [03:12] *** rf left [03:33] <:(*@args, *%kwargs)> is it me or weak typing is a bad thing [05:45] *** Heptite left [06:47] <:(*@args, *%kwargs)> is raku made to accomodate someone who has enough time to type code in character map lol why does it support so many unicode symbols [06:53] <:(*@args, *%kwargs)> what does nqp do [06:54] you don't need to enter characters by their code: https://docs.raku.org/language/unicode_entry [07:37] I mean, well done, the name of Any is indeed Any 😄 [07:38] NQP is the bootstrapping language of Raku (not sure if it's specced as such but that's how it is in Rakudo) [07:39] <:(*@args, *%kwargs)> so it gets the name of the invocant instead of the first arg? [07:40] Don't forget that the first argument you passed is not even a metaobject [07:43] m: Any.HOW.say [07:46] https://github.com/rakudo/rakudo/blob/704a05b934ba10f3240e8764827bbfd7fe089cdf/src/Perl6/Metamodel/Naming.nqp#L5 [07:56] <:(*@args, *%kwargs)> why does my function returns Nil https://glot.io/snippets/ghmzmvga3v [07:57] <:(*@args, *%kwargs)> oh the last for just got interpreted as a statement [07:57] yes, your last for is run in sunk context [07:58] however, this is nothing a do statement prefix couldn't accomodate for [07:58] https://cdn.discordapp.com/attachments/768511641758466088/1068077487545925662/image.png [07:58] <:(*@args, *%kwargs)> i just wrap it in parens [07:58] https://cdn.discordapp.com/attachments/768511641758466088/1068077545318252574/image.png [08:03] https://glot.io/snippets/ghmzu5g7qg [08:03] changed two little things [08:05] <:(*@args, *%kwargs)> thx [08:06] <:(*@args, *%kwargs)> m:perl my @a is default(True); say @a[1]; say @a; [08:06] <:(*@args, *%kwargs)> is that autovivification magic [08:06] basically yes [08:06] it says "if you retrieve a value that doesn't exist, you should get this" [08:09] <:(*@args, *%kwargs)> is there builtin function which does .raku.say? [08:09] more or less [08:09] <:(*@args, *%kwargs)> like this sub say-raku($v) { $v.raku.say } [08:09] dd does something that includes that [08:09] it tries to fetch the name of the variable as well [08:10] m: my @a = [[1,2],3]; dd @a [08:10] m: my @a = [[1,2],3]; dd @a[0] [08:10] mind the $ [08:11] <:(*@args, *%kwargs)> $ = container [08:11] because it's an element of an array [08:11] so it's wrapped in a SCalar [08:11] <:(*@args, *%kwargs)> m: say 13.Str.comb.reverse.join.Int [08:11] <:(*@args, *%kwargs)> chaining magic 😎 [08:12] you don't even need .Str I think [08:12] weak typing 😆 [08:12] say 13.comb.reverse.join.Int [08:12] m: say 13.comb.reverse.join.Int [08:12] actually, this is just 13.flip.Int [08:13] <:(*@args, *%kwargs)> m: say 13.flip [08:13] m: dd 13.flip [08:14] the reason is that Int is Cool [08:14] this is not my pun [08:14] https://docs.raku.org/type/Cool [08:16] <:(*@args, *%kwargs)> weak typing isn't cool 😤 [08:17] not even if it's called inheritance? 😛 [08:20] <:(*@args, *%kwargs)> its not if unrelated types are implicitly coerced [08:20] <:(*@args, *%kwargs)> m: say 1 + '1' [08:21] that's a different case [08:21] and well, "implicitly"? Isn't it what + signals? [08:21] as opposed to ~ for example [08:21] <:(*@args, *%kwargs)> ok "explicitly" coerced [08:23] <:(*@args, *%kwargs)> implicit because there is no .Int after the string [08:23] okay but who decided that .Int (or perhaps better said .Numeric) is the only way to mark the operands as numbers? [08:26] <:(*@args, *%kwargs)> me [08:26] 🐈 [08:28] btw I might have found a bug [08:28] all roles are Cool [08:29] <:(*@args, *%kwargs)> :cameliathink: [08:30] <:(*@args, *%kwargs)> m: my @set = (1, 2, 3).Set; dd @set; [08:31] <:(*@args, *%kwargs)> somehow everything in @ is coerced into an Array [08:35] there are two things with @ [08:35] an enforced type constrain (Positional) [08:35] and a default type (Array) [08:36] when you assign a value to a my @var, you are putting stuff into the array [08:36] if you were to bind instead [08:36] m: my @set := (1, 2, 3).Set; [08:36] dang, that doesn't fulfill the constraint [08:44] <:(*@args, *%kwargs)> how do i convert from a list of keys to a Map with the keys in the same order [08:45] Maps don't keep order I think [08:45] that's intrinsic to their representation [08:46] <:(*@args, *%kwargs)> Hash does? [08:46] probably not [08:46] there are modules that enforce some ordering but that's definitely a performance penalty [08:47] you canuse Hash::Ordered if you must [08:58] <:(*@args, *%kwargs)> how to apply a callable to a list [08:59] what do you mean? this sounds like a function call with a list argument [09:00] <:(*@args, *%kwargs)> py f(*args) or like this in jsjs f.apply(null, args) [09:00] <:(*@args, *%kwargs)> do i use slips again? [09:01] oh so you want to unpack it into an argument list? [09:01] Well, basically yes, except here I think you must use the | syntax [09:01] |@list [09:01] or something [09:03] | can be used for unpacking a Pair or Map into named arguments, too [09:07] <:(*@args, *%kwargs)> til there are 3 kinds of slurpy args [09:09] <:(*@args, *%kwargs)> m: sub f(*@args) { @args } sub g(**@args) { @args } sub h(+@args) { @args } say f(1, (2, 3), 4); say g(1, (2, 3), 4); say h(1, (2, 3), 4); [09:10] <:(*@args, *%kwargs)> ** slurpy is the closest to other languages [09:10] *** dakkar joined [09:11] yes [09:11] * is kind of legacy and + is the pragma [09:14] <:(**@args, **%kwargs)> does the choice of slurpy types affect named slurpies? [09:15] <:(**@args, **%kwargs)> m: sub f(*%kwargs) { %kwargs } sub g(**%kwargs) { %kwargs } sub h(+%kwargs) { %kwargs } say f( :a(1), :b(2, 3) ); say g( :a(1), :b(2, 3) ); say h( :a(1), :b(2, 3) ); [09:15] <:(**@args, **%kwargs)> what [09:16] <:(**@args, **%kwargs)> bruh [09:16] i was trying the last one and it becomes and Array :y [09:17] m: -> +%k { %k.say }((a => 4, b => -2)) [09:17] ** and + not meant to use with % [09:17] **%a one turns into %a [09:17] +%a turns into... array [09:18] <:(**@args, *%kwargs)> i want to use ** with % for consistency with **@ 😭 [09:18] it turns into array for scalars as welll [09:19] m: -> +$a { $a.say }(4, 5) [09:19] i think +%k is better for esoterism [09:19] then +$a [09:19] fair enough tbh [09:20] also, does *%kwargs flatten or not? [09:26] seems to me that flattening a map/hash is not really a thing [09:26] well okay, I think consistency would be if ** and + existed for named arguments as well... [09:29] <:(**@args, *%kwargs)> except that for named argument there are no flattening and they are the same [09:29] same as what? [09:30] oh you mean *%a to be the same as **%a? [09:30] <:(**@args, *%kwargs)> as in, *, ** and + should have the same behavior for % [09:30] +% maybe not [09:31] <:(**@args, *%kwargs)> oh yeah [09:32] <:(**@args, *%kwargs)> m: say 1 in Set.new(1, 2, 3); [09:32] but yeah I think this could be added to another language version no problem [09:33] probably not on the fly because it is kind of a breaking change [09:33] <:(**@args, *%kwargs)> m: say 1 (elem) Set.new(1, 2, 3); [09:33] <:(**@args, *%kwargs)> 😠 [09:33] what's the problem? [09:33] <:(**@args, *%kwargs)> is in ever used for anything [09:34] not sure [09:34] https://docs.raku.org/routine/in welp [09:34] <:(**@args, *%kwargs)> why can't they just use keyword in instead of (elem) or ∈ [09:35] well, add it for yourself [09:35] lol [09:36] sub infix($a, $b) { $a (elem) $b } [09:36] or something [09:37] <:(**@args, *%kwargs)> m: my &infix: = infix:<(elem)>; say(3 in (1, 2, 3).Set); [09:37] missed the & [09:37] <:(**@args, *%kwargs)> m: my &infix: = &infix:<(elem)>; say(3 in (1, 2, 3).Set); [09:38] actually this is a better idea than what I did [09:43] anyway, if you have preferences of this sort, you can create e.g a module for yourself and load that [09:43] kinda simple [09:57] <:(**@args, *%kwargs)> how do i set the operator precedence of my defined operators [09:58] https://docs.raku.org/language/functions#Precedence [10:09] <:(**@args, *%kwargs)> > Specifying the associativity of non-infix operators is planed but not yet implemented. why do unary (prefix or postfix) operators need associativity [10:13] Good question xd [10:14] However, this question might be about postcircumfix or sth [10:15] <:(**@args, *%kwargs)> i dont think postcircumfix might need associativity [11:12] *** MasterDuke left [11:37] <:(**@args, *%kwargs)> what is the equovalent of super in raku [11:39] i realized captures are both positional and named slurpers [11:40] m: -> |allargs { allargs.say }(3, 4, a => 2) [11:40] m: -> |allargs { allargs.say }(a => 2, 3, 4) [12:10] I wish I knew, at this point I suspect it may not even exist [12:10] Probably some metamodel magic [12:35] *** ab5tract joined [13:16] <:(**@args, *%kwargs)> why no super tho [13:21] *** ab5tract left [13:21] <:(**@args, *%kwargs)> like it should be one of the most basic oo features [13:24] I think it's the concept that is a bit shallow [13:24] How does Python do it? [13:24] With multi dispatch (and mixins, in Raku) [13:32] *** ab5tract joined [13:43] if you want to use super, you probably want to look into using roles [13:47] *** ab5tract left [14:04] *** jgaz joined [14:07] I wanted to say multiple inheritance, not multiple dispatch [14:11] <:(**@args, *%kwargs)> python classes have an mro created using C3 algorithm (like raku) super then just pick the next element in the mro so if the mro is [A, B, C, object] then super() will just create an object that forward anything to B [14:23] lizmat: how do you use roles in a similar way? [14:30] if this is about calling methods in a parent class, then https://docs.raku.org/language/functions#Re-dispatching could be of interest [14:34] It seems problematic that method resolution is backed up by the same (non-transparent) rules as multiple dispatch motivated by the type of function parameters [14:35] Python can do this safely because there are absolutely no function overloads [14:42] It might be something that I don't know. With inheritance and mixins (?), there can be multiple protos; super is logically about switching protos, not switching candidates [14:43] a proto is a "stopper" in dispatch terms [14:43] at least, afaik :-) [14:50] What does that mean? 👀 [14:52] Before starting the guessing game... I don't feel I would know the hierarchy when you have inheritance and some candidates on both levels in the inheritance chain [15:22] *** ab5tract joined [15:40] *** ab5tract left [15:58] m: class A { proto method a() { dd } }; class B is A { proto method a() { dd; nextsame } }; B.a # I stand corrected [15:58] rakudo-moar d10c27506: OUTPUT: «method a(B: *%_)␤method a(A: *%_)␤» [16:02] <:(**@args, *%kwargs)> **** rakudo-moar d10c27506: OUTPUT: «method a(B: *%_)␤method a(A: *%_)␤» [16:03] <:(**@args, *%kwargs)> why doesn’t it wrap in code blocks to get away with discord formatting [16:06] someone on the Discord side should answer that I thiunk [16:06] *think [16:14] <:(**@args, *%kwargs)> super should be easy? A.^mro[1] should get the superclass whats next is just creating an object to forward calls to that superclass? [16:18] <:(**@args, *%kwargs)> is there a method to call when a wrong (missing) method is called [16:25] *** Heptite joined [16:28] Yep, FALLBACK [16:41] I'll look into both mentioned issues in a bit, thanks for noticing [17:18] <:(**@args, *%kwargs)> m: class A { method FALLBACK(**@args, *%kwargs) { say %(|@args, |%kwargs); } } my $a = A.new; $a.x(1, 2, foo => 'bar'); [17:18] <:(**@args, *%kwargs)> m: class A { method FALLBACK(**@args, *%kwargs) { say %(|@args.pairs, |%kwargs); } } my $a = A.new; $a.x(1, 2, foo => 'bar'); [17:36] *** dakkar left [17:47] *** Guest7492 joined [18:11] *** Guest7492 left [18:51] *** ab5tract joined [19:22] *** gfldex joined [20:54] *** m_athias left [20:54] *** m_athias joined [21:28] *** NemokoschKiwi joined [23:04] *** ab5tract left [23:21] *** jaguart left [23:57] *** NemokoschKiwi left