🦋 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: ... | Logs can be inspected at colabti.org/irclogger/irclogger_log/raku
Set by lizmat on 1 May 2021.
[Coke] ugexe: that still gives a broken pipe exception 00:00
(but then it's not "unhandled")
Xliff Huh. Why doesn't this regex work? 02:18
replit.com/@Xliff/DimTrustworthyCo...#main.raku
tusooa Xliff: Not found error: This is not the page you're looking for. 02:21
If you think this is a mistake please contact us_
Xliff Hrm,,,
Xliff tusooa: Try this - replit.com/join/dyyhuasi-xliff 02:27
tusooa Xliff: it asked me to login 03:13
Xliff tusooa: OK, nevermind then. Thanks! 03:16
raydiak [Coke]: 'use NativeCall; sub signal(int32 $, int64 $) is native {}; signal(SIGPIPE, 0);' works on 64-bit linux. see github.com/rakudo/rakudo/issues/3004 and github.com/rakudo/rakudo/issues/4214 03:18
moon-child 0 is SIG_IGN? 03:39
kybr c++ has reinterpret_cast for saying "no. i really know this is type X" class Animal {...}; class Dog is Animal {...}; my $animal = Dog.new; # can i ask $animal if is really a dog? 05:24
err.. my Animal $animal = Dog.new ;
Xliff kybr: say $animal ~~ Dog; 05:25
m: class Animal { }; class Dog is Animal { }; my $animal = Dog.new; say $animal ~~ Dog; say $animal ~~ Animal; 05:26
camelia True
True
Xliff m: class Animal { }; class Dog is Animal { }; my $doc = Dog.new; my Animal $animal = $dog; say $animal ~~ Dog; say $animal ~~ Animal; 05:27
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable '$dog' is not declared. Did you mean any of these: '$doc',
'Dog'?
at <tmp>:1
------> 3 my $doc = Dog.new; my Animal $animal = 7⏏5$dog; say $animal ~~ Dog; say $animal ~~
Xliff m: class Animal { }; class Dog is Animal { }; my $dog = Dog.new; my Animal $animal = $dog; say $animal ~~ Dog; say $animal ~~ Animal;
camelia True
True
Xliff So even typed as Animal, $animal still knows its a Dog
kybr i see that, but i really want to write a method of Animal that uses introspection to give me a string that is the real (most specific) type of self. 05:28
Xliff m: class Animal { }; class Dog is Animal { }; my $dog = Dog.new; my Animal $animal = $dog; say $animal.^name
camelia Dog
Xliff There you go.
Unless I am missing something. If so, please let me know. 05:29
kybr maybe i'm missing something :) i think i need to collect my thoughts. thank you.
Xliff yw!
m: class Animal { }; class Dog is Animal { method bark { say 'Woof!' }; my $dog = Dog.new; my Animal $animal = $dog; say $animal.^name; $animal.bark 05:32
camelia 5===SORRY!5=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> 3 = $dog; say $animal.^name; $animal.bark7⏏5<EOL>
expecting any of:
statement end
statement modifier
statement modifier loo…
Xliff m: class Animal { }; class Dog is Animal { method bark { say 'Woof!' }; }; my $dog = Dog.new; my Animal $animal = $dog; say $animal.^name; $animal.bark
camelia Dog
Woof!
Xliff And on that note, I'm confused. If it's typed Animal, it should not know how to .bark() -- right? 05:33
moon-child m: class Animal {}; class Dog is Animal {}; class Cat is Animal {}; my Animal $a = Dog.new; my Dog $d = $a; my Cat $c = $a
camelia Type check failed in assignment to $c; expected Cat but got Dog (Dog.new)
in block <unit> at <tmp> line 1
moon-child Xliff: no, typing is gradual 05:34
Xliff moon-child: And that means?
moon-child $x ~~ Animal means $x can do _at least_ anything an Animal can, not at most
Xliff Ah. OK. That's what I suspected. Thanks!
kybr ha. how about this.. from an animal method, may i call a method on my dog-self? 05:35
Xliff moon-child: So all "my Animal $a" means is that $a ~~ Animal MUST be true. Right?
kybr sort of the opposite dirrection of callsame
Xliff kybr: I'm confused by the question. Isn't that what I just demonstrated with .bark() ? 05:36
moon-child m: class Animal { method do-stuff { self.bark } }; class Dog is Animal { method bark { say 'woo' } }; my $d = Dog.new; $d.do-stuff
camelia woo
moon-child Xliff: to my understanding yes
Xliff class Animal { method do-stuff { self.bark } }; class Dog is Animal { method bark { say 'woo' } }; my $d = Dog.new; $d.do-stuff; my $emo = Animal.new; $emo.do-stuff 05:37
moon-child Xliff: well, $a ~~ Animal means Animal.ACCEPTS($a). So you could make your own ACCEPTS
Xliff m: class Animal { method do-stuff { self.bark } }; class Dog is Animal { method bark { say 'woo' } }; my $d = Dog.new; $d.do-stuff; my $emo = Animal.new; $emo.do-stuff
camelia woo
No such method 'bark' for invocant of type 'Animal'. Did you mean any
of these: 'Bag', 'WALK'?
in method do-stuff at <tmp> line 1
in block <unit> at <tmp> line 1
Xliff moon-child: I know that. I am asking about type checking.
Not .ACCEPTS.
moon-child afaik yes
Xliff So, as demonstrated, "my Animal $a" can do Dog's methods. 05:38
This is kinda counter-intuitive to most OOP implementations.
kybr Xliff: yes.
Xliff And with that, I must suspend all processes for a few hours. :) 05:39
Xliff &
moon-child night 05:40
kybr m class Parent { method show { self.defaults.signature}} ; class Child is Parent { method defaults($a, $b = 2, :$c = 3) {}};Child.show().say; 05:42
m: class Parent { method show { self.defaults.signature}} ; class Child is Parent { method defaults($a, $b = 2, :$c = 3) {}};Child.show().say;
camelia Too few positionals passed; expected 2 or 3 arguments but got 1
in method defaults at <tmp> line 1
in method show at <tmp> line 1
in block <unit> at <tmp> line 1
kybr it's not really that i want to call a method on the dog as inspect it's signature. 05:43
kybr i want to refer to a method (defaults) without calling it 05:49
raydiak m: class Parent { method show { self.WHAT.^methods.first(*.name eq "defaults").signature } }; class Child is Parent { method defaults ($a, $b = 2, :$c = 3) {} }; Child.show.say; 06:01
camelia (Child: $a, $b = 2, :$c = 3, *%_)
raydiak I'm not sure what you're hoping to accomplish, and I'm actually afk for now, but it kinda sounds like you might want to re-think your class heirarchy or whatever architectural choices led to this need 06:06
kybr raydiak: yes! that's what i wanted. and Yes! your are almost certainly correct that i need to rethink how i'm designing things. 06:28
raydiak kybr: glad I could help :) 07:42
codesections that's a fun error msg: 10:37
m: my Int $a; $a.VAR.abs
camelia No such method 'abs' for invocant of type 'Int'. Did you mean 'abs'?
in block <unit> at <tmp> line 1
tbrowder g'day, i have a question about unicode and first word char match. the result i want is to separate a set of words into 4 sets based on their first character. but there seem to be several <:charprop> codes that are similar. 12:18
the 4 sets should be lower-case <:Lc>, upper-case <:Uc>, number <:Nu>, and punctuation <:P> 12:21
sorry, too early 12:22
tbrowder again: <:LI>, <:Lu>, <:N>, and <:P>. will those sets be mutually exclusive but complete? 12:24
given a match on the first char of a word? 12:25
tbrowder kyber: and look into roles, too 12:31
roles solved some subclass problems for me 12:32
kybr: ^^^
thundergnat tbrowder: Depending on your word list, that should be fairly complete. A few words with initial characters that _won't_ fall into one of those categories: $100, +47, Džungla 13:06
tbrowder thundergnat: i see $ won't, but why Dzugla? 15:25
tbrowder is it that Dz is a combined/composed thing? 15:26
btw, i am working on my Abbreviations module to fix what i see is a problem with your auto-abbreviations 15:27
tbrowder it didn't make sense to me that the list 'A ab Abcde' came out wth 3 until i realized that i could break the analysis into subgroups by leading char type 15:30
no, the problem is not yours, the problem is my using it
um, let me check the above statement again... 15:32
tbrowder word set 'A ab Abcde' shows 2 but i wondered why the ab couldn't be 'a ab' as abbrevs. that's when i decided to start breaking word sets into subgroups when it is appropriate. based on your comments i may add a couple more subgroups and then have a catchall group. 15:38
thank!
tbrowder thundergnat: i'll add <:S> for symbol and put all else into a catch-all group (unless you can tell me how to catch 'Dz' 16:06
codesections is there a good way to wrap a fn for its next call, but then unwrap it after? e.g, a .wrap-once equivalent? 16:39
thundergnat tbrowder: Sorry, got an emergency call in to work right after my last comment. Copy pasto, that third one should have been Džungla (Dž ligature) with a :Lt property (title case). 17:33
They are obscure but exist. 17:34
m: say .key, '=>', .value.head(5) for (^1000).map(*.chr).classify( { .substr(0,1).uniprop } ) 17:35
camelia Zs=>(  )
Sk=>(^ ` ¨ ¯ ´)
Cf=>(­)
Lt=>(Dž Lj Nj Dz)
Sm=>(+ < = > |)
Cc=>(␀ )
Mn=>(̀ ́ ̂ ̃ ̄)
No=>(² ³ ¹ ¼ ½)
Pe=>() ] })
Sc=>($ ¢ £ ¤ ¥)
Lu=>(A B C D E)
Lm=>(ʰ ʱ ʲ ʳ ʴ)
Pd=>(-)
Lo=>(ª º ƻ …
tbrowder so probably i should add that group anyway, just for **fun** :-D
tbrowder or add them to the <:Lu> group 17:36
tbrowder i assume this regex should work /^ <:Lu>|<:Lt>/ for that 17:39
tbrowder hm, maybe that's overkill. just upper/lower case and all else in another group 17:45
once i have the subgrouping, if a user requests i can easily add other groups. 17:46
tbrowder thanks so much 17:46
oddp i have a pipeline like so: .comb.map(...).produce(* + *).unique; now, what's an elegant way to insert 0 into that seq before .unique since .produce doesn't allow a custom starting value? 18:59
tellable6 2021-05-07T06:43:02Z #raku <gfldex> oddp this migth do what you want: gfldex.wordpress.com/2021/01/03/in...direction/
oddp Might not be able to keep that one-liner with seq and instead have to collect into an array and then push 0 onto it, right? 19:04
lizmat perhaps some form of ... ?
oddp huh? i'm converting a small dlang script that allows setting a custom seed value for cumulativeFold/produce 19:06
ugexe .map({ $++ ?? $_ !! (0,$_).Slip }) 19:12
lizmat perhaps Seq should have an .inject method :-) 19:15
oddp interesting, thanks, will try to integrate that somehow. map has a bunch of these atm: when '>' { -1i }; when '<' { i }; ... 19:16
ugexe .map({ my $val = do given $_ { when Str { 1 }; when Int { 2 }; }; $++ ?? $val !! (0,$val).Slip }) 19:18
oddp thanks for that, appreciated! 19:23
oddp what do you say, is this also acceptable? or not recommended because it allocates too much? my $foo = ...produce(* + *); say unique(|0, |$foo).elems; 19:32
ugexe only if $foo will be less than 65535 values 19:35
ugexe m: my $foo = 0..65535; say unique(|0, |$foo).elems 19:36
camelia Too many arguments (65537) in flattening array, only 65535 allowed.
in block <unit> at <tmp> line 1
ugexe m: my $foo = 0..65535; say unique(|0, $foo.Slip).elems
camelia 65536
oddp damn, good to know, thanks! 19:37
MasterDuke m: my $foo = 0..65535; say (|0, |$foo).unique.elems # method form is fine 19:39
camelia 65536
oddp sweet, prolly sticking to that for now then. thank you! 19:44
kybr i can't remmeber where, but i think i've seen an impressive, succinct list of Raku language features and boasts. maybe in a presentation? was it shaped like a christmas tree? 20:16
Anton I am trying out the package Math::Matrix ( github.com/pierre-vigier/Perl6-Math-Matrix ). I wonder should use Math::Matrix or Math::Libgsl::LinearAlgebra. Has anyone used Math::Matrix for "serious" matrix computation workflows? 21:07
tbrowder .tell kybr checkout my 2021 advent post about santa claus and raku: a christmas tree forming a raku script 22:02
tellable6 tbrowder, I'll pass your message to kybr
tbrowder uh, 2020, that is 22:03
kybr i found it in a talk Larry Wall gave and i found a good list of feature in the FAQ, but i'd love to see others. 22:04
oddp m: multi sub foo($x) { 'no' }; multi sub foo($x where *.Int) { 'ok' }; say foo $_ for <a 1 0>; 22:59
camelia no
ok
no
oddp is the last case really expected behaviour?
oddp hm, foo($x where /\d+/) seems to work, good enough i guess 23:12
ugexe m: say ① ~~ /\d+/; # a friendly reminder that \d+ is not a very good integer validator 23:31
camelia 「1」
moon-child eh what's wrong with that 23:33
m: my Int $x = ①
camelia ( no output )
ugexe its cute but not really what most people expect when validating things 23:34
oddp well, '0' not getting caught by the above multi sub is even more unexpected 23:35
ugexe where False 23:36
where 0
oddp still
ugexe *.Int returns an Int, what do you think it does?
i.e. its not checking if * is an Int 23:37
m: multi sub foo($x) { "no" }; multi sub foo(Int $x) { "ok" }; say foo $_ for <a 1 0>; 23:39
camelia no
ok
ok
oddp alright, thanks for that. now i just have to figure out, why that's not working for my actual script 23:49
oddp seems like the above isn't working when recursive calls are involved 23:59