🦋 Welcome to Raku! raku.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: colabti.org/irclogger/irclogger_log/raku
Set by ChanServ on 14 October 2019.
guifa Tirifto: one other potential way to do what you want to do (maybe) is to use ‘trusts’, that will allow a particular class access to the innards of another one, but not others. 00:55
Xliff m: my $*A = 1; { $*A = 2; { $*A = 4; say $*A }; say $*A }; say $*A; 03:47
camelia 4
4
4
Xliff m: my $*A = 1; { my $*A = 2; { my $*A = 4; say $*A }; say $*A }; say $*A; 03:48
camelia 4
2
1
toddandmargo Does anyone know if Raku's NativeCall runs "LocalFree( )" after it finishes with buffers? Or do I need to do it myself? docs.microsoft.com/en-us/windows/w...-localfree 05:11
toddandmargo I am doing it anyway. It is not throwing an error.This may be a bug in NativeCall, resulting in a memory leak 06:03
xinming m: my ($, @data) = <a b c d>; $.perl.say; @data.perl.say; 06:47
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable $.perl used where no 'self' is available
at <tmp>:1
------> 3my ($, @data) = <a b c d>; $.perl7⏏5.say; @data.perl.say;
expecting any of:
term
xinming In this case, How can we print the value of $ ?
I mean, how do we use the $ var, IIRC, It can be used in one-liners 06:48
Xliff m: my ($, @data) = <a b c d>; @data.perl.say; 06:48
camelia ["b", "c", "d"]
Xliff xinming: In this situation the $ is a dummy variable.
In other words, you CAN'T print its value. It doesn't exist.
m: my ($, $, @data) = <a b c d>; @data.perl.say; 06:49
camelia ["c", "d"]
xinming Xliff: Ok, So, only anonymous use of $ can be used, right?
Xliff Yes.
m: ++$.say
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable $.say used where no 'self' is available
at <tmp>:1
------> 3++$.say7⏏5<EOL>
expecting any of:
prefix
Xliff m: $++.say
camelia 0
Xliff m: $++.say; $++.say 06:50
camelia 0
0
Xliff m: for ^3 { $++.say }
camelia 0
1
2
Xliff m: (++$).say; $++.say 06:51
camelia 1
0
xinming my %data; %data{$header.split(',')} = $line.split(','); return %data; <--- How can we write this into a single hash?
It's actually trying to do some easy csv loading.
return %($header.split(',') xx $line.split(',') ) 06:52
Let me try again.
Xliff xinming: Isn't that what you are doing? 06:53
xinming m: my @x = <a b c>; my @y = <x y z>; %( (@x Z @y).flat).perl.say;
camelia {:a("x"), :b("y"), :c("z")}
xinming m: my @x = <a b c>; my @y = <x y z>; %( (@x Z @y).flat).perl.say;
camelia {:a("x"), :b("y"), :c("z")}
xinming Xliff: This is what I try to do. :-)
I mean, merge that into a single statement 06:54
m: my @x = <a b c>; my @y = <x y>; %( (@x Z @y).flat).perl.say;
camelia {:a("x"), :b("y")}
Xliff xinming: my $contents = $file.IO; my %data; (%data{$contents.line[0].split(',')} = .split(',') for .lines.skip(1)).Hash 06:55
no-n m: {}.WHAT
camelia ( no output )
no-n m: {}.WHAT.say
camelia (Hash)
Geth doc: cb80067556 | (JJ Merelo)++ | doc/Language/contexts.pod6
Specifies numeric conversion of whitespace #2632
doc: d75b8f7565 | (JJ Merelo)++ | doc/Type/Any.pod6
Specifies behavior of non-int batch size in rotor #2632
doc: 4b0d38d5ce | (JJ Merelo)++ | doc/Type/Any.pod6
Comments behavior on negative gaps #2632
Xliff xinming: That's buggy actually.
no-n m: {foo => 'bar'}.WHAT.say
camelia (Hash)
no-n m: {foo => 'bar'}.perl.say
camelia {:foo("bar")}
Xliff xinming: sub readCSV($file) { my $contents = $file.IO; my %data; %data{$contents.line[0].split(',')} = .split(',') for .lines.skip(1); %data; }
Aand... that's still buggy. 06:57
xinming m: my @x = <a b c>; my @y = <x y z>; %( (@x Z @y).flat).perl.say;
camelia {:a("x"), :b("y"), :c("z")}
xinming m: my @x = <a b c>; my @y = <x y>; %( @x Z=> @y).perl.say;
camelia {:a("x"), :b("y")}
xinming How can we force @x to be enumated in Zip operator?
no-n m: <a b c>.keys.say 06:58
camelia (0 1 2)
xinming hm 06:59
no-n m: my @a = <a b c>; say zip @a.keys, @a
camelia ((0 a) (1 b) (2 c))
Xliff xinming: sub readCSV($file) { my $contents = $file.IO; my @header = $contents.lines[0].split(','); (@header Z=> $contents.lines.skip(1).split('.
xinming m: my @x = <a b c>; my @y = <x y>; %( @x.keys.map({ @x[$_] => @y[$_] }) ).perl.say;
camelia {:a("x"), :b("y"), :c(Any)}
Xliff xinming: sub readCSV($file) { my $contents = $file.IO; my @header = $contents.lines[0].split(','); (@header Z=> $contents.lines.skip(1).split(',') }
xinming Is there a way to do this shorter?
no-n xinming: like that? 07:00
xinming m: my @x = <a b c>; my @y = <x y>; %( @x.keys.map({ @x[$_] => @y[$_] }) ).perl.say;
camelia {:a("x"), :b("y"), :c(Any)}
xinming no-n: Yea, but the @x.keys.map ... thing is too long.
Is there a shorter way. :-)
no-n zip @x.keys, @x
Xliff xinming: sub readCSV($file) { my $contents = $file.IO; my @header = $contents.lines[0].split(','); @data.push: %( (@header Z=> .split(',').flat ) for $contents.lines} 07:01
And you need the return value, so...
xinming Xliff: Thanks for your example, Actually, I use gather/take to implement that.
Xliff xinming: sub readCSV($file) { my $contents = $file.IO; my @header = $contents.lines[0].split(','); @data.push: %( (@header Z=> .split(',').flat ) for $contents.lines; @data}
xinming: TIMTWOTDI
xinming I just return a single row. with my @x = gather { ... take %( @header Z=> @line) }
yea
xinming no-n: Could you give an exmaple for that? 07:01
Xliff xinming: goog luck! 07:02
no-n m: my @x = <a b c>; for @x.keys, @x -> ($k, $v) { .say "$k: $v" } # xinming
camelia 5===SORRY!5=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> 3b c>; for @x.keys, @x -> ($k, $v) { .say7⏏5 "$k: $v" } # xinming
expecting any of:
infix
infix stopper
statement end…
xinming no-n: No, Not this.
no-n hm
xinming m: my @x = <a b c>; my @y = <x y>; %( @x Z=> @y).perl.say; <--- This one shouldn't have for loop. 07:03
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in quote words; couldn't find final '>' (corresponding starter was at line 1)
at <tmp>:1
------> 3 <--- This one shouldn't have for loop.7⏏5<EOL>
expecting an…
no-n m: my @x = <a b c>; for (zip @x.keys, @x) -> ($k, $v) { say "$k => $v" } #ooops 07:05
camelia 0 => a
1 => b
2 => c
xinming Stil have for. 07:06
If I wish to use for, I wouldn't ask this question, It's all for shorter and shorter statement 07:07
cpan-raku New module released to CPAN! OLE::Storage_Lite (0.0.1) by 03JGOFF 07:08
Xliff m: my @x = <a b c>; my @y = <x y>; %( @x Z=> @y).perl.say; 07:28
camelia {:a("x"), :b("y")}
Xliff m: my @x = <a b c>; my @y = <x y>; my $h = %( @x Z=> @y).perl.say; $h.^name.say 07:29
camelia {:a("x"), :b("y")}
Bool
Xliff m: my @x = <a b c>; my @y = <x y>; my $h = %( @x Z=> @y); $h.perl.say; $h.^name.say
camelia ${:a("x"), :b("y")}
Hash
SmokeMachine m: say <a b c>.kv 07:31
camelia (0 a 1 b 2 c)
SmokeMachine Xliff: I’ve answered your comment... 07:34
xinming m: my @x = <a b c>; my @y = <x y>; %( @x Z=> @y).perl.say; 07:39
camelia {:a("x"), :b("y")}
xinming SmokeMachine: In this example, How can we also force the length of @x for the resulting hash?
SmokeMachine m: my @x = <a b c>; my @y = <x y>;  %( @x Z=> @y.pairs).perl.say # xinming something like this? 07:46
camelia {:a(0 => "x"), :b(1 => "y")}
xinming SmokeMachine: Nope 07:55
m: my @x = <a b c>; my @y = <x y>; %( @x.keys.map({ @x[$_] => @y[$_] }) ).perl.say;
camelia {:a("x"), :b("y"), :c(Any)}
daxim p6: class Foobar {}; my $A = [Foobar.new, Foobar.new]; my $L = (Foobar.new, Foobar.new); multi sub someop(Iterable[Foobar] $f) {}; someop($A); someop($L); 08:24
camelia Cannot resolve caller someop(Array:D); none of these signatures match:
(Iterable[Foobar] $f)
in block <unit> at <tmp> line 1
daxim how do you write a type constraint where all elems of an iterable are instances of the same class?
moritz daxim: you don't, because iterables aren't usually fully reified at the time of type checks, so you cannot check all the elements at type check time 08:35
lizmat weekly: github.com/drforr/raku-OLE-Storage_Lite 08:36
notable6 lizmat, Noted! (weekly)
Geth ecosystem: ec65603d34 | 0racle++ (committed using GitHub Web editor) | META.list
Remove File::Stat and Point. They're on CPAN.
09:31
cpan-raku New module released to CPAN! Desktop::Notify (1.0.0) by 03FRITH 10:29
xinming m: my @h; my @n; @n.push: @h; @h = <a b c>; @n.push: @(@h); @n.perl.say; 11:35
camelia [["a", "b", "c"], ["a", "b", "c"]]
xinming m: my @h; my @n; @n.push: @h; @h = <a b c>; @n.push: [@h]; @n.perl.say;
camelia [["a", "b", "c"], ["a", "b", "c"]]
xinming m: my @h; my @n; @n.push: @h; @h = <a b c>; @n.push: @h,; @n.perl.say;
camelia [["a", "b", "c"], ["a", "b", "c"]]
xinming m: my @h = <a b c>; my @n; @n.push: @(@h); @h = <x y z>; @n.push: @(@h); @n.perl.say 11:36
camelia [["x", "y", "z"], ["x", "y", "z"]]
xinming my @h = <a b c>; my @n; @n.push: [@h]; @h = <x y z>; @n.push: @(@h); @n.perl.say;
evalable6 [["a", "b", "c"], ["x", "y", "z"]]
xinming Anyone here can explain the semantic about this for me please? the diff between @(@h) and [@h] 11:37
before, I thought that @(@h) is the same as [@h]; But it's definitely wrong in this case.
As I thought that @() is an array constructor which is like %() does
jnthn @(@h) means @h.list, but it already is listy, so it's just the identity function
xinming Ok, Thanks, I thought that @() is the same as %() :-) 11:38
jnthn [@h] iterates @h (per single argument rule) and creates an new array with the values produced by the iteration
It is
%(%h) is also the identity function
It's just that you probably usually pass something that is not hashish. 11:39
xinming So, If we want to copy the content, and push it, We should call something like @a[] ?
jnthn You should probably just call append :)
xinming Ok, :-)
jnthn But yes, you can do the zen slice too.
But append will be more efficient
Tirifto Thanks for the tip, guifa! I'll see if I could make that work for me… 13:35
p6: class A {has Str $.msg is rw;} class B {has A $!a; method speak () {$!a.msg.say}} my $a = A.new(msg => “Boo!”); my $b = B.new(a => $a); $b.speak(); 13:43
camelia 5===SORRY!5=== Error while compiling <tmp>
Strange text after block (missing semicolon or comma?)
at <tmp>:1
------> 3class A {has Str $.msg is rw;}7⏏5 class B {has A $!a; method speak () {
expecting any of:
infix
Tirifto p6: class A {has Str $.msg is rw;}; class B {has A $!a; method speak () {$!a.msg.say}}; my $a = A.new(msg => “Boo!”); my $b = B.new(a => $a); $b.speak(); 13:46
camelia Cannot look up attributes in a A type object
in method msg at <tmp> line 1
in method speak at <tmp> line 1
in block <unit> at <tmp> line 1
sena_kun Tirifto, your attribute must be public for automagically generated constructor to initialize that 13:48
m: class A {has Str $.msg is rw;}; class B {has A $.a; method speak () {$!a.msg.say}}; my $a = A.new(msg => “Boo!”); my $b = B.new(a => $a); $b.speak();
camelia Boo!
sena_kun otherwise you need to provide implementation of `BUILD` submethod... 13:49
m: class A {has Str $.msg is rw;}; class B {has A $!a; submethod BUILD(:$a) { $!a = $a }; method speak () {$!a.msg.say}}; my $a = A.new(msg => “Boo!”); my $b = B.new(a => $a); $b.speak();
camelia Boo!
sena_kun Tirifto, ^
Tirifto sena_kun: I have experimented with the twigil, but I don't understand why it matters. I thought an attribute would always be accessible from within its object, and that the only thing the ‘.’ twigil would do is generate an accessor method, which should have no effect on referencing the attribute directly via ‘$!’. Apparently I'm missing something here? :/ 13:52
jnthn Tirifto: The . doesn't just generate an accessor, it also means that attribute can be initialized using the default object construction mechanism. 13:59
(It also controls whether it's included in the .raku dump output, and also the default destructuring) 14:00
Tirifto jnthn: Since I'm giving B.new an object which has already been constructed ($a) in the example above, what exactly does the class need to construct when assigning $a to $b’s $!a? 14:03
jnthn m: class C { has $.a }; say C.new(a => 42).a 14:05
camelia 42
jnthn m: class C { has $!a }; say C.new(a => 42).a
camelia No such method 'a' for invocant of type 'C'
in block <unit> at <tmp> line 1
jnthn hah, of course :)
m: class C { has $.a; method m() { say $!a } }; say C.new(a => 42).m
camelia 42
True
jnthn m: class C { has $!a; method m() { say $!a } }; say C.new(a => 42).m
camelia (Any)
True
jnthn That's what I wanted to show.
It won't initialize $!a from a named constructor argument `a` in the second case 14:06
So the point is that when it's declared with `$!a` is *isn't* assigning $a to $b's $!a 14:07
Tirifto Huh! I see. 14:08
jnthn This means that whenever you have a `has $!foo` in a class, then you know you can refactor it by only considering the code in the class body. 14:10
Geth please-turn-off-the-autowatch-feature: ac33fbf818 | (Aleks-Daniel Jakimenko-Aleksejev)++ | README.md
Add some text, should be good enough
14:18
Tirifto Thank you, jnthn; I’ve come to some level of understanding now. :-) 14:42
uzl[m] m: say "Hello", "world", "!"; 15:10
camelia Helloworld!
uzl[m] m: say log 32, 2;
camelia 5
uzl[m] m: log 32, 2; 15:11
camelia WARNINGS for <tmp>:
Useless use of "log 32, 2" in expression "log 32, 2" in sink context (line 1)
uzl[m] Kind of weird. I was getting "Two terms in a row\n------> log⏏ 32, 2" for the same expression in the REPL. Probably I was inserting some non-visible character?! 15:14
MasterDuke the repl has a bunch of known problems, maybe you just found a new one? 15:16
uzl[m] Yeah, that's probable. 15:42
[Coke] works fine here. is it reproducible on a fresh run of the REPL for you? If so, what version of perl6 are you using?
Geth rakudo.org: 26dd1dac1b | (Daniel Mita)++ (committed using GitHub Web editor) | templates/people.html.ep
Replace broken hugtastic link
15:49
Tirifto (Works fine here, too, for what it’s worth.) 15:52
[Coke] ugh, -7ºC here today 16:10
Tirifto [Coke]: Have you got a sweater? 16:26
lizmat +13ºC here 16:29
which is a local record
too bad it was really rainy and overcast as well
Tirifto Min or max record? :o 16:30
[Coke] Tirifto: I was out in shorts earlier today, guess I shouldn't complain. 16:31
Wearing a coat in my house atm, though.
lizmat Tirifto: max 16:33
cpan-raku New module released to CPAN! Gnome::GObject (0.15.8) by 03MARTIMM 16:35
Tirifto Well, on the bright side, you get the opportunity to use a coat and an umbrella respectively, both of which are pretty cool articles! 16:47
cpan-raku New module released to CPAN! Gnome::Gtk3 (0.21.1.2) by 03MARTIMM 16:48
Tirifto And it looks like I can make a wrapper object to selectively block write access to a certain object’s attributes by adding that object as an attribute which handles whatever, and then overriding its read accessors with my custom ones, whereafter the default write accessors no longer appear to work on it. 16:51
(Although I don't know how the default write accessor is implemented, given that just setting a custom read accessor can invalidate it; might be missing something still.) 16:55
lizmat Tirifto: you only need to make sure the return value of the original accessor is decontainerized
Geth ¦ problem-solving: AlexDaniel assigned to JJ Issue SEO for the keyword "rakulang" seems poor github.com/Raku/problem-solving/issues/147 16:57
lizmat m: class A { has $.a is rw = 42 }; role B { method a() { callsame<> } }; my $a := A.new; my $b := $a but B; dd $b.a = 666 # Tirifto 17:00
camelia Cannot modify an immutable Int (42)
in block <unit> at <tmp> line 1
Tirifto lizmat: Thanks for the example; I'll need to sit on that for a while. xP 17:04
lizmat the <> is the decontainerization
kktt007 ddd 17:12
jnthn lizmat: Not sure you need to decont since method a is not marked `is rw` nor `is raw`, so it will strip the container anyway :) 17:13
lizmat m: class A { has $.a is rw = 42 }; role B { method a() { callsame } }; my $a := A.new; my $b := $a but B; dd $b.a = 666 # Tirifto 17:14
camelia Cannot modify an immutable Int (42)
in block <unit> at <tmp> line 1
lizmat he
TIL
or rather, TIR (Today I Realized :-) 17:18
jmerelo Hi 17:37
Is there any way to map a number to an unicode character? That number is computed or in a variable
I'm trying this, but it does not work, probably for a good reason 17:38
m: say "\c[{ 0x25A1 + 2 } ]"
camelia 5===SORRY!5=== Error while compiling <tmp>
Unrecognized \c character
at <tmp>:1
------> 3say "\c[7⏏5{ 0x25A1 + 2 } ]"
expecting any of:
argument list
double quotes
term
Grinnz chr()? 17:39
jmerelo Grinnz: oh yes
Sorry
m: say char( 0x25A1 + 2 )
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared routine:
char used at line 1. Did you mean 'chars', 'chr'?
jmerelo m: say chr( 0x25A1 + 2 )
camelia
jmerelo I mean, really
jmerelo smacks head and goes back to work 17:40
thanks Grinnz!
uzl[m] Coke: It's working fine here too. I guess I somehow inserted a nonvisible character 😅�😅�. I'm using Rakudo 2019.11. 17:45
tbrowder hi, #raku people 17:49
tellable6 2020-01-03T08:14:17Z #raku <jmerelo> tbrowder raku-advent.blog is cool.
jmerelo Hi, tbrowder ! 17:50
tbrowder we now have doman raku-advent.blog for our own
jmerelo: hi
jmerelo tbrowder: great! 17:51
tbrowder i'm on holland-america's ms zuiderdam tied up at costa maya with internet access till this afternoon 17:52
jmerelo Have a great trip
For the time it's not working, but I guess DNS will catch up in a while.
tbrowder you can take the new domain and get it all set up? 17:52
jj, i just claimed it so it may be a while 17:53
tbrowder anyone interested in number bases check out my module Number::More 17:56
tbrowder i'm reworking it into a new, improved module Number::Rebase with up to base 91. one advantage of base 91 is to have a UUID in 20 characters of ASCII (good for RDBMS unique keys) 18:01
rywo if class attributes are $!foo and $.foo what is $foo in a class? a static field? 19:12
as in `class foo{ my $whatisthis }` 19:16
in contrast to `class foo{ has $!pravate }`
moritz it's just a variable that's lexical to the class body 19:25
(also, you need a space between the class name and the {)
rywo is it unique to each instance of the class? 19:31
moritz no 19:37
rywo ah ok. thanks. 19:53
Geth doc: 670d0af874 | (Stoned Elipot)++ | doc/Language/io.pod6
Fix link to unlink routine
21:39
cpan-raku New module released to CPAN! OLE::Storage_Lite (0.0.2) by 03JGOFF 22:26