🦋 Welcome to the former MAIN() IRC channel of the Raku Programming Language (raku.org). This channel has moved to Libera (irc.libera.chat #raku) Set by lizmat on 23 May 2021. |
|||
00:01
Shaeto left
00:02
reportable6 left
|
|||
raydiak | leont++ I just finished watching your syntax talk, great job showing off awesome features in an approachable way | 00:04 | |
00:05
reportable6 joined
00:14
Shaeto joined
00:19
Shaeto left
00:24
Shaeto joined
00:29
Shaeto left
00:42
Shaeto joined
00:46
Shaeto left
00:51
Shaeto joined
00:55
Shaeto left
01:09
Shaeto joined
01:10
wjbb joined
01:13
wjbb left
01:14
Shaeto left
01:18
Shaeto joined
01:21
yewscion left
01:23
Shaeto left
01:27
Shaeto joined
01:32
Shaeto left
01:36
Shaeto joined
|
|||
[Coke] | looks like an E<mdash> in POD is converted to an mdash when generating html, but not when running raku --doc | 01:38 | |
see docs.raku.org/language/101-basics vs. (clone raku docs and) raku --doc doc/Language/101-basics.pod6 | grep mdash | |||
(this is causing an error in the spelling tests for the docs, because operatorE<mdash>a is rendering as "operatormdasha" instead of "operator—a" | 01:39 | ||
Seems like this is a rakudo bug. | |||
01:41
Shaeto left
01:55
Shaeto joined,
RandalSchwartz left
02:00
Shaeto left
02:04
Shaeto joined
02:08
Shaeto left
02:13
Shaeto joined
02:18
Shaeto left,
moon-child left
02:23
moon-child joined
02:31
Shaeto joined
02:36
Shaeto left
02:40
Shaeto joined
02:45
Shaeto left
02:59
Shaeto joined
03:04
Shaeto left
03:08
Shaeto joined
03:13
Shaeto left
|
|||
cnx | re `add $*HOME: '.cache'`: moritz, I expected it to give the same result as `$*HOME.add: '.cache'` | 03:15 | |
03:17
Shaeto joined
03:21
cnx left,
demostanis[m] left,
juanfra left
03:22
tyil[m] left,
ComplYue[m] left,
CIAvash left,
AlexDaniel left,
Shaeto left
03:26
Shaeto joined
03:30
Shaeto left
03:35
Shaeto joined
03:39
Shaeto left
03:40
zephyr_ joined
03:43
squashable6 left,
squashable6 joined,
squashable6 left
03:44
Shaeto joined
03:45
squashable6 joined
03:49
Shaeto left
04:02
Shaeto joined
04:07
Shaeto left
04:12
Shaeto joined
|
|||
moritz | cnx: and instead you get...? | 05:07 | |
tellable6 | moritz, I'll pass your message to cnx | ||
05:12
linkable6 left,
evalable6 left,
tellable6 left,
evalable6 joined
05:13
linkable6 joined,
tellable6 joined
05:17
ufobat__ joined
05:19
Shaeto left
05:21
Shaeto joined
05:25
Shaeto left
05:26
Doc_Holliwood joined
05:30
Shaeto joined
05:35
Shaeto left
05:39
Shaeto joined
05:44
Shaeto left
05:48
Shaeto joined
05:49
Sgeo left
05:53
Shaeto left
05:57
Shaeto joined
06:02
reportable6 left,
Shaeto left
06:03
reportable6 joined
06:07
Shaeto joined
06:11
Shaeto left
06:16
Shaeto joined
06:20
Shaeto left
06:25
Shaeto joined
06:29
Shaeto left
06:30
stoned75 joined
06:34
Shaeto joined
06:39
Shaeto left
06:43
Shaeto joined
06:46
Doc_Holliwood left
06:47
Shaeto left
06:52
Doc_Holliwood joined,
Shaeto joined
06:57
Shaeto left
07:01
Shaeto joined
07:06
Shaeto left
07:09
patrickb joined
07:10
Shaeto joined
07:14
peder joined
07:15
Shaeto left
07:20
Shaeto joined
07:23
juanfra joined
07:24
Shaeto left
07:25
AlexDaniel joined,
demostanis[m] joined,
cnx joined,
ComplYue[m] joined,
tyil[m] joined,
CIAvash joined
07:29
Shaeto joined
07:33
Shaeto left
07:38
Shaeto joined
|
|||
raydiak | m: say $*HOME.add: '.cache'; say add $*HOME: '.cache'; # cnx | 07:41 | |
camelia | "/home/camelia/.cache".IO "/home/camelia/.cache".IO |
||
07:42
Doc_Holliwood left
07:43
Shaeto left
07:47
Shaeto joined
07:52
Shaeto left
|
|||
raydiak | if you're getting different results, there are 3 probable causes off the top of my head: (1) much looser precedence of the second form interacting unexpectedly with whatever is around it, (2) an outdated rakudo with a bug, or (3) an overlooked discrepancy elsewhere in your code | 07:55 | |
07:56
Shaeto joined
|
|||
cnx | no worries I think I tried it with something .IO without the parenthesis and was confused by the error | 07:58 | |
tellable6 | 2021-06-11T05:07:44Z #raku <moritz> cnx: and instead you get...? | ||
cnx | Undeclared routine: add | 07:59 | |
08:00
abraxxa left
|
|||
raydiak | glad you figured it out | 08:00 | |
08:01
Shaeto left
|
|||
cnx | thanks (-; | 08:01 | |
btw is github.com/MoarVM/MoarVM/issues/433 still a problem on Windows | 08:02 | ||
I saw the relevant commit being reverted and I'm not familiar with windows' lib | |||
(it's still an issue on POSIX though) | |||
patrickb | o/ | 08:03 | |
cnx | o/ | ||
raydiak | \o | ||
08:05
Shaeto joined
|
|||
raydiak | idk, I don't run windows | 08:05 | |
patrickb | I'm writing a method trait that needs some persistent storage that is object and method local (i.e. each method that has the trait applied should have its own storage, two objects of the same type -> two separate storage places). Can I somehow dynamically tack on a variable on to an object? | 08:08 | |
08:10
Shaeto left
08:14
Shaeto joined
08:19
Shaeto left
|
|||
moritz | make that extra object an attribute? | 08:20 | |
or you could use a mixin | |||
08:20
Doc_Holliwood joined
|
|||
patrickb | moritz: Can I dynamically add attributes? | 08:21 | |
patrickb reads up on mixins | 08:22 | ||
08:23
Shaeto joined
|
|||
moritz | m: class A { has $.x }; role ExtraAttribute { $.extra = 42 }; my $a = A.new: :x(3); $a does ExtraAttribute; say $a.extra | 08:24 | |
camelia | 5===SORRY!5=== Error while compiling <tmp> Variable $.extra used where no 'self' is available at <tmp>:1 ------> 3has $.x }; role ExtraAttribute { $.extra7⏏5 = 42 }; my $a = A.new: :x(3); $a does E expecting any of: ter… |
||
moritz | m: class A { has $.x }; role ExtraAttribute { has $.extra = 42 }; my $a = A.new: :x(3); $a does ExtraAttribute; say $a.extra | ||
camelia | 42 | ||
moritz | m: class A { has $.x }; role ExtraAttribute { has $.extra = 42 }; my $a = A.new: :x(3); $a does ExtraAttribute(23); say $a.extra | ||
camelia | 23 | ||
raydiak | could probably also use a state hash keyed on .WHICH instead of attached to the object | 08:26 | |
kinda like a p5 inside-out object | 08:27 | ||
08:28
Shaeto left
08:29
zephyr_ left
|
|||
raydiak | m: multi trait_mod:<is> (Method $m, :$t) { $m.wrap: -> |a { state %o; say %o{a[0].WHICH} //= rand; callsame; } }; class C { method m is t { } }; my $a = C.new; my $b = C.new; $a.m; $a.m; $b.m; $b.m; | 08:32 | |
camelia | 0.3498273627434584 0.3498273627434584 0.6734468350068424 0.6734468350068424 |
||
08:33
Shaeto joined
08:38
Shaeto left
|
|||
raydiak | then again, that wouldn't get garbage-collected | 08:42 | |
patrickb | m: role Store { has %.store; }; multi sub trait_mod:<is>(Method:D $m, :$serial-dedup) { say "wrapping"; $m.wrap(my method ($obj:) { if !$obj.does(Store) { $obj does Store }; say $obj.store{$m.name}++; callsame()} ); }; class C {method m() is serial-dedup { say "m()" }; method n() is serial-dedup { say "n()" } }; my C $c .= new; $c.m; $c.m; $c.n | 08:49 | |
camelia | wrapping wrapping 0 m() 1 m() 0 n() |
||
patrickb | Thanks everyone! | 08:50 | |
raydiak | thanks for sharing the interesting question :) | 08:51 | |
if this is for use with other people's classes/roles, keep in mind that'll mask out a .store method if one exists in class C | 08:55 | ||
lizmat | raydiak: using a hash with .WHICH as a key, is not thread safe, you should keep that in mind | 08:56 | |
or any hash, for that matter:-) | |||
raydiak | ah, another good point against it | 08:57 | |
09:00
Doc_Holliwould joined
09:03
Doc_Holliwood left
09:38
Doc_Holliwould left
09:39
Doc_Holliwould joined
09:42
sono left
09:58
Shaeto joined
10:53
M_o_C joined
10:54
M_o_C is now known as MoC
10:59
MoC is now known as MoC_,
MoC_ is now known as MoC__,
MoC__ is now known as MoC
11:00
frost joined
11:02
MoC left,
MoC joined
11:07
Doc_Holliwould left
11:13
MoC left,
MoC joined
11:30
MoC left,
MoC joined
11:32
MoC left,
MoC joined
11:34
MoC left,
MoC joined
11:35
sena_kun joined
11:40
holly__ joined
11:41
holly__ left
11:44
b2gills left
11:58
MoC left
12:02
reportable6 left
12:04
reportable6 joined
12:56
Kaipi joined
12:58
Kaiepi left
12:59
frost left
13:12
b2gills joined
13:39
RandalSchwartz joined
13:54
guifa joined
13:59
kylese joined
14:17
MoC joined
14:19
jess joined
14:28
vrurg left
14:37
Sgeo joined
14:38
ufobat_ joined
14:42
ufobat__ left
14:54
lizmat_ joined
14:57
Raycat|Work left,
lizmat left
15:15
MoC left,
MoC_ joined,
vrurg joined
15:18
MoC_ is now known as MoC
|
|||
guifa | I don't suppose anyone has any ancient versions of Mac OS X laying around that could test something for me? | 15:32 | |
Altreus | I'm not going to admit to that | 15:38 | |
15:38
Kaipi left
|
|||
Altreus | Although I'm not sure the computer works so I actually shouldn't | 15:38 | |
how ancient is ancient? | |||
guifa | Altreus: eh, I mean, if you had it still running public beta that'd be cool :-) | 15:40 | |
Altreus | it's an intel chip so I guess no | 15:41 | |
guifa | I'm switching to a new method for grabbing user information in one of my modules. The way I'd been getting it via shell commands has worked for … many a version, but I recently found out isn't considered a formal API. | ||
Altreus | Wait, was OSX always on intel? | ||
guifa | Nope, on PPC originally. | 15:42 | |
Altreus | ah, yeah I had a PPC but it was shafted so I put debian on it | ||
guifa | So now I'm making Foundation calls via NativeCall but I'm not clear how far back those work (certainly the core ones, but I'll want to put in a version guard for the one or two that I know weren't available in PB times) | 15:44 | |
Altreus | alas I am unable to satisfy your minimum age requirement | 15:45 | |
or ... maximum | |||
That's a matter of perspective | |||
codesections | That is some _commitment_ to backwards compatibility | ||
guifa | codesections: honestly, more of curiosity. I legit don't know when Apple added a few calls. | 15:46 | |
But I'm really interested in beefing up the UserLanguage and UserTimezone modules (and probably down the road, similar UserFoo stuff) and NativeCall is definitely the way to go for Windows and Mac for best long term stability | 15:48 | ||
MasterDuke34 | i have an old mac mini, i think it's running lion, but i haven't turned it on in over a year | 15:51 | |
could give it a try later tonight or this weekend if you're still in need | 15:52 | ||
Altreus | Might have to be both if you need to compile raku on it :D | ||
MasterDuke34 | hm, you know, don't think i ever have on it (yet) | 15:53 | |
guifa | My update to UserLanguage doesn't just get me ast-US like it used to, but now it does ast-Latn-US-t-ca-gregory-co-trad-fw-sun-ms-ussystem | 15:59 | |
I'll finally be able to produce proper output for DateTime::Format | |||
Altreus | what the heck | 16:01 | |
Nice of them to abbreviate some of those :P | 16:02 | ||
guifa | i love the "gregory" for gregorian. BCP47 says each element can only be max 8 characters | 16:03 | |
Altreus | Strange constraint but OK | 16:05 | |
guifa | right? The weirder one is the total max length of 256 characters (including hyphens), but NO restriction on number of subtags | 16:07 | |
16:31
jess left,
cnx left,
demostanis[m] left,
juanfra left,
codesections left,
GreaseMonkey left
16:44
jess joined
16:49
RandalSchwartz left
16:50
greaser|q joined,
codesections joined
16:53
jess is now known as j
17:02
j is now known as jess
17:08
juanfra joined
17:29
demostanis[m] joined
17:32
MoC left
17:36
Doc_Holliwould joined
17:37
cnx joined
18:02
reportable6 left
18:04
reportable6 joined
18:15
holly_ joined
18:18
kybr left
18:20
kybr joined
18:23
wjbb joined
18:24
ufobat_ left
18:28
avuserow joined
18:36
wjbb left
18:50
Kaiepi joined
|
|||
m6locks | how do I create a 2dim array? the examples that I see using rotor don't seem to work with my array that is supposed to be filled with booleans | 19:29 | |
19:30
RandalSchwartz joined
|
|||
m6locks | in java it's merely new boolean[rows][cols]; | 19:30 | |
guifa | m6locks: what code do you have right now? | 19:31 | |
m6locks | nothing | ||
I tried my Bool @matrix = <False xx $rows*$cols>.rotor($rows); | 19:32 | ||
guifa | aaaah | ||
okay so it's making an array BUT | |||
you've typed it, and rotor doesn't return it typed | |||
m6locks | ah | ||
guifa | my ($rows, $cols) = 3, 3; my @matrix = <False xx $rows*$cols>.rotor($rows); say @matrix[1][2]; | 19:33 | |
evalable6 | (Any) | ||
guifa | err | ||
m6locks | aye it works if I remove the Bool | ||
thx | |||
guifa | well, it almost does. You need () not < > | ||
<False xx $rows*$cols> produces a list of string elements, "False", "xx", and "$rows*$cols" | 19:35 | ||
m6locks | my @matrix = [False xx 3*3].rotor(3); say @matrix[1][2]; | ||
evalable6 | False | ||
m6locks | I'll use that one | 19:36 | |
guifa | if you want to type: | 19:39 | |
my Array[Bool] @matrix = Array[Array[Bool]].new(Array[Bool].new(False xx $cols) xx $rows); say @matrix[1][2] | |||
m: my Array[Bool] @matrix = Array[Array[Bool]].new(Array[Bool].new(False xx $cols) xx $rows); say @matrix[1][2] | |||
camelia | 5===SORRY!5=== Error while compiling <tmp> Variable '$cols' is not declared. Did you mean '&cos'? at <tmp>:1 ------> 3ray[Bool]].new(Array[Bool].new(False xx 7⏏5$cols) xx $rows); say @matrix[1][2] |
||
guifa | err duh I'd need to define the cols and rows ha | 19:40 | |
m6locks | aye that's consistent with other constructs being typed | 19:43 | |
raydiak | there's also shaped arrays | 19:47 | |
m: my Bool @a[3;3]; @a = False xx 3 xx 3; say @a.raku | 19:48 | ||
camelia | Array[Bool].new(:shape(3, 3), [Bool::False, Bool::False, Bool::False], [Bool::False, Bool::False, Bool::False], [Bool::False, Bool::False, Bool::False]) | ||
19:48
MoC joined
19:50
MoC_ joined
19:53
MoC left
19:54
MoC_ is now known as MoC
19:57
holly_ left
19:58
Kaiepi left
19:59
Kaiepi joined
20:02
stoned75 left
20:04
Kaiepi left
20:09
yewscion joined
20:12
Kaiepi joined
20:27
Xliff joined
|
|||
Xliff | \o | 20:27 | |
Is there a way to find proto methods in a list of Method objects? | |||
I would have thought that would have been a method on Routine. | |||
Or Method itself. | |||
codesections | does this do what you want? (I'm not quite sure I know what you're looking for) | 20:33 | |
m: my class C { proto method foo(|) {*}; multi method foo(Str) { 'str'}; multi method foo(Int) {42}}; say C.^methods.grep({.candidates».multi}) | |||
camelia | (foo BUILDALL) | ||
[Coke] | (mac) I'm on 10.15.7, which isn't ancient, but is a major rev back. | 20:40 | |
20:40
kylese left
|
|||
Xliff | codesections: How many times is foo mentioned in .^methods? | 20:42 | |
codesections | foo is mentioned once, which referees to the proto (e.g., it has a .signature of (|)). foo.candidates returns 2 foo (multi) methods | 20:43 | |
20:49
sono joined
|
|||
Xliff | Ah! OK. I found repeat methods in my .^methods output. Turns out those were put there by Method::Also. | 20:49 | |
Just hacked in a way to identify these. | |||
20:59
yewscion left,
yewscion joined
|
|||
codesections | interesting. I don't think I've ever used Method::Also. I take it that's what you get from the `also is` declarator? | 21:03 | |
Xliff | 'is also', yes | 21:04 | |
codesections | ? so not docs.raku.org/language/classtut#Th...declarator | 21:06 | |
m: my class C { also is Int } | |||
camelia | ( no output ) | ||
raydiak | no, not that (though I like that syntax) | 21:08 | |
Xliff is using modules.raku.org/dist/Method::Also...:ELIZABETH | |||
codesections | ahhh, I see! | 21:09 | |
21:13
Shaeto left
|
|||
raydiak | personally quite fond of 'also is/does' though. looks cleaner to me a lot of the time. nice to have the traits and inheritance/composition stuff inside the curly braces instead of tacked on to the name, imo | 21:17 | |
codesections | m: my class C { method raku {note '.raku called' ''}}; C.new eqv C.new | 21:18 | |
camelia | 5===SORRY!5=== Error while compiling <tmp> Two terms in a row at <tmp>:1 ------> 3ass C { method raku {note '.raku called'7⏏5 ''}}; C.new eqv C.new expecting any of: infix infix stopper postfix … |
||
codesections | m: my class C { method raku {note '.raku called'; ''}}; C.new eqv C.new | ||
camelia | WARNINGS for <tmp>: Useless use of "eqv" in expression ".new eqv C.new" in sink context (line 1) .raku called .raku called |
||
codesections | wait, ??? why is eqv calling .raku? I thought (and the docs indicate) it was for structural equivalence, not string comparison | 21:19 | |
I guess that's from github.com/rakudo/rakudo/blob/mast...1204-L1209 | 21:21 | ||
but strikes me as very odd | 21:22 | ||
21:23
yewscion left
|
|||
codesections | m: my class C { has $.a; method raku {note '.raku called'; ''}}; say C.new(:a<Yes>) eqv C.new(:a<No!>) | 21:26 | |
camelia | .raku called True .raku called |
||
raydiak | that is kinda interesting. it's comparing .raku output instead of inspecting the objects with the MOP | 21:34 | |
guifa | raydiak: I prefer the also is/does when I have unit scoped things, and when the role/class applied needn't pollute the outer symbol table | 21:35 | |
codesections: basically, it's the fallback for comparison. The idea is that .raku should have the information needed to reconstruct an object, hence being an adequate (if potentially imperfect) fallback | |||
codesections | Yeah, I *guess* I get that. (Though, as shown above, it can break if uses don't realize that and do something they shouldn't with .raku output (tempting for people who want more readable .raku/dd output)). And it means we *really* need things to round trip correctly (which is spec, but there are a lot of open bugs) | 21:37 | |
raydiak | it does feel a touch unexpected. otoh, no more unexpected than a raku method having side-effects like printing output | 21:38 | |
codesections | But, more to the point, *why*? Why are we falling back on .raku comparisons so early? It seems like we're not trying something like .^attributes recursively | 21:39 | |
guifa | .^attributes could potentially catch things that are unnecessary, e.g., an internal-use-only UUID, that would autofail the eqv. I think that's the point of .raku, since it's only the relevant bits of data | 21:40 | |
my only issue with eqv is that it's very hard to create custom eqv methods | 21:41 | ||
codesections | hmmm, I *think* I disagree. If two objects have a different UUID, it seems like they shouldn't be eqv (though they could compare equal in other ways) | 21:42 | |
guifa | note I said internal uuid | ||
raydiak | my main concern would be that someone might make a custom .raku with non-deterministic output. e.g. iterating over an internal hash without sorting the keys | ||
guifa | raydiak: that's something that should be noted for developers, absolutely | ||
class A {Â }; my $a = A.new; my $b = A.new; say $a.WHERE == $b.WHERE | 21:43 | ||
evalable6 | False | ||
guifa | WHERE or WHICH are basically UUIDs, but irrelevant for comparison | ||
codesections | Yeah. But a u_u_id seems like it's there precisely to be able to tell objects apart, no? | ||
but not attributes | 21:44 | ||
21:44
lizmat_ is now known as lizmat
|
|||
raydiak | eqv isn't supposed to tell objects apart. it's supposed to tell the value of objects apart. and what constitutes the "value" of an object depends on what it is and how it's meant to be used. === tells objects apart | 21:45 | |
codesections | right, I get that; sorry for the sloppy terminology :) | 21:46 | |
guifa | raydiak: exactly. And .raku isn't supposed to create the identical object, just an identically valued object. The internal attributes may or may not contribute to that, though. | ||
but the .raku output, properly created, should | |||
codesections | Maybe my fundamental issue is expressed by the comment above the code I linked: «# Last ditch snapshot semantics. We shouldn't come here too often» Right now, we come there by default for pretty much every user-created type | 21:47 | |
guifa | codesections: I wouldn't disagree about that. We just don't have a great equivalency protocol, but I'm also not sure how to create one | 21:48 | |
Right now the options are: (a) creative a custom infix:<eqv>($a, $b) for the types, or (b) ensure .raku output is identical | 21:49 | ||
(a) will only work when you can have the module in scope, which is to say you can never rely on outside code to properly calculate the equivalency | 21:50 | ||
(b) well, you've already seen the potential downsides to that one | |||
guifa . o O are my language tags getting too crazy? new sample lol: es-ES-t-ca-gregory-co-trad-cu-eur-fw-sun-ms-metric-tz-usnyc ) | 21:51 | ||
raydiak | maybe a trait to flag an attribute for exclusion from eqv and .raku? | ||
codesections | Maybe we should make `is implementation detail` be applicable to attributes | ||
guifa | d | 21:52 | |
codesections | raydiak: we're thinking along the same lines, clearly :D | ||
raydiak | great minds and all that, right? :D | 21:53 | |
guifa | So .... how do we properly do eqv for this one? :-) Â class Length {Â has $.unit; has $.quantity } | ||
This is a case where you'd even want the unit and quantity in the .raku output, but you'd want two things to be found potentially eqv. | 21:54 | ||
guifa figures if we're gonna muck with eqv, we probably should look at all angles | |||
vrurg | It worth a problem-solving. What if eqv optionally bypasses to object's 'EQUALS' method, similar to how smarmatch uses ACCEPTS? I already see a problem here, but still think it's worthful to consider. | 21:55 | |
codesections | is that a trick question? Length $a and Length $b are eqv iff $a.unit eqv $b.unit && $a.quantity eqv $b.quantity | ||
guifa | codesections: I don't think it is | ||
Length.new( :unit<meter>, :1quantity ) should be equivalent to Length.new( :unit<centimeter>, :100quantity ) | 21:56 | ||
raydiak | hrm. make both implementation-detail, and add $.value = $!length * $!quantity ? idk, good example | ||
vrurg | Two objects are not necessarily to be of the same type of be equivalent. Think of a point in Polar and Cartesian representations. | 21:57 | |
moon-child | I think you want to map :unit<centix> :quantity(y) to :unit<x> :quantity(y/100) | ||
codesections | Hmm, I'd actually say those shouldn't be eqv, but should be == | ||
moon-child | or possibly to :unit<x> :quantity(y) :ratio(1/100) | 21:58 | |
codesections | m: my Num $a = 1.Num; my Int $b = 1; say $a eqv $b; say $a == $b | 21:59 | |
camelia | False True |
||
vrurg | codesections: I had to refresh my memory and you're right. eqv is first of all about type equivalency. | ||
codesections | guifa's Length example is trickier, in that both are Lengths. But I'd still say they're not eqv | 22:01 | |
(Though I freely admit that's pushing against the meaning of the English word 'equivalent' a bit!) | 22:02 | ||
guifa | and regardless, the inability to specify a custom eqv except in specific, non-dynamic scopes, is problematic | ||
codesections | Agreed. | 22:03 | |
vrurg's .EQUALS idea (.EQUIVALENT ?) would be one way to get at that | 22:04 | ||
22:04
Maylay left
22:05
Maylay joined
|
|||
guifa | Since the type equivalency is required, it actually shouldn't be as problematic | 22:05 | |
22:05
patrickb left
|
|||
guifa was thinking something like == or cmp or eq need symmetry, but that's hard to define if the types can be different | 22:07 | ||
moon-child | m: my \*x | 22:08 | |
camelia | 5===SORRY!5=== Error while compiling <tmp> Malformed my at <tmp>:1 ------> 3my7⏏5 \*x |
||
moon-child | why not? Syntactic ambiguity with *x? | ||
vrurg | There is one thing to keep in mind though. ~~ is asymmetric. But eqv is commutative. So, if a method is used we must ensure that both side methods are giving True | ||
guifa | vrurg: yeah, but since eqv requires type equivalency, then a type can ensure that its method EQUIV() is symmetric, since it would only be passed its own type | 22:10 | |
codesections | guifa: and I guess as a corollary to the point you made re: custom eqv, Test::is-deeply will never use a custom eqv with the current system, right? | 22:14 | |
vrurg | guifa: Likely so. Apparently, one can always break the rule, but then it'd be up to him to take the responsibility for such design. | ||
guifa | codesections: correct. No way to force your eqv method into Test's is-deeply | 22:15 | |
codesections | There is cmp-ok, but yeah... | 22:16 | |
guifa | Cmp lets you specify the method… but if you compare two lists of objects, they won't know to use your special method in comparing their contents | 22:17 | |
they = the lists | |||
you'd have to write a full comparison function, but then you could just do 'ok myspecialmethod($a, $b)' | |||
22:18
swaggboi left
22:19
MoC left
|
|||
codesections | yeah. I guess you could do `all .map({cmp-ok($a, &[eqv], $b)})`. But that's just a short/inline comparison function | 22:20 | |
guifa | (this is, incidentally, an issue with most operators, and I'm not sure a great design solution. If I have a custom infix:<+> for my type, there's no way to have it propogate) | 22:21 | |
22:23
sena_kun left
|
|||
codesections | yeah. Many languages solve that by having $a + $b compile to $a.infix_plus_operator($b), but that makes the order of the operands determinate | 22:23 | |
guifa | I mean, technically it's determinate for infix:<+>($a, $b) too | 22:24 | |
codesections | True enough | 22:25 | |
guifa | m: class A {}; class BÂ {}; multi sub infix:<+>(A $, B $) {Â say "a plus b" }; B + A | ||
camelia | WARNINGS for <tmp>: Useless use of "+" in expression "B + A" in sink context (line 1) Use of uninitialized value of type B in numeric context in block <unit> at <tmp> line 1 Use of uninitialized value of type A in numeric context in bloc… |
||
guifa | I think you could just wrap it to try to get first dibs on the operators, but that'd be an extra check at runtime | 22:26 | |
codesections | I guess my point was that Raku lets you do something like sub infix:<+>(Int $a, MyType $b) {...} and have 1 + MyType.new work, which isn't true for languages where that'd call Int.infix_plus | 22:27 | |
But only if you're in the right scope to define _any_ infix:<+> | 22:28 | ||
moon-child | some languages will let you instead call MyType.opposite_size_infix_plus | ||
...but that's even worse, because you can have multiple candidates | |||
codesections | was that a typo for opposite_sides? | 22:29 | |
if not, I don't get it | |||
moon-child | yeah | ||
guifa | So I wonder | 22:32 | |
multi sub infix:<+>($a, $b) is dynamic { … } ? | |||
nope, doesn't work | 22:33 | ||
codesections | some of these solutions seem like they'd fit a lot better if we're talking about what gets called by the infix:<OPERATOR> in Mu. If there's an infix in the calling scope above that, it could still overide it lexically | ||
guifa | but dynamic is specifically called out as being unknown for subs. Maybe that could be enabled. After all, I can probably much more easily ensure a custom operator is in my call chain | 22:34 | |
codesections | What about ~ ? | 22:35 | |
moon-child | guifa: if you could do that optimization would suffer a lot | 22:36 | |
guifa | moon-child: yeah, no doubt | 22:44 | |
moon-child | thoughts on adding an is assoc<ambivalent> or similar? It would allow .race.reduce to work in parallel, as well as allowing for potentially better register allocation | 22:49 | |
codesections | hmm, the docs call out assoc<non> as illegal. Was this discussed before? | 22:51 | |
(I like the idea in general, though -- .race.reduce _should_ be able to work in parallel for associative ops) | 22:52 | ||
(and does in many languages) | |||
er, maybe assoc<non> was the opposite? Would this be more like assoc<yes> :D? | 22:53 | ||
moon-child | no assoc<non> is different. if O is assoc<non>, then a O b O c is illegal. if O is assoc<ambivalent>, then (a O b) O c is the same as a O (b O c) | ||
yeah | |||
codesections | ok, yeah, I like the idea and can't think of any immediate issues (though I'm hardly an expert in the related areas!) | 22:55 | |
m6locks | m: my $precision = 9; my $a = '%0' ~ $precision ~ 'd'; say $a.printf(35.base(2)).comb; | 22:56 | |
camelia | 000100011(T r u e) | ||
m6locks | m: my $precision = 9; my $a = '%0' ~ $precision ~ 'd'; say $a.printf(35.base(2)); | ||
camelia | 000100011True | ||
m6locks | where's the True coming from? | 22:57 | |
I'd just like to have leading zeros in a binary number | |||
moon-child | m: my $precision = 9; my $a = '%0' ~ $precision ~ 'd'; $a.printf(35.base(2)); | 22:58 | |
camelia | 000100011 | ||
moon-child | m: my $precision = 9; my $a = '%0' ~ $precision ~ 'd'; say $a.sprintf(35.base(2)); | ||
camelia | 000100011 | ||
codesections | you probably want sprintf: docs.raku.org/language/independent...ne_sprintf | ||
m6locks | ah, ok. thanks | ||
moon-child | ^^ two ways to do it | ||
22:58
japhb joined
|
|||
m6locks | yes, now it works | 22:59 | |
23:26
Xliff left
|
|||
SmokeMachine | Does anyone know where in Documentable it does test the =code snippets from the documentation? | 23:45 |