🦋 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.
whatnext hello raku community :] 01:00
how can I set an attribute declared in the parent in the TWEAK of the child? 01:01
I get "Attribute $!id is not declared in class My::Class" 01:02
any thoughts? :] 01:03
MasterDuke m: class A { has $.a }; class B is A { has $.b; multi method new($n) { self.bless(a => $n) } }; say B.new(4).a   # whatnext ^^^ it's not TWEAK, but would this accomplish what you're trying to do? 02:07
camelia 4
lizmat sjn: did you find a solution ? 11:56
Anton Antonov I am trying to get someone to install and use Raku, but they get messages about "psunzip" not being available, etc. 12:26
whatnext hi all :] re-asking my question from earlier: 12:27
Anton Antonov Do you / did you have Raku installation problems like that? I pointed them to : github.com/ugexe/zef/issues/341#is...-611459217 . Does the advise there work?
whatnext how can I set an attribute declared in the parent in the TWEAK of the child?
I get "Attribute $!id is not declared in class My::Class" ...? 12:28
lizmat m: class A { has $.a is rw }; class B is A { method TWEAK { self.a = 42 } }; dd B.new.a 12:34
camelia Int $!a = 42
lizmat whatnext ^^
whatnext thanks lizmat - that looks like the way I'd expect it to work. Not sure why I'm getting an error though. If $.a is not rw and I set $!a that also should work? And would it make a difference if "required" ? I am trying to figure what might be causing that error 12:40
lizmat the attribute *must* be marked as "is rw", otherwise it won't work
whatnext ah really
that explains it then
lizmat well, there are other ways... 12:41
whatnext for example?
Nemokosch $!a is like object private
lizmat but if the class has indicated that the attribute is not to be changed from outside, you should probably respect that
whatnext yes... but I figured the child would still have access
lizmat access is ok
whatnext but cannot set? 12:42
lizmat m: class A { has $.a = 42 }; class B is A { }; dd B.new.a
camelia 42
Nemokosch to $!a ? it probably won't
whatnext yes I guess I meant that in the TWEAK of the child, $!a declared in the parent cannot be set - is this correct? 12:44
lizmat not unless the parent allows it
whatnext the parent allows it by marking it "rw" ? 12:45
Nemokosch $.foo stuff is essentially a method, and these methods can be marked "is rw". From what I know, the actual data with the ! is always object private; basically there is no syntax to access it in a high-level way 12:47
whatnext haha great bot :] 12:48
lizmat well, there is, but it's butt ugly, using introspection
m: class A { has $.a }; class B is A { method TWEAK { self.^mro[1].^attributes.first(*.name eq q/$!a/).set_value(self,42) } }; say B.new.a
camelia 42
whatnext ok that looks complicated '=D 12:50
I think the "rw" solution will work - thanks lizmat
rf Morning folks 14:14
lizmat rf o/
rf How are things today lizmat? 14:17
lizmat interesting and a bit exciting: trying to re-implement pod parsing as a true slang 14:18
rf Oooh sounds like fun!
Best of luck :D
lizmat well, the fun comes when it works, so far it is mostly torture :-)
rf :P 14:19
Anton Antonov @rf Please, take a look here: resources.wolframcloud.com/PacletR...nadMakers/ 14:55
I used "⟹" in monadic pipelines before I discovered Raku. I like Raku's forward feed operator, "==>". 14:56
(And the backward one too..)
ugexe Anton Antonov: that error message means they have no program that can extract whatever archive the distribution is. if its from fez then they don't have a program that can extract a tar file in their PATH, if its a zip file they don't have 'unzip' or 'powershell' in their PATH, etc 15:16
Anton Antonov @ugexe Thanks! So, the correct paths of "unzip" and "powershell" have to be specified. 15:39
ugexe er, not exactly i was simplifying it to unixy terms 15:40
to be more precise, they need either a `unzip` or `powershell` command to be available 15:41
they might not exist in $PATH, but on a unixy system that is what that usually means
im guessing they need the tar command
Anton Antonov @ugexe 🙂 thank you. I know they had unzip when we talked.
ugexe modern windows 10 comes with one i think 15:42
Anton Antonov Ok
I should try to make a Windows 10 virtual environment in some cloud service. 15:43
ugexe devblogs.microsoft.com/commandline...o-windows/
Anton Antonov Thanks again1 15:44
rf @Anton very nice 16:33
Anton Antonov @rf Thanks, you are kind, 16:43
rf Where exactly is the docs for declaring types for sub-routines as parameters 18:56
m: sub foo((foo -> bar):D &f) { &f() } 18:57
camelia ===SORRY!=== Error while compiling <tmp>
Invalid typename 'foo' in parameter declaration.
at <tmp>:1
------> sub foo((foo⏏ -> bar):D &f) { &f() }
rf kind of thing ^
Voldenet rf: docs.raku.org/language/signatures.html 19:03
rf Thanks!
Is there any way to have generics in a sub-routine?
Voldenet see type captures 19:06
m: sub foo(::T $x) { sub (T $bar) { $x + $bar } }; foo(1)(2).say; 19:07
camelia 3
Voldenet m: sub foo(T) { sub (T $foo) { sub (T $bar) { $foo + $bar } } }; foo(Int)(1)(2).say;
camelia ===SORRY!=== Error while compiling <tmp>
Invalid typename 'T' in parameter declaration.
at <tmp>:1
------> sub foo(T⏏) { sub (T $foo) { sub (T $bar) { $foo +
Voldenet m: sub foo(::T) { sub (T $foo) { sub (T $bar) { $foo + $bar } } }; foo(Int)(1)(2).say; 19:08
camelia 3
rf Perfect thanks! 19:13
Nemokosch can a user define "thunky operators"? 23:33
deoac What is the meaning of `:10[6,1,3]` 23:58
is it simply shorthand for `[6,1,3].join.Int.base(10)` 23:59