🦋 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.
Xliff tonyo: I was just hoping for a more direct method than" ::?CLASS.^attributes.grep( *.name eq $attribute-name )" is all. Thanks for the help. 00:09
m: class A { has $!x; has $!y; }; A.^attribute_table.gist.say 00:12
camelia {$!x => Mu $!x, $!y => Mu $!y}
Xliff :-O
Well color me plaid!]
Xliff m: role AttributeAccess { method ATTRIBUTE { ::?CLASS.^attribute_table{ self.VAR.name }; }; multi sub trait_mod:<is> (Attribute \a, :$accessed) { a does AttributeAccess }; class A { has $!x; has $!y; method a { $!x.ATTRIBUTE.name.say }; }; A.new.a 00:21
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
------> sed) { a does Attribute…
Xliff m: role AttributeAccess { method ATTRIBUTE { self.package.^attribute_table{ self.VAR.name }; }; multi sub trait_mod:<is> (Attribute \a, :$accessed) { a does AttributeAccess }; class A { has $!x; has $!y; method a { $!x.ATTRIBUTE.name.say }; }; A.new.a
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
------> sed) { a does Attribute…
Xliff m: role AttributeAccess { method ATTRIBUTE { self }; multi sub trait_mod:<is> (Attribute \a, :$accessed) { a does AttributeAccess }; class A { has $!x; has $!y; method a { $!x.ATTRIBUTE.name.say }; }; A.new.a 00:22
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
------> sed) { a does Attribute…
tonyo Attr table, nice find 00:23
Xliff Thanks! I think that will work. 00:26
Thanks again for the help, tonyo++
Xliff In the end, this is what worked... 00:27
m: class A { has $!x; has $!y; method a { self.^attribute_table{ $!x.VAR.name }.gist.say }; }; A.new.a
camelia Mu $!x
Xliff tonyo: You mentioned a use case. Well, in some of my code, I have postdeclared comments on attributes that serve as annotations. Such things I can use at runtime. 00:28
So direct access to the Attribute (not its value) is preferred. This solves that problem.
tonyo Ahh v nice
Xliff \o 04:56
Is there a way to have a role enforce a class inheritance? 04:57
moritz a role can apply a class inheritance 06:13
Geth ecosystem/main: 3d408a6d55 | L'Alabameñu++ (committed using GitHub Web editor) | META.list
Intl::CLDR is now on zef/fez
12:09
tbrowder hi, need some help about module organization for a class and a separate file for a r 13:05
*set of subroutines for use by it and other progs 13:06
call the class Bar in dir lib/Foo 13:07
call the file of subs lib/Foo/Subs.rakumod 13:08
i want to call a sub in Subs from class Foo::Bar 13:09
no reply yet, please, i need to check some more...i'm getting circular call errors but i haven't given just yet. 13:13
ugexe do you know what a circular reference is? 13:25
if you have Foo.rakumod and Foo/Subs.rakumod and each one of those files uses the other file, its a circular reference 13:26
because when you load Foo it then goes to load Foo::Subs, which then needs to load Foo which needs to load Foo::Subs, and so on 13:27
it sounds like you need to move code in Foo::Subs (the code that depends on Foo in such a way you need a `use Foo` in Foo/Subs.rakumod) to a third module 13:28
or put that logic inside of Foo::Subs in such a way that it doesnt need `use Foo`
[Coke] if we don't have that in one of the tutorials on the doc site, someone please open a ticket for it. 14:39
(avoiding circular dependencies)
Anton Antonov @Coke In case you did not get the message -- you have issues. 14:40
[Coke] I didn't see that, no. 14:44
[Coke] Thanks. this should a small lift, will try to get to it in the next few days 14:51
Anton Antonov @Coke Sounds good. 15:27
El_Che does [Coke] have issues? www.youtube.com/watch?v=SAxPLSvvbXY 15:29
tbrowder ugexe: yes, i got it fixed, thnx 15:43
Anton Antonov @El_Che Thanks! 15:48
All the chapters of my PhD thesis start with epigraphs that are quotes from "The Offspring" songs. 15:49
nine Anton Antonov: that's epic :)
El_Che Anton: as everyone's should! 15:50
Nemokosch not sure if it's possible to forgive them for that awful Obladi Oblada parody... but anyway, that's not what I wanted to say 16:11
do we have something like Text::Extract::Word in Perl, or is it up to the new generation?
"the new generation" that hopefully won't need much of .doc files but unfortunately I do
ToddAndMargo I have created a class and  a variable of that class.  I have been using "push" to create an array of that variable.  Problem: all of the lines inside the array (about 20 of them)  are all the last line I pushed into the array,  Am I doing something wrong?   The offending line is 84: "push @Tasks, $TaskLine;" 20:31
vpaste.net/iI8EM#uploads
lizmat could you create a gist with line numbers ? 20:33
ToddAndMargo Windows 11; raku -v 20:34
Welcome to RakudoΓäó v2022.07.
Implementing the Raku® Programming Language v6.d.
Built on MoarVM version 2022.07.
lizmat looks like you're only creating a single $TaskLine object
and updating that in each iteration and pushing that 20:35
instead of creating a new TaskLine object each iteration
ToddAndMargo It is that last line repeated over and over 20:36
Xliff ToddAndMargo, under "for $RtnStr.lines[ 3..*-1 ] -> $Line {" 20:37
You need a "$TaskLine = TaskLine.new"
Rather ... "$TaskLine = TaskLineClass.new" 20:38
You can turn the "my $TaskLine = TaskLineClass.new" above that into just "my $TaskLine" 20:39
ToddAndMargo I though I was just reusing line 51 "my $TaskLine     = TaskLineClass.new;"
Xliff Nope.
Well... yes. You are.
That's why you are getting the repeats. 20:40
'You are using the same object. Not a new one.
So when you go to print the list in the next loop, they are all the same.
It's pretty much as lizmat++ said.
ToddAndMargo Fixed! Thank you! 20:42
   for $RtnStr.lines[ 3..*-1 ] -> $Line  { 20:43
      # print "$Line\n";
      my $TaskLine = TaskLineClass.new;
      $TaskLine.ImageName     = $Line.substr(  0..24 ).trim;
      $TaskLine.PID           = $Line.substr( 26..33 ).trim.Int;
      $TaskLine.SessionName   = $Line.substr( 35..50 ).trim;
      $TaskLine.SessionNumber = $Line.substr( 52..62 ).trim.Int;
      $TaskLine.MemUsage      = $Line.substr( 64..75 ).trim;
      push @Tasks, $TaskLine;
Xliff yw - And try to minimize posting code like that in IRC>
I speak from experience! You get yelled at!
Particularly if you bother camelia. 20:44
Xliff flees
ToddAndMargo oops!
lizmat also: if you want to ensure types and values, you'd probably be better of in a TWEAK method doing all of the cleanup
*off
ToddAndMargo Soon as I learned Raku's OOP, I dropped hashes.  OOP is just to powerful and easy to read 20:50
Xliff ToddAndMargo: Yes. However hashes still have their place. ;)
ToddAndMargo One of the endearing things I find with Raku is that there are 1001 ways to do everything! 20:54
Xliff Is a once {} block guaranteed to run only once per execution? 21:00
Xliff m: sub a { once { say "Boo!" }; say "You" }; a;a;a;a 21:00
camelia Boo!
You
You
You
You
lizmat once, like state, suffers from a race condition, but other than that: yes 21:01
Xliff m: class A { method A { say "A"; }; method a { say "a" }; }; A.a; A.A 21:30
camelia a
A
Xliff Oh god bless Raku for case sensitive method names!
lizmat although, you could actually make method lookup case-insensitive if you really wanted :-) 21:33
by replacing the ^find_method method in the meta-class :-)
Xliff lizmat: Yes, I do realize that. I'm good. Thanks! ;) 21:40
lizmat hehe 21:41
Xliff Case sensitivity solves a significant design issue in my code.
So I'm happy about it.
ToddAndMargo Is tehere a sysem variable that will tell me "raku,exe"?  (rakuw,rakudi, etc.) 21:42
rakudo
lizmat m: say $*EXECUTABLE # ToddAndMargo 21:43
camelia "/home/camelia/rakudo-m-inst-1/bin/rakudo-m".IO
ToddAndMargo >raku -e "say $*EXECUTABLE" 21:45
"C:\Program Files\Rakudo\bin\raku.exe".IOaPerfect!  TH
Thank yoU!
Geth advent: 80bfebb402 | (Tom Browder)++ (committed using GitHub Web editor) | raku-advent-2022/artlicles/tbrowder
Create tbrowder
21:49
lizmat tbrowder++ 21:50
Geth advent: 729a7cd8a4 | (Tom Browder)++ (committed using GitHub Web editor) | raku-advent-2022/artlicles/tbrowder
Delete raku-advent-2022/artlicles directory
21:51
advent: e312cf397a | (Tom Browder)++ (committed using GitHub Web editor) | raku-advent-2022/articles/tbrowder.md
Create tbrowder.md
21:52
advent: c29a13bae7 | (Tom Browder)++ (committed using GitHub Web editor) | raku-advent-2022/articles/tbrowder.md
Update tbrowder.md
21:54
Geth advent: 29f6698007 | (Tom Browder)++ (committed using GitHub Web editor) | raku-advent-2022/articles/tbrowder.md
Update tbrowder.md
23:11
advent: 5e5812e223 | (Tom Browder)++ (committed using GitHub Web editor) | raku-advent-2022/authors.md
Update authors.md
23:12
Geth advent: 693eee6ed4 | (Tom Browder)++ (committed using GitHub Web editor) | raku-advent-2022/articles/tbrowder.md
Update tbrowder.md
23:22
advent: efe5c7d7b9 | (Tom Browder)++ (committed using GitHub Web editor) | raku-advent-2022/articles/tbrowder.md
Update tbrowder.md
23:25
Geth advent: 01b97af6cc | (Tom Browder)++ (committed using GitHub Web editor) | raku-advent-2022/articles/tbrowder.md
Update tbrowder.md
23:35
Geth advent: tbrowder++ created pull request #97:
add draft article
23:50
advent: 7c86520f0b | (Tom Browder)++ | raku-advent-2022/articles/tbrowder.md
add draft article
23:51
advent: e38b05938b | (Tom Browder)++ (committed using GitHub Web editor) | raku-advent-2022/articles/tbrowder.md
Merge pull request #97 from tbrowder/tbrowder

add draft article