🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). This channel is logged for the purpose of keeping a history about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | Log inspection is getting closer to beta. If you're a beginner, you can also check out the #raku-beginner channel! Set by lizmat on 25 August 2021. |
|||
00:07
reportable6 left
00:08
reportable6 joined
00:26
dextercd left
|
|||
stevied | anyone know offhand how I can figure out which version of vim started supporting "raku" for the filetype? | 00:26 | |
actually, more specifically, when they dropped support for perl6 fitetypes | 00:30 | ||
Nemokosch | what does it mean that it's supported? 👀 | ||
stevied | well, here's the issue: | 00:31 | |
github.com/kbucheli/p6-Text-VimCol...m_colour.t | 00:32 | ||
test 7 fails with the newest versions of vim | |||
if I change it to raku, it works with newer versions | |||
so need to figure out when to set it to perl6 for ancient versions of vim and when to set it to raku for newer versions of vim | 00:33 | ||
sorry, test 4 fails | 00:34 | ||
tests pass with version 8.2.3489 but fail with 8.2.4100 | 00:36 | ||
00:36
andrea[m] left
|
|||
I guess easiest thing to do is use perl6 for all versions up to 3489 and raku for all versions after | 00:36 | ||
00:39
aitron left,
aitron joined,
Manifest0 left
00:40
Manifest0 joined
|
|||
but it doesn't seem easy to get at patch version | 00:40 | ||
8.1 was released in 2018, before raku came out. so I can't use that | |||
00:55
andrea[m] joined
01:38
timo left
01:50
hasrthur joined
01:54
hasrthur left
01:55
frost joined
02:06
BinGOs left,
bingos joined
|
|||
[Coke] | Do you need to pass things that are so old they don't support raku ? | 02:09 | |
(Seems like just changing it to 'raku' is a good first pass) | 02:10 | ||
02:34
frost left
02:37
frost joined
03:37
coverable6 left,
unicodable6 left,
evalable6 left,
greppable6 left,
benchable6 left,
bisectable6 left,
statisfiable6 left,
tellable6 left,
committable6 left,
nativecallable6 left,
shareable6 left,
quotable6 left,
sourceable6 left,
notable6 left,
releasable6 left,
linkable6 left,
reportable6 left,
bloatable6 left,
squashable6 left
03:38
greppable6 joined,
bloatable6 joined,
statisfiable6 joined
03:39
releasable6 joined,
notable6 joined,
nativecallable6 joined,
unicodable6 joined,
committable6 joined,
quotable6 joined,
shareable6 joined
03:40
sourceable6 joined,
benchable6 joined,
squashable6 joined
03:53
andinus joined
04:28
D5n9sMatrix joined
|
|||
D5n9sMatrix | Hi all | 04:29 | |
04:31
frost left
|
|||
D5n9sMatrix | develop my project "ably" used language ["Perl6", "Erlang", "Octave", "Gambas"] any your my help ? | 04:32 | |
#raku one pivoting | 04:34 | ||
04:39
linkable6 joined,
bisectable6 joined
|
|||
D5n9sMatrix | sub pivoting($U11, $L21) { my $self = [Coke]+$U11|$L21; } #expression Intel Core | 04:40 | |
create one File in Folder /develop/ -> | 04:54 | ||
# pivtos solver verify the elements | |||
sub pivots($Ut12, $Coke){ | |||
# reflect arguments silent | |||
my $self = @[$Coke]; | |||
my $sys = Array.x[$Ut12]; | |||
# type of speech voice commands | |||
say "look pivots to solver the elements" if $self.x; | |||
say "look the resolution verify", if $sys.x; | |||
return $self; # running path car silent | |||
} | |||
04:56
aitron left
04:59
aitron joined
05:00
aitron left
|
|||
D5n9sMatrix | # pivtos solver verify the elements | 05:01 | |
sub pivots($Ut12, $Coke){ | |||
# reflect arguments silent | |||
my $self = @[$Coke]; | |||
my $sys = Array.x[$Ut12]; | |||
# type of speech voice commands | |||
say "look pivots to solver the elements" if $self.x; | |||
say "look the resolution verify", if $sys.x; | |||
return $sys.x[$Ut12[" aitron has left (Read error: Connection reset by peer)"]]; | |||
return $self; # running path car silent | |||
} | |||
move change return to access true connection aitron ... | 05:03 | ||
05:08
aitron joined
|
|||
D5n9sMatrix | create solver problems /develop/ -> | 05:14 | |
# k + 1 relfect ah-ha! | |||
sub L21($k + 1){ | |||
my $self = @[$k+1]; | |||
my $detail = &[$k.x[5.5]]; | |||
my $solver = m/$k/; | |||
say "look detail solver problems", if $self.x; | |||
say "verify the detail of elements", if $detail.x; | |||
say "problems resolver" if $solver.x; | |||
return $self.x; | |||
} | |||
solved here -> | 05:16 | ||
# k + 1 relfect ah-ha! | |||
sub L21($k){ | |||
my $self = @[$k+1]; | |||
my $detail = $k.x[5.5]; | |||
my $solver = m/$k/; | |||
say "look detail solver problems", if $self.x; | |||
say "verify the detail of elements", if $detail.x; | |||
say "problems resolver" if $solver.x; | |||
return $self.x; | |||
} | |||
#raku Rook Pivoting | 05:17 | ||
#raku 3.4.7 Rook Pivoting | 05:18 | ||
Lu pivoting reference of points in what verify the elements -> | 05:34 | ||
# Lu pivoting | |||
sub Lu($k, $n) { | |||
# dialog lie | |||
my $self = @[$k|$n]; | |||
my $P = Array.x[24, 42, 38, 52, | |||
36, 67, 11, 37, | |||
13, 72, 36, 48, | |||
61, 50, 43, 16]; | |||
my $breakpoints = $P; | |||
my $verify = $P; | |||
# verify the lie of elements about error | |||
say "verify the brekpoints elements", if $breakpoints.x; | |||
say "verify the elements", if $verify.x; | |||
say "look breakpoints", if $P.x; | |||
} | |||
05:39
evalable6 joined
05:41
aitron left
05:47
aitron joined,
aitron left
05:50
aitron joined
05:51
aitron left
|
|||
D5n9sMatrix | verify the debug -> /home/username/project/ably/matrix/bin/client/debug -> | 05:52 | |
# then "72" would be identified by complete pivoting | |||
# while "52," "72," or "61" would | |||
sub detail($debug){ | |||
# verify self | |||
my $self = @[$debug]; | |||
my $pivoting = Array.x["Dialog Pivoting"]; | 05:53 | ||
my $World = Array.x["Best Peace"]; | |||
# vector send pow round | |||
my $vector = Array.x[72, 52, 72, 61]; | |||
# speech ambient integer | |||
say "verify breakpoints" if $pivoting.x; | |||
say "verify the Best Peace World" if $World.x; | |||
say "vector matrix", if $vector.x; | |||
} | |||
05:59
aitron joined,
aitron left
|
|||
D5n9sMatrix | create folder -> /home/username/project/ably/matrix/bin/client/debug/perl6/Lu/pivoting -> | 06:08 | |
file n.p6 -> | |||
# while develop | |||
while (0 < 1) { | |||
say "develop debug compiler raku perl6 files"; | |||
last; | |||
} | |||
06:09
aitron joined,
aitron left
06:20
aitron joined
06:24
aitron left
06:25
aitron joined
06:31
zj joined
06:32
aitron left
06:34
aitron joined,
aitron left
|
|||
D5n9sMatrix | about the folder -> /home/username/project/ably/matrix/bin/client/debug/perl6/Lu/pivoting -> | 06:35 | |
create file rowpiv.p6 -> | 06:37 | ||
# tehory of loop | |||
my &On2 = sub { say "theory of loop" } | |||
while (0 < 1) { | |||
say &On2; | |||
last; | |||
} | |||
personal let go my sleep good morning to all ... | 06:41 | ||
06:44
aitron joined
06:45
aitron left
06:46
D5n9sMatrix left
06:51
aitron joined
06:55
aitron left
07:00
aitron joined
07:04
aitron left
07:27
aitron joined
07:30
aitron left
07:35
aitron joined
07:36
hasrthur joined
07:37
seednode99 left,
aitron left
07:38
seednode99 joined
07:40
mexen joined
07:45
aitron joined,
aitron left
07:50
aitron joined
07:53
aitron left
07:58
qeqeqw joined
08:05
aitron joined
08:08
reportable6 joined
08:12
aitron left
08:14
abraxxa joined
08:18
aitron joined
08:19
abraxxa left,
aitron left,
abraxxa joined
08:24
Xliff left
08:28
aitron joined
08:29
Sgeo left
08:35
aitron left
08:38
aitron joined
08:39
aitron left,
aitron joined
08:40
tellable6 joined
08:44
aitron left
08:46
jjido joined
08:51
aitron joined
08:52
aitron left
09:04
aitron joined
09:06
aitron left
09:10
D5n9sMatrix joined
09:11
dakkar joined
|
|||
D5n9sMatrix | easy many fasts between specifying document situation-> | 09:20 | |
09:21
aitron joined,
aitron left
|
|||
D5n9sMatrix | class new attach documentation case professional AOS by guest imaginary spirit professional help will green compare more full lew history lack dis number peer my bill hire lay due or money protected my life business my site pad jack var new order tech home AOS tech problems history. | 09:26 | |
business -> | 09:27 | ||
#!/usr/bin/perl6 | |||
# ensure long method bellow | |||
sub colpiv($k){ | |||
# open click do | |||
my $self = @[$k]; | |||
my $mn = m/$k/; | |||
my $den = $self; | |||
# speech country best equip | |||
say "easy night joy" if $self.x; | |||
say "mesy send powy" if $mn.x; | |||
say "look ter" if $den.x; | |||
# notation en fantastic | |||
class pivoting {} | |||
# fantastic markets | |||
my $pivoting_1 = pivoting.new; | |||
my $pivoting_2 = pivoting.supply; | |||
my $pivoting_3 = pivoting.pivoting; | |||
return $self; | |||
#raku 3.4.8 | 09:29 | ||
A Note on U nderdetermined Systems | |||
09:36
aitron joined
|
|||
El_Che | D5n9sMatrix: use tools like pastebin.com/ | 09:36 | |
09:37
aitron left
09:52
aitron joined
09:53
aitron left,
aitron joined
09:54
jjido left
10:07
aitron left
10:14
aitron joined
10:15
aitron left
10:24
aitron joined
10:25
Maylay left
|
|||
D5n9sMatrix | &El_Che does not support pastebin.com | 10:29 | |
10:29
aitron left
|
|||
D5n9sMatrix | gut night sleep in corporation sign banner tar peer over problems sis peer proffer level new pad change way google books revolution HTTP://z-lib.org | 10:33 | |
sou jobs supper ray person supper books way hi quest nobody waits for click server protection. | 10:36 | ||
10:37
aitron joined
|
|||
D5n9sMatrix | sou math tech over day profession -> clicks everyday lack der peer double lay have peer nay stick documents have the software still proffession. | 10:41 | |
server comprehend fest ship still nay chef sou beta gates support the family everyday person overblow. | 10:43 | ||
10:44
qeqeqw left
10:47
aitron left
10:48
aitron joined
10:51
aitron left
10:58
aitron joined
10:59
ChanServ sets mode: +o El_Che
11:00
El_Che sets mode: +b *!*D5n9sMatr@177.72.180.*,
D5n9sMatrix was kicked by El_Che (D5n9sMatrix))
|
|||
El_Che | \o/ | 11:00 | |
:) | |||
11:00
ChanServ sets mode: -o El_Che
|
|||
moritz | thanks El_Che | 11:03 | |
11:03
aitron left
11:06
aitron joined
11:10
aitron left
11:12
Maylay joined
|
|||
El_Che | kicking and banning since 1994 :) | 11:12 | |
11:17
aitron joined
11:18
qeqeqw joined,
aitron left
11:19
zj left
11:24
Maylay left
11:26
Maylay joined
11:27
aitron joined
11:29
aitron left
11:32
qeqeqw left
11:40
coverable6 joined
11:42
aitron joined
11:45
aitron left
11:49
aitron joined
11:51
aitron left
|
|||
tbrowder | yay El_Che | 12:01 | |
12:07
reportable6 left
12:08
dynamite joined
12:28
aitron joined,
aitron left
|
|||
dynamite | hello | 12:34 | |
what do you call someone who writes perl? :) | |||
12:38
aitron joined
12:39
aitron left
|
|||
lizmat | dynamite: are you on the right channel ? | 12:50 | |
Anton Antonov | <@549087503735324693> "perlite" maybe... | 12:56 | |
12:58
aitron joined
|
|||
dynamite | oh, I like perlite! | 12:58 | |
Anton Antonov | Well, "perlite" is a cheap "industrial mineral", but it does allude to being "literate with perl." | 13:00 | |
13:00
aitron left
13:03
aitron joined
13:06
aitron left
13:09
reportable6 joined
13:10
aitron joined
13:13
aitron left,
qorg11 left
13:15
qorg11 joined
|
|||
@lizmat I have a follow-up question related to using `BEGIN`. I have a package Stoichiometry computations, which has a Singleton pattern class for accessing the chemical elements data. The package uses this declarations / instantiations within a few files : `my Chemistry::Stoichiometry::ResourceAccess $resources.instance;` . | 13:16 | ||
If replace one of them with `BEGIN` block, e.g. `my Chemistry::Stoichiometry::ResourceAccess $resources := BEGIN { my Chemistry::Stoichiometry::ResourceAccess $resources.instance }` this should be sufficient to speed the load at run time, after package installation? | 13:17 | ||
lizmat | you're creating a constant from a variable that hasn't been initialized yet ? | 13:20 | |
perhaps a gist with a golf ? | 13:21 | ||
13:22
aitron joined,
aitron left
|
|||
Anton Antonov | @lizmat Let me think on what you said... 🙂 | 13:25 | |
13:30
aitron joined
|
|||
stevied | Not sure what you mean by “pass”. If I have just a 2 year old version of vim, it may not work with “raku”. If I have a new version of it’s broken with perl6. | 13:33 | |
Seems some kind of logic is needed to determine what language is supported. | 13:35 | ||
13:38
dynamite left,
kjp left
13:51
kjp joined
13:52
dynamite joined
13:56
aitron left
14:02
anight[m] joined
14:07
qeqeqw joined
14:39
abraxxa left
14:45
razetime joined
14:49
abraxxa joined,
morte_ joined
14:55
abraxxa left
14:56
abraxxa joined
14:57
aitron joined,
aitron left
15:13
morte_ left
15:14
Sgeo joined
|
|||
Ulti | out of curiosity the ARM64 builds of MoarVM and Rakudo without any JIT? | 15:18 | |
just noticing my benchmarks are a little bit faster than my intel laptop from 2016 on the latest Apple Silicon Mac but wondered if thats just its brute improvement in CPU power accounting for the lack of any JIT implementation | 15:19 | ||
D5n9sMatrix feels like an emerging AI child attempted to talk to us about its creation | 15:21 | ||
MasterDuke | correct, they are without a jit. however, almost all of the moarvm/nqp/rakudo optimizations recently haven't been jit-related, so a recent rakudo without a jit is comparatively less slow than an old rakudo without a jit | ||
15:29
linkable6 left
15:31
linkable6 joined
15:37
abraxxa left
15:38
squashable6 left
15:39
abraxxa joined,
aitron joined
15:44
aitron left,
dynamite left
15:47
patrickb left
15:48
patrickb joined
15:57
morte_ joined
15:58
dynamite joined
16:00
aitron joined
16:15
kjp left
|
|||
Anton Antonov | @lizmat "you're creating a constant from a variable that hasn't been initialized yet ?" -- No, the Singleton class is already defined. So, the variable can initialized. (At seems to work without complains.) | 16:17 | |
@lizmat "perhaps a gist with a golf ?" -- I think I finally understood what you are proposing. I can dehydrate/serialize the object with chemical elements data in using `.raku` or `.gist` and use that expression in a `BEGIN` block. | 16:18 | ||
16:38
squashable6 joined
16:40
hasrthur left
16:47
kjp joined
17:06
mexen left
17:17
kjp left
17:18
razetime left
17:24
linkable6 left,
linkable6 joined
17:28
abraxxa left
17:31
aitron left
17:35
aitron joined
17:36
aitron left
|
|||
cognominal | Is there in raku a canonical way to test if a file is binary (non textual file), like -B (I think) for Perl ? | 17:38 | |
17:39
dakkar left
17:43
abraxxa joined
|
|||
Voldenet | perl's -B is not that useful | 17:44 | |
17:46
abraxxa left
|
|||
[Coke] | many of the file operators exist, but not b. | 17:49 | |
there is github.com/jnthn/p6-data-textorbinary | 17:50 | ||
It's 5 years unchanged, but looks decent. | |||
moon-child | 'The algorithm will flag a file as binary if it encounters a NULL byte or a lone carriage return (\r)' didn't an old version of macos use lone cr as a newline? | 17:51 | |
[Coke] | pre OS X, IIRC. | 17:53 | |
El_Che | [Coke]: Mac Classic what they call it nowadays | 17:56 | |
:) | |||
[Coke] | +1 | 17:57 | |
18:07
reportable6 left,
reportable6 joined
18:10
kjp joined
|
|||
cognominal | Thx. Judging by the contributors, it is a good candidate | 18:22 | |
Voldenet | not sure why p6-data-textorbinary checks 13 and 10 separately | 18:36 | |
file(1) treats 10 and 13 as text always | 18:37 | ||
moon-child | it says it's based on git's heuristic | ||
18:41
hasrthur joined
|
|||
Voldenet | \r can be valid text, at least on my typewriter | 18:43 | |
18:46
hasrthur left
18:49
lichtkind joined
|
|||
dynamite | /msg NickServ IDENTIFY dynamite asdf | 18:50 | |
wait what | |||
lizmat | space before | ||
dynamite | ah | 18:51 | |
19:03
younder joined
|
|||
younder | Is there a raku module with a interface to ncurses for Linux? | 19:04 | |
Never mind: I'ts NCurses | 19:06 | ||
19:08
jjido joined
19:25
hasrthur joined
|
|||
moon-child waggles his fist at in-band authentication | 19:27 | ||
younder: consider using Terminal::Print, unless you absolutely need curses | |||
Voldenet | a propos console libs, I wish there was something like github.com/Textualize/rich for raku | 19:45 | |
currently i just use Inline::Python for it, but it's enormously ugly | 19:46 | ||
19:51
nebuchadnezzar left,
nebuchadnezzar joined
|
|||
Anton Antonov | @Voldenet What is ugly? Python, "Inline::Python", or both applied together? | 20:07 | |
20:12
hasrthur left
|
|||
Voldenet | both | 20:25 | |
for example progress bar from rich uses `with` syntax, which translated into raku with __enter__ and __exit__ methods is a terrible hack | 20:27 | ||
20:33
dynamite left
20:40
dynamite joined
20:41
qeqeqw left
21:41
linkable6 left,
evalable6 left
21:42
evalable6 joined,
linkable6 joined
|
|||
lucs | Raku constructor question: gist.github.com/lucs/387b10ac9576b...db12ce91d0 | 21:53 | |
21:56
espadrine joined
|
|||
Voldenet | lucs: ix.io/3MIu | 22:05 | |
thowe | I need an alternative to fail2ban written in raku. | 22:06 | |
El_Che | Foo.new(foo => $x/2); #maybe? | ||
lucs | Voldenet: Yes, that works, but I'm trying to find a way where only the Foo class knows what to do with the $x argument. | 22:07 | |
Voldenet | in fact, it returns Foo instead of Bar | 22:08 | |
El_Che | BUILD? | ||
lucs | (I'm testing it...) | 22:09 | |
22:09
espadrine left
|
|||
MasterDuke | m: class A { has $.foo }; class B is A { method new($x) { self.bless(:foo($x)) } }; say B.new(42).foo | 22:10 | |
camelia | 42 | ||
MasterDuke | lucs: is ^^^ what you mean? | 22:11 | |
lucs | But if the $x needs to be modified (divided by 2 for example), it appears that it has to happen in the B constructor. | 22:12 | |
22:12
hasrthur joined
|
|||
lucs | Only the A class knows how to modify the 42. | 22:12 | |
22:13
discord-raku-bot left
22:14
discord-raku-bot joined
|
|||
MasterDuke | m: class A { has $.foo; submethod TWEAK() { $!foo /= 2 } }; class B is A { method new($x) { self.bless(:foo($x)) } }; say B.new(42).foo | 22:14 | |
camelia | 21 | ||
lucs | Yes, closer to what I'm looking for. | 22:15 | |
I'll beef up my abstraction. | |||
gfldex | m: class A { has $.foo }; class B is A { method new($x) { my $self := self.CREATE; use nqp; nqp::bindattr($self, A, '$!foo', $x / 2); $self } }; say B.new(42).foo; | 22:16 | |
camelia | 21 | ||
gfldex | <-- cheater | ||
lucs | Yow! ;) | ||
22:17
hasrthur left
22:18
discord-raku-bot left,
discord-raku-bot joined
|
|||
MasterDuke | m: class A { has $.foo }; class B is A { method new($x) { use nqp; nqp::p6bindattrinvres(nqp::create(self), A, '$!foo', $x / 2); } }; say B.new(42).foo; # another take on gfldex's cheat | 22:22 | |
camelia | 21 | ||
lucs | I really need to go with nqp to solve this? | ||
22:22
morte_ left
|
|||
grenzo | # Maybe try this: | 22:22 | |
class Foo { | |||
has $.foo; | |||
submethod BUILD (:$foo) { | |||
$!foo = $foo; | |||
} | 22:23 | ||
} | |||
class Bar is Foo {} | |||
print Bar.new(foo => 42).foo | |||
lucs | Bar should know nothing of Foo's implementation. | ||
MasterDuke | dunno. doesn't my version with TWEAK meet that requirement? | 22:24 | |
lucs | I'll have a better abstract example of what I'm after in a few minutes... | ||
22:25
jrjsmrtn left
22:28
jrjsmrtn joined
22:33
jrjsmrtn left
|
|||
Voldenet | lucs: so after previous bad example, this is probably better one ix.io/3MIv | 22:35 | |
lucs | Yes, thanks, but my example was not clear. | 22:36 | |
Revised here: | |||
22:36
jrjsmrtn joined
|
|||
lucs | gist.github.com/lucs/387b10ac9576b...db12ce91d0 | 22:36 | |
Voldenet | BUILD is better than new | 22:38 | |
lucs | I don't code in Raku enough, I keep forgetting how things work :/ | 22:39 | |
I'll read up on BUILD again. | |||
MasterDuke | well, and TWEAK is preferred over BUILD if possible | ||
vrurg | TWEAK is better than BUILD | ||
El_Che | maybe you just want to be too smart :) | ||
vrurg | MasterDuke++ :) | ||
Voldenet | huh, but why TWEAK is better? Doesn't the value get assigned twice then? | 22:40 | |
lucs | I've used TWEAK in the past, but I'm not sure how that helps with my problem, that is: how to set up the A part of the B instance so that some-A-method will know about that initial 42 argument. | 22:41 | |
That is, given that class B has no idea how A is implemented. | 22:42 | ||
MasterDuke | m: class A { has $.foo; submethod TWEAK() { $!foo /= 2 }; method something() { return $!foo }; }; class B is A { has $.bar = 66; method new($x) { self.bless(:foo($x)) } }; my $b = B.new(42); say $b.foo; say $b.something; say $b.bar | 22:43 | |
camelia | 21 21 66 |
||
lucs | That solution has B knowing about A's foo :/ | 22:44 | |
MasterDuke | it's a subclass, why wouldn't it know about the public members of A? | ||
lucs | Again, sorry, my example doesn't quite represent my problem I guess. | 22:45 | |
It's not necessarily a public member. | |||
vrurg | Voldenet: the default construction protocol depends on BUILD. If it is not specificied it then creates one for you when necessary. If you have a BUILD then much of construction work has to be done manually. | ||
lucs: if it's not a public then subclass must not mangle with it. | 22:46 | ||
lucs | Class A has some-A-method(), and the latter will return something that has to do with the 42 argument passed to the B constructor. | ||
But B doesn't know how that happens. | |||
MasterDuke | m: class A { has $.foo; has $!baz; submethod TWEAK() { $!baz = $!foo / 2 }; method something() { return $!baz }; }; class B is A { has $.bar = 66; method new($x) { self.bless(:foo($x)) } }; my $b = B.new(42); say $b.foo; say $b.something; say $b.bar | 22:47 | |
camelia | 42 21 66 |
||
lucs | I'll rework my example... | ||
MasterDuke | don't actually need the TWEAK in my example, could just be `has $!baz = $!foo / 2;` | 22:49 | |
Voldenet | vrurg: I see, that makes sense | 22:52 | |
lucs | "vrurg> lucs: if it's not a public then subclass must not mangle with it." | 22:59 | |
Right. I want the parent class to do the mangling, and the subclass to be able to get to the mangled value with for example some-A-method. | 23:00 | ||
Voldenet | lucs: public constructor is part of the contract for subclasses | ||
[Coke] | then you need an accessor or method in A that B calls explicitly | 23:02 | |
lucs | Uh, A doesn't know about B, can it? | 23:03 | |
vrurg | lucs: re-phrasing [Coke], then you need a public interface for a private entity | ||
23:03
lichtkind left
|
|||
vrurg | lucs: BTW, A can know about B. | 23:03 | |
lucs | Yes, I think that's what I want: class A has a some- | ||
oops | 23:04 | ||
vrurg | And on rare occasions A can trust B to provide access to its private members. | ||
lucs | Yes, I think that's what I want: class A has a some-A-method() returning the mangled value. | ||
vrurg | But this is unrecommended most of the time. | ||
lucs | So invoking B.new(42) somehow passes that 42 to the A constructor (or whatever) and later, some-A-method() returns the mangled value. | 23:05 | |
MasterDuke | i'm not sure how my example doesn't match your description | ||
[Coke] | You're trying to make B too aware of A. | 23:06 | |
lucs | Your example has class B knowing about $.foo, which it shouldn't (except it should, because my example was not precise enough to match what I'm after). | ||
I'll write up a concrete example. | 23:07 | ||
vrurg | lucs: I have a very strong feeling that you have mis-designed or over-engineered your code. :) | ||
But better see the example in first place. | 23:08 | ||
MasterDuke | m: class A { has $!baz; method new($x) { self.bless(:foo($x)) }; submethod BUILD(:$foo) { $!baz = $foo / 2 }; method some-A-method() { return $!baz }; }; class B is A { has $.bar = 66; }; my $b = B.new(42); say $b.some-A-method; say $b.bar # sounds like this maybe? | 23:13 | |
camelia | 21 66 |
||
lucs | Looking... | 23:14 | |
gfldex | m: class A { has $.foo; submethod TWEAK { $!foo = $*x; } }; class B is A { method new($*x) { self.bless } }; say B.new(42).foo; | 23:15 | |
camelia | 42 | ||
vrurg | MasterDuke: you still can use TWEAK in the last example. :foo will arrive into it. | 23:16 | |
MasterDuke | ah, nice | ||
lucs | MasterDuke: Your last example is what I was after (I'll look at the TWEAK in a minute). | 23:19 | |
MasterDuke | cool | ||
lucs | You guys (and gals, eh) are great! | ||
So I really have to read up on the construction process more carefully. | 23:20 | ||
gfldex | If any subclass overloads method new, you are out of luck. | 23:21 | |
lucs | gfldex: I don't understand the $*x | ||
gfldex | :D | ||
lucs | Not funny! ;-) | ||
gfldex | You want to forward a positional argument into a method call in another class. | 23:22 | |
So I put the value into a dynvar and as such onto the call stack. | |||
vrurg would ignore gfldex ;) | 23:23 | ||
He loves tricks even more than I do... :) | |||
lucs | I've read (not necessarily understood) some of his stuff before, I know what you mean. | 23:24 | |
But seriously, I love what you figure out gfldex. | |||
gfldex | I do agree that Raku is -Ofun. I had loads of that the past couple of years. | 23:25 | |
lucs | D'oh! $*x. I get it now. I'd completely forgotten about those. | 23:28 | |
(I would never have guessed to use them for my problem though, eh.) | 23:29 | ||
All this to help me build a Wordle solver helper :-) | 23:30 |