🦋 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.
00:00 reportable6 left 00:02 reportable6 joined 00:33 tankf33der left 01:04 razetime joined 01:18 ab5tract left 01:56 MasterDuke joined 02:00 swaggboi joined 02:09 rf left 02:14 rf joined 02:26 hh1488 joined 02:38 hh1488 left 03:38 reportable6 left, quotable6 left, bisectable6 left, benchable6 left, tellable6 left, coverable6 left, bloatable6 left, unicodable6 left, nativecallable6 left, linkable6 left, shareable6 left, statisfiable6 left, evalable6 left, notable6 left, squashable6 left, sourceable6 left, committable6 left, greppable6 left, releasable6 left, reportable6 joined, statisfiable6 joined 03:39 nativecallable6 joined, coverable6 joined, linkable6 joined, benchable6 joined, sourceable6 joined 03:40 committable6 joined, greppable6 joined, bisectable6 joined, unicodable6 joined, evalable6 joined, quotable6 joined 03:41 notable6 joined, tellable6 joined, squashable6 joined, releasable6 joined, shareable6 joined, bloatable6 joined 03:49 bigdata left 03:53 bigdata joined 03:58 rf left 04:13 razetime left 04:51 euandreh left 04:57 euandreh joined 05:17 razetime joined 05:30 jpn joined, bigdata left 05:34 jpn left
nemokosch In one situation people act like Raku is literally Rakudo, in another, the distinction is drawn carefully 05:49
05:53 siavash joined
If one looks at the state of the "standard", ecosystem modules, language versioning, it's clear that 1. the standard is very far from exhaustive 2. the ecosystem is full of content that would only ever work with Rakudo or MoarVM specifically 3. the versioning is used as a backup mechanism for continuously releasing backwards compatible Rakudo 05:54
06:00 reportable6 left 06:01 reportable6 joined 06:05 HobGoblin joined 06:06 siavash left, rantanplan joined 06:07 samcv_ joined 06:08 siavash joined 06:12 heartburn left, samcv left, timo left, goblin left, thebb left, snonux left, rjbs left, spacekookie left, skaji_ left, pjlsergeant__ left 06:17 spacekookie joined, skaji_ joined 06:18 thebb joined 06:19 timo joined 06:21 heartburn joined 06:31 pjlsergeant__ joined 06:32 rjbs joined 06:55 jpn joined 07:01 jpn left 07:12 jpn joined
lizmat weekly: news.ycombinator.com/item?id=37040681#37041705 07:15
notable6 lizmat, Noted! (weekly)
07:18 Sgeo left 07:19 jpn left 07:23 jpn joined
nemokosch this is a good example actually. There is no reason why the default behavior couldn't be negotiated - except the lack of compatibility policy of Rakudo... 07:24
07:31 jpn left
same forum, labelling Go as neither readable, nor expressive made my day :DD 07:33
07:36 jpn joined 07:41 jpn left
> When I was looking at the language, I didn't find the documentation "really poor". In fact I was impressed at how much of a one-stop-shop the official docs site was for both conceptual docs and API docs. okay, I think it was only fair that this opinion also popped up 07:42
there are many based takes in that thread 07:45
07:57 jpn joined 08:04 jpn left 08:10 dakkar joined 08:14 teatime left 08:15 teatime joined 08:16 teatwo joined 08:19 teatime left
SmokeMachine m: say (rand xx 10).min: :k 08:25
camelia 0.10457051696021624
SmokeMachine should we have adverbs on .min and .max?
lizmat possibly
it wouldn't make sense for Seq.min|max 08:26
*much
SmokeMachine m: my @a = rand xx 10; say @a.min: :k
camelia 0.22860281190188647
SmokeMachine lizmat: maybe not, but for Positional? 08:27
lizmat sure...
08:49 siavash left
nemokosch There is an issue for it I think 08:57
github.com/Raku/problem-solving/issues/367 09:01
09:14 abraxxa joined 09:17 jpn joined 09:19 jmcgnh left 09:32 jmcgnh joined 09:36 jpn left 09:45 jpn joined 09:52 sftp left, a3r0 left, tbrowder__ left, gordonfish left, avar left, tib_ left, BinGOs left, rba left, dpk left, leont left, bd3i left
SmokeMachine m: say given 13 { 42 } # Is this a LTA error message? should it suggest say do given 13 { 42 } ? 09:56
camelia ===SORRY!=== Error while compiling <tmp>
Unsupported use of bare "say". In Raku please use: .say if you meant
to call it as a method on $_, or use an explicit invocant or argument,
or use &say to refer to the function as a noun.
at <tmp…
10:04 sftp joined, a3r0 joined, tbrowder__ joined, gordonfish joined, avar joined, tib joined, BinGOs joined, rba joined, dpk joined, leont joined, bd3i joined 10:14 razetime left 10:30 razetime joined
lizmat m: .say given 13 { 42 } 10:40
camelia ===SORRY!=== Error while compiling <tmp>
Unexpected block in infix position (missing statement control word before the expression?)
at <tmp>:1
------> .say given 13⏏ { 42 }
expecting any of:
infix
infix s…
lizmat hmmm
nemokosch Legit 10:41
The surprise is rather that the error message changed, i.e the say took precedence over the mere syntax 10:42
10:50 abraxxa left 11:32 abraxxa joined 12:00 reportable6 left 12:01 euandreh left, reportable6 joined
lizmat clickbaits rakudoweekly.blog/2023/08/07/2023-...doc-gamma/ 12:03
12:07 jpn_ joined 12:08 jpn left, squashable6 left 12:11 squashable6 joined 12:12 jpn_ left
lizmat SmokeMachine: with regards to .min :k what's wrong with minpairs? 12:22
m: dd <a b a c a d>.minpairs
camelia (0 => "a", 2 => "a", 4 => "a").Seq
SmokeMachine lizmat: my lack of knowledge about that... :) 12:23
nemokosch anyway, what's wrong with min :k ?
SmokeMachine lizmat: but probably, if .min had :p that wouldn't need to exist... 12:24
lizmat yeah, but then we get to the semantics: what if there's more than one min / max ?
12:24 ab5tract joined
lizmat I think that's better covered in the name this way 12:25
(with the s at the end)
nemokosch that should be an orthogonal manner tbh
even different values can compare equal 12:26
so it's kind of hackish to assume the only reason you want all minimums is to get the key
at the end of the day, minpairs wouldn't be needed if min had a :k and an :a(ll) flag 12:28
SmokeMachine :s? (as for plural) .min: :s (mins) 12:30
nemokosch the three hard problems in IT 12:31
12:31 samebchase left
SmokeMachine it's not global, but it would be kind of consistent with regex it it was :g (just wondering...) 12:32
12:32 samebchase joined
drakonis lizmat: that url points to moonchild's comment 12:32
lizmat drakonis: which URL ?
drakonis news.ycombinator.com/item?id=37040681#37041705 this one
which you added to the weekly blog post tracker 12:33
lizmat aaah... ok:
weekly: news.ycombinator.com/item?id=37040681
notable6 lizmat, Noted! (weekly)
lizmat drakonis++
drakonis i see
there it is
12:43 ab5tract left 12:44 jpn joined 12:55 jpn left
nemokosch Perl seems to have a great record of "popcorn grabber" moments in the community lmfao 12:58
lizmat it was less fun on stage
nemokosch I wonder if drama is mandatory in open-source communities
12:58 jpn joined
lizmat I hope it isn't 12:59
teatwo drama is mandatory in communities
lizmat but it definitely appears to be customary
drakonis what is this about?
teatwo you just do the best you can, I think Perl community is waaay above average 13:00
also you can't do big, impactful work w/o upsetting some people
nemokosch I was thinking that in a corporatist setup it's simply not affordable, it explodes quicker in case 13:01
tbrowder__ hi, i just saw an article about 'cython' on Code Project and thought about our NativeCall. It would be a giant Raku selling point if App::GPTrixie could be enhanced to handle the latest standard C and C++ open source compilers. it would be nice if someone with the chops and time could apply for a grant to do that. 13:07
13:14 razetime left, razetime_ joined
lizmat nemokosch I'm pretty sure the RHS of ~~ is not thunky, where did you get that idea from? 13:18
nemokosch well, how do I illustrate this, other than "trust me bro" 13:21
anyway, it needs to be thunky, if you think about it. The topic of the RHS is set to the value coming from the LHS, BUT for nothing else 13:22
Do you see any other way to do that?
13:24 tankf33der joined
lizmat thing is that if you see how ~~ is QASTed, it is just a call to &infix:<~~> with two arguments (by value) 13:24
nemokosch m: my $result = 1 ~~ say($ + $); dd $result 13:25
Raku eval 2 Bool $result = Bool::True
nemokosch that's just not what the behavior is like
lizmat smartmatch against True always matches and say returns True 13:26
nemokosch yes, that's not the thing. The thing is that by the time say ran, it knew that the topic needs to be 1 13:27
in other words, the left handside was evaluated and was already passed into the right handside
13:28 Ven_de_Thiel joined
m: my $result = &infix:<~~>(1, say($ + $)); dd $result 13:28
Raku eval 0 Use of uninitialized value of type Any in numeric context in block <unit> at main.raku line 1 Use of uninitialized value of type Any in numeric context in block <unit> at main.raku line 1 Bool $result = Bool::True
nemokosch that's not something a normal subroutine call could achieve
lizmat m: my $result = 1 ~~ say($ + $); dd $result 13:32
camelia Use of uninitialized value of type Any in numeric context
0
in block <unit> at <tmp> line 1
Use of uninitialized value of type Any in numeric context
in block <unit> at <tmp> line 1
Bool $result = Bool::True
lizmat I wonder why the Raku eval bot produces a different result
nemokosch oh damn 13:33
the question is, what did you see?
lizmat <Raku eval> 2 Bool $result = Bool::True
nemokosch yeah that part was okay, I mean the code
because mine was $_ + $_
lizmat my $result = 1 ~~ say($ + $); dd $result
evalable6 Use of uninitialized value of type Any in numer…
lizmat, Full output: gist.github.com/321cdc5bbe70f6d61d...958264ec37
nemokosch I thought the markdown was only a client-side hackery but then apparently it doesn't carry through the bridge at all?? 13:34
13:34 NemokoschKiwi joined
NemokoschKiwi  my $result = 1 ~~ say($_ + $_); dd $result 13:35
evalable6 2
Bool $result = Bool::True
lizmat ok that makes more sense and is indeed intriguing
NemokoschKiwi m: my $result = &infix:<~~>(1, say($_ + $_)); dd $result
camelia Use of uninitialized value of type Any in numeric context
0
in block <unit> at <tmp> line 1
Use of uninitialized value of type Any in numeric context
in block <unit> at <tmp> line 1
Bool $result = Bool::True
nemokosch $ test $
NemokoschKiwi pfft
lizmat looking at the QAST it is indeed doing some trickery with $_ 13:36
NemokoschKiwi I wonder how the bot works that markdown there is markdown here xd
**asd**
yeah, it's not raw string
13:36 NemokoschKiwi left
lizmat TIL :-) 13:37
nemokosch so yeah ^^ part of the reason ~~ m/.../ seems so antagonistic
it actually makes the match call as the thunky part, AND THEN matches to the returned match object
this is why smartmatching of Match objects needs to be the RHS itself 😢 13:38
lizmat looks like
nemokosch and this is why one of my "Christmas wishes" for RakuAST is to have a syntactic transformation for ~~ m/../ and the likes 13:39
so that they indeed just call .match, .subst and so on, acknowledging that they are special cases 13:40
13:43 xinming left 13:45 xinming joined
this is one of the few cases where it's relatively simple to propose a solution that "saves the code", rather than "this shouldn't ever be tried, case closed" 13:47
14:01 jagtalon joined
antononcube Somebody has been pushing lots of P5* modules in raku.land — that might be an usurping assault attempt!!! 14:11
lizmat antononcube that would be me, and they're old
antononcube Never mind, it is Liz…
@lizmat Good luck! 🙂 14:12
lizmat antononcube I realized yesterday that a small change in these modules, would make it possible for $_ to not have to be marked as "dynamic" anymore
which makes it *much* better optimizable
antononcube Do you mean “across all Raku”, or “just” the Perl5 sub-parts. 14:13
lizmat all across Raku
these P5xxx modules where basically blocking that]
antononcube Wow! I assume (maybe wrongly) that epiphany is a byproduct of the articles you wrote on Perl5->Raku syntax ? 14:15
lizmat no, vrurg was responsible for that
the articles had been mostly written already about 2.5 years ago 14:16
Ven_de_Thiel I guess that breaks the filemode operators?
lizmat Ven_de_Thiel ?? P5-X you mean, or the Raku ones ?
Ven_de_Thiel P5-X 14:17
lizmat nope, it doesn't
vrurg_ lizmat: responsible for what?
14:17 vrurg_ is now known as vrurg
antononcube @lizmat Agh, ok. 😉 14:17
lizmat instead of CALLERS::<$_> it now uses CALLER::LEXICAL::<$_>
Ven_de_Thiel ah :) 14:18
lizmat vrurg realizing ^^
antononcube @lizmat “these P5xxx modules where basically blocking that]“ — That might be a subject of another interesting/instructive article.
vrurg Ah, OK. :)
vrurg was worried that something needs fixing.
lizmat m: sub a() { dd CALLER::LEXICAL::<$a> }; my $a = 42; a
camelia Int $a = 42
lizmat the $a is *not* marked as dynamic 14:19
antononcube @vrurg I was trying to raise a fake “Perl5 is coming” alarm because of too much coffee.
nemokosch it isn't marked as dynamic, indeed. But what does this change about how it works? 14:20
Ven_de_Thiel it means you don't need a dynamic $_ to use that behavior
lizmat what Ven_de_Thiel said :-)
nemokosch what does that mean in practice, though?
lizmat CALLERS::<$_> requires t to be dynamic
antononcube Which means faster or safer code?
nemokosch why is this CALLER::LEXICAL:: lookup better than the one before? 14:21
lizmat it's better because it doesn't require the looked up thing to be marked as dynamic
m: sub a() { dd CALLERS::<$a> }; my $a = 42; a
camelia Int $a = 42
lizmat hmmm
that is... huh?
m: sub a() { dd CALLERS::<$_> }; my $a = 42; a 14:22
camelia Any $_ = Any
nemokosch surprising surprises
lizmat indeed
vrurg lizmat: The problem is that CALLERS:: won't see $a in the immediate caller lexical scope.
Ven_de_Thiel m: sub a() { dd CALLERS::<$_> }; a with 42 14:24
camelia Rakudo::Internals::LoweredAwayLexical
Ven_de_Thiel meh
14:24 Ven_de_Thiel left
nemokosch hah, I just came across your name in some historical module repo 14:26
like an hour ago or so
14:29 Ven_de_Thiel joined
Ven_de_Thiel m: sub a() { dd CALLERS::<$_> }; a with 42 14:29
camelia Rakudo::Internals::LoweredAwayLexical
Ven_de_Thiel lol
lizmat I'm wondering if some optimization somewhere knows it can get away with lowering $_ 14:30
m: sub a() { dd CALLERS::<$_> }; $_; a with 42 14:31
camelia WARNINGS for <tmp>:
Useless use of $_ in sink context (line 1)
Rakudo::Internals::LoweredAwayLexical
lizmat m: sub a() { dd CALLERS::<$_> }; .say; a with 42
camelia (Any)
Rakudo::Internals::LoweredAwayLexical
lizmat hmmm
vrurg Ven_de_Thiel: $_ gets optimized away because it is not used in a lexical scope other than where it's declared. CALLERS::<$_> is a dynamic operation and the optimizer can't be aware of it.
m: sub a() { dd CALLERS::<$_> }; with 42 { .say; a } 14:32
camelia 42
Rakudo::Internals::LoweredAwayLexical
vrurg m: sub a() { dd CALLERS::<$_> }; with 42 { if True { .say; }; a }
camelia 42
Rakudo::Internals::LoweredAwayLexical
lizmat have we found a problem? 14:33
14:33 Xliff joined
vrurg It's not easy to convince the optimizer it shouldn't do it because it does its best to lower lexicals. 14:33
lizmat: it depends. Because the only solution would be to disable lowering of the topic. 14:34
I'd rather be for a way to explicitly disable lowering when it's necessary. 14:35
lizmat it was my understanding of the way I implemented the P5xxx modules inhibited the lowering of $_
vrurg m: sub a() { dd CALLERS::<$_> }; with 42 { if .rand > 0 { .say; }; a }
camelia 42
Rakudo::Internals::LoweredAwayLexical
vrurg m: sub a() { dd CALLERS::<$_> }; with 42 { if .rand > 0 { say $_; }; a }
camelia 42
Rakudo::Internals::LoweredAwayLexical
lizmat perhaps we need to take this to #raku-dev :-) 14:36
14:36 Ven_de_Thiel38 joined
vrurg Moving over there. 14:37
14:37 rf joined, Ven_de_Thiel left 14:44 tankf33der left 15:12 Ven_de_Thiel38 left
lizmat weekly: lobste.rs/s/x5impj/raku_language_for_gremlins 15:26
notable6 lizmat, Noted! (weekly)
15:27 rir joined 15:30 abraxxa left
rir news.ycombinator.com/item?id=37040681 focuses on Raku the idea of judging languages on delightful/horrifing and surprising/unsurprising x/y quadrants. 15:32
^focuses on Raku with...
lizmat rir: yeah we've been discussing it here :-) 15:33
notable6 weekly 15:34
notable6: weekly
notable6 lizmat, 3 notes: gist.github.com/4bbd2941d41ae5f69e...e679ab52fc
lizmat notable6: weekly reset
notable6 lizmat, Moved existing notes to “weekly_2023-08-08T15:34:26Z”
lizmat weekly: news.ycombinator.com/item?id=37040681
notable6 lizmat, Noted! (weekly)
lizmat weekly: lobste.rs/s/x5impj/raku_language_for_gremlins
notable6 lizmat, Noted! (weekly)
lizmat notable6: weekly reset
notable6 lizmat, Moved existing notes to “weekly_2023-08-08T15:34:52Z”
lizmat weekly: news.ycombinator.com/item?id=37040681
notable6 lizmat, Noted! (weekly)
lizmat weekly: lobste.rs/s/x5impj/raku_language_for_gremlins
notable6 lizmat, Noted! (weekly)
lizmat notable6: weekly 15:35
notable6 lizmat, 2 notes: 2023-08-08T15:34:57Z <lizmat>: news.ycombinator.com/item?id=37040681 ; 2023-08-08T15:34:59Z <lizmat>: lobste.rs/s/x5impj/raku_language_for_gremlins
lizmat there's nothing you can do against doing the wrong thing :-)
15:40 Ven_de_Thiel joined
librasteve since @hillel wants raku as a calculator, I thought I'd make one for him - App::Ralc is born 15:44
ralc 'say (1.6km / (60 * 60 * 1s)).in: <mph>' #0.994194mph
and so on...
Xliff m: role A { has $!invocant; $!invocant = self }; class A { }; my $a = A.new; $a = $a but A;
camelia ===SORRY!=== Error while compiling <tmp>
Variable $!invocant used where no 'self' is available
at <tmp>:1
------> role A { has $!invocant; $!invocant⏏ = self }; class A { }; my $a = A.new; $
Xliff m: role A { has $!invocant; submethod COMPOSE { $!invocant = self } }; class A { }; my $a = A.new; $a = $a but A; 15:45
camelia ===SORRY!=== Error while compiling <tmp>
Redeclaration of symbol 'A'.
at <tmp>:1
------> COMPOSE { $!invocant = self } }; class A⏏ { }; my $a = A.new; $a = $a but A;
expecting any of:
generic role
Xliff m: role A { has $!invocant; submethod COMPOSE { $!invocant = self } }; class B { }; my $a = B.new; $a = $a but A;
camelia ( no output )
Xliff m: role A { has $!invocant; submethod COMPOSE { say "Y"; $!invocant = self } }; class B { }; my $a = B.new; $a = $a but A; 15:46
camelia ( no output )
Xliff m: role A { has $!invocant; submethod COMPOSE { say "Y"; $!invocant = self.compute-from-object } }; class B { method compute-from-object { DateTime.now }; }; my $a = B.new; $a = $a but A;
camelia ( no output )
Xliff m: role A { has $!invocant; submethod COMPOSE { say "Y"; $!invocant = self } method i { $!invocant.say } }; class B { }; my $a = B.new; $a = $a but A;; $a.i 15:47
camelia ===SORRY!=== Error while compiling <tmp>
Strange text after block (missing semicolon or comma?)
at <tmp>:1
------> d COMPOSE { say "Y"; $!invocant = self }⏏ method i { $!invocant.say } }; class B
expecting any of:
Xliff m: role A { has $!invocant; submethod COMPOSE { say "Y"; $!invocant = self.compute-from-object }; method i { $!invocant.say } }; class B { method compute-from-object { DateTime.now }; }; my $a = B.new; $a = $a but A; $a.i
camelia (Any)
Xliff What is the best way to set role attributes from the object when the role is mixed in? 15:48
vrurg: ^^ Does this explain why I want COMPOSE any better? Or maybe a better submethod name would be MIXIN?
lizmat you can't: when the role is mixed in, it hasn't been instantiated yet
so there are no attributes to assign 15:49
Xliff lizmat
lizmat Xliff
Xliff lizmat: Is this something that would be difficult to add? 15:50
lizmat yes, because at the time a role is mixed in, there is no instantiated object yet
Xliff So "$a = $a but A" is done at compile time.
And there's no mechanism that tells A it needs something from $a? 15:51
lizmat no it isn't
Xliff I always thought "but" was more of a runtime thing.
lizmat but is an infix op
Xliff So I would want a custom infix op, then? 15:52
lizmat ah, ok, misread / missynced
that would be possible, in macro land
Xliff RakuAST, then?
lizmat well, yes, potentially 15:53
you could try with a macro right now...
Xliff It seems to me if I have things I want abstracted into a role, then this is something that a Role should be able to accomplish. 15:54
Or maybe I am going about it wrong?
It seems that "$a = $a but A" might be a good place for a PHASER. 15:55
lizmat well, I'm not 100% what you're trying to achieve 15:56
"What is the best way to set role attributes from the object when the role is mixed in?"
Xliff Yes.
m: role A { has $!invocant; submethod COMPOSE { say "Y"; method setInvocant { $!invocant = self.compute-from-object }; }; method i { $!invocant.say } }; class B { method compute-from-object { DateTime.now }; }; my $a = B.new; $a = $a but A; $a.setInvocant; $a.i 15:57
camelia P6opaque: no such attribute '$!invocant' on type $?CLASS in a B+{A} mixin when trying to get a value
in method setInvocant at <tmp> line 1
in block <unit> at <tmp> line 1
Xliff m: role A { has $!invocant; method setInvocant { $!invocant = self.compute-from-object }; }; method i { $!invocant.say } }; class B { method compute-from-object { DateTime.now }; }; my $a = B.new; $a = $a but A; $a.setInvocant; $a.i 15:58
camelia ===SORRY!=== Error while compiling <tmp>
Cannot understand $!invocant in this context
at <tmp>:1
------> -from-object }; }; method i { $!invocant⏏.say } }; class B { method compute-from-
Xliff m: role A { has $!invocant; method setInvocant { $!invocant = self.compute-from-object }; method i { $!invocant.say } }; class B { method compute-from-object { DateTime.now }; }; my $a = B.new; $a = $a but A; $a.setInvocant; $a.i
camelia 2023-08-08T17:58:14.541465+02:00
Xliff I guess something like that might work, but it's clumsy.
15:59 jpn left
lizmat nothing comes to mind atm 16:03
Xliff OK, thanks. 16:05
m: multi sub infix:<mybut> (Mu $a is rw, Mu \R) { $a = $a but R; $a.MIXEDIN }; role A { has $!invocant; method MIXEDIN { $!invocant = self.compute-from-object }; method i { $!invocant.say } }; class B { method compute-from-object { DateTime.now }; }; my $a = B.new; $a = $a mybut A; $a.i 16:07
camelia No such method 'i' for invocant of type 'DateTime'. Did you mean 'IO'?
in block <unit> at <tmp> line 1
Xliff m: multi sub infix:<mybut> (Mu $a is rw, Mu \R) { $a = $a but R; $a.MIXEDIN; $a }; role A { has $!invocant; method MIXEDIN { $!invocant = self.compute-from-object }; method i { $!invocant.say } }; class B { method compute-from-object { DateTime.now }; }; my $a = B.new; $a = $a mybut A; $a.i
camelia 2023-08-08T18:07:50.034902+02:00
lizmat the closest thing I can think of is an attribute on a TWEAK method in the role that would cause the calling of TWEAK to be done
Xliff lizmat: ^^ something like that, maybe. 16:08
lizmat after any TWEAK method in the class has done
so that a TWEAK method in the class does *not* override the one from the role
Xliff lizmat: Will that work if the instance has alreayd been instantiated?
lizmat no, because than TWEAK will have run already ?
Xliff Exactly. That's not what I want. 16:09
See previous camelia run.
lizmat more exactly: the BUILDPLAN has been executed
feels complicated ?
Xliff That's pretty much what I need, but now all of the roles I would use would need to standardize on MIXEDIN, which I cannot guarantee. 16:10
It's no more complicated than a TWEAK hack that's not guaranteed to run.
So... custom infix with standardized method call for now.
Thanks for the help. 16:11
lizmat m: role B { method TWEAK(|) { dd "role" } }; class A { }; dd A.new but B
camelia "role"
A+{B}.new
lizmat m: role B { method TWEAK(|) { dd "role" } }; class A { method TWEAK(|) { dd "class" } }; dd A.new but B
camelia "class"
"role"
A+{B}.new
Xliff role B { method TWEAK(|) { dd "role" } }; class A { }; my ($a, $b) = A.new xx 2; $a but B; $b but B
evalable6 "role"
"role"
Xliff Hmmm... maybe that does work. 16:12
m: role A { has $!invocant; submethod TWEAK { $!invocant = self.compute-from-object }; method i { $!invocant.say } }; class B { method compute-from-object { DateTime.now }; }; my $a = B.new; $a = $a mybut A; $a.i
camelia ===SORRY!=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> ateTime.now }; }; my $a = B.new; $a = $a⏏ mybut A; $a.i
expecting any of:
infix
infix stopper
statement end
Xliff m: role A { has $!invocant; submethod TWEAK { $!invocant = self.compute-from-object }; method i { $!invocant.say } }; class B { method compute-from-object { DateTime.now }; }; my $a = B.new; $a = $a but A; $a.i 16:13
camelia 2023-08-08T18:13:04.137395+02:00
Xliff \o/
lizmat *phew* :-)
Xliff :-)
m: role A { has $!invocant; submethod TWEAK { $!invocant = self.compute-from-object }; class C does A { submethod TWEAK { say "BOO!" }; method compute-from-object{ say "BAH!" }; }; method i { $!invocant.say } }; class B { method compute-from-object { DateTime.now }; }; my $a = B.new; $a = $a but A; $a.i; C.new 16:18
camelia ===SORRY!=== Error while compiling <tmp>
Cannot declare our-scoped class inside of a role
(the scope inside of a role is generic, so there is no unambiguous
package to install the symbol in)
at <tmp>:1
------> lf.compute-from-object …
Xliff m: role A { has $!invocant; submethod TWEAK { $!invocant = self.compute-from-object }; method i { $!invocant.say } }; class C does A { submethod TWEAK { say "BOO!" }; method compute-from-object{ say "BAH!" }; }; class B { method compute-from-object { DateTime.now }; }; my $a = B.new; $a = $a but A; $a.i; C.new
camelia 2023-08-08T18:18:51.670299+02:00
BOO!
Xliff m: role A { has $!invocant; submethod TWEAK { $!invocant = self.compute-from-object; nextsame }; method i { $!invocant.say } }; class C does A { submethod TWEAK { say "BOO!" }; method compute-from-object{ say "BAH!" }; }; class B { method compute-from-object { DateTime.now }; }; my $a = B.new; $a = $a but A; $a.i; C.new 16:19
camelia 2023-08-08T18:19:00.305001+02:00
BOO!
Xliff m: role A { has $!invocant; submethod TWEAK { $!invocant = self.compute-from-object; }; method i { $!invocant.say } }; class C does A { submethod TWEAK { say "BOO!"; nextsame }; method compute-from-object{ say "BAH!" }; }; class B { method compute-from-object { DateTime.now }; }; my $a = B.new; $a = $a but A; $a.i; C.new
camelia 2023-08-08T18:19:40.527956+02:00
BOO!
Xliff Hmmm... so overloaded TWEAK does not work. 16:20
m: role A { has $!invocant; submethod TWEAK { $!invocant = self.compute-from-object; }; method i { $!invocant.say } }; class C does A { submethod TWEAK { say "BOO!"; nextsame }; method compute-from-object{ say "BAH!" }; }; class B { method compute-from-object { DateTime.now }; }; my $a = B.new; $a = $a but A; $a.i; C.new.i
camelia 2023-08-08T18:20:32.665734+02:00
BOO!
(Any)
Xliff m: role A { has $!invocant; submethod TWEAK { $!invocant = self.compute-from-object; }; method i { $!invocant.say } }; class C does A { submethod TWEAK { say "BOO!"; nextsame }; method compute-from-object{ "BAH!" }; }; class B { method compute-from-object { DateTime.now }; }; my $a = B.new; $a = $a but A; $a.i; C.new.i
camelia 2023-08-08T18:20:45.928285+02:00
BOO!
(Any)
Xliff m: role A { has $!invocant; submethod TWEAK { $!invocant = self.compute-from-object; }; method i { $!invocant.say } }; class C does A { submethod TWEAK { say "BOO!"; self::A::TWEAK }; method compute-from-object{ "BAH!" }; }; class B { method compute-from-object { DateTime.now }; }; my $a = B.new; $a = $a but A; $a.i; C.new.i 16:21
camelia 2023-08-08T18:21:38.129613+02:00
Could not find symbol '&TWEAK' in 'GLOBAL::self::A'
in submethod TWEAK at <tmp> line 1
in block <unit> at <tmp> line 1

BOO!
Xliff m: role A { has $!invocant; submethod TWEAK { $!invocant = self.compute-from-object; }; method i { $!invocant.say } }; class C does A { submethod TWEAK { say "BOO!"; self.::A::TWEAK }; method compute-from-object{ "BAH!" }; }; class B { method compute-from-object { DateTime.now }; }; my $a = B.new; $a = $a but A; $a.i; C.new.i 16:22
camelia 2023-08-08T18:22:07.590035+02:00
BOO!
BAH!
Xliff And there's the workaround.
16:38 dakkar left
librasteve hmmm I just rtfm and tested --- seems like the numerator of a Rat is unlimited --- I believe a better default would be to limit the numerator to 2128-1 (anyway the denominator is limited to 264) 17:05
lizmat librasteve could you elaborate on that in an issue ? 17:07
librasteve why ... well we have both Int and FatRat that are "infinite" precision and I think that for the average coder that usually anything that results in a number bigger than 2 ^ 128-1 is either a very large Real (in which case it should be in a Num) or an error in which case, there should be an (optional) warn or error 17:08
yeah - just an issue in rakudo ok?
17:09 Ven_de_Thiel left, Ven_de_Thiel joined
lizmat yes please :- ) 17:11
librasteve github.com/rakudo/rakudo/issues/5335 17:19
17:22 razetime_ left 17:23 Xliff left 17:30 jpn joined 17:31 rf left 17:37 jpn left
nemokosch What makes this a good idea, though? 17:38
18:00 reportable6 left 18:02 Ven_de_Thiel left, reportable6 joined
librasteve fair question - and it does apply a limit to the current Rat size - but one principle here is that if a type gracefully UNDERFLOWs then it should also OVERFLOW in the same size region 18:17
after all we have FatRats to give us "unlimited" precision (although I am not a fan of unlimited precision)
18:18 Ven_de_Thiel joined
do you agree with the principle that Ints, Rats, Nums and Complex should share the same unified Numeric space? 18:19
(and FatRats)
18:19 tankf33der joined 18:39 Ven_de_Thiel left
design.raku.org/S02.html#Numeric_Types line_810 ... looks like I am asking for a Rat64 ... I have closed the issue for now since this was considered and decided a long time ago 18:40
18:42 Tirifto left 18:43 Tirifto joined
vrurg Xliff: I don't have time to read it all through, but in 6.e TWEAK is absolutely legal way to achieve your goal. 18:45
tellable6 vrurg, I'll pass your message to Xliff
19:02 ab5tract joined 19:15 Ven_de_Thiel joined 19:18 ab5tract left 19:32 Ven_de_Thiel left 19:33 jpn joined 19:50 jpn left 20:16 teatwo left, teatwo joined 20:21 tea3po joined 20:23 tea3po left 20:24 tea3po joined, teatwo left 20:35 jpn joined 20:48 Ven_de_Thiel joined 21:25 ab5tract joined 21:30 kst joined 21:53 jpn left 22:02 Ven_de_Thiel left 22:11 ab5tract left 22:49 jpn joined
nemokosch okay, I learned it the hard way that this HackerNews has a funny idea about what "posting too fast" means 22:52
I don't know, maybe 5 messages in 15 minutes? Now I wonder how much of a cooldown somebody has to bear for this crime 22:53
22:54 jpn left 22:56 ab5tract joined
guifa TIL 22:57
in perl you can reference named regexen internally 22:59
but I don't think we have an equivalent in Raku do we?
something akin to / $<hex>=<[0..9a..z]> '-' <hex> ** 3/ which would match any four hex digits with a dash between the first two 23:01
23:01 rir_ joined 23:02 rir left
guifa m: say '0-a4f' ~~ / $<hex>=<[0..9a..z]> '-' &<hex> ** 3/; 23:02
camelia Nil
guifa m: say '0-a4f' ~~ / $<hex>=<[0..9a..z]> '-' <hex> ** 3/; 23:03
camelia No such method 'hex' for invocant of type 'Match'
in block <unit> at <tmp> line 1
23:08 ab5tract left
guifa is there any way to do that without a complicated workaround? 23:16
I guess I could do /:my $hex = /<[0..9a..z]>/; $hex '-' $hex ** 3/; to keep things simple but feels like &<hex> or even &hex should work 23:18
23:19 rf joined 23:23 Sgeo joined 23:29 rf left
nemokosch isn't it enough to just define a regex and then use it in the other regex? 23:38
guifa I mean, probably. But if it's a one for that regex 23:40
nemokosch disclaimer, there is still a non-negligible chance that there is something we just don't know about, this is Raku, after all 23:51
guifa yeah
nemokosch but at the same time, this desperately seems like something that would just be a weird flex nobody actually demands
my regex hex { ... } and then using <hex> is really just fine 23:52
guifa I mean, it has been Perl regex for quite sometime (albeit slightly different syntax, but basically the idea of one sequence is match the stringy result of a named match, and the other is used the regex code of the named match). I haven't gone through all major engines yet but I imagine it's not the only one 23:58
23:59 wayland joined