»ö« Welcome to Perl 6! | perl6.org/ | evalbot usage: 'p6: say 3;' or rakudo:, or /msg camelia p6: ... | irclog: irc.perl6.org or colabti.org/irclogger/irclogger_logs/perl6 | UTF-8 is our friend!
Set by moritz on 22 December 2015.
00:08 khw left 00:19 tphilipp joined 00:24 tphilipp left 00:33 spider-mario left 00:50 tphilipp joined 00:52 telex left 00:58 cpage_ joined 01:08 telex joined 01:26 kurahaupo left 01:32 cdg joined 01:38 molaf left 01:42 kurahaupo joined 01:47 _nadim left
AlexDaniel we have s/a/b/ and S/a/b/, but what is the S-like equivalent for tr/a/b/ ? 01:48
m: $_ = ‘abc’; TR/a/X/ 01:49
camelia rakudo-moar b3b24b: OUTPUT«5===SORRY!5=== Error while compiling /tmp/fBdlU7XUZ9␤Missing required term after infix␤at /tmp/fBdlU7XUZ9:1␤------> 3$_ = ‘abc’; TR/a/X/7⏏5<EOL>␤ expecting any of:␤ prefix␤ term␤»
AlexDaniel Hotkeys: I've figured that it is possible to make S/‘ ’/_/ shorter if we had TR 01:50
Hotkeys ik
01:50 _nadim joined
Hotkeys I tried it when you first mentioned it 01:51
01:51 molaf joined
AlexDaniel Hotkeys: then where's your bug report? :) 01:51
Hotkeys I didn't realize it was a bug
AlexDaniel well, not a bug, but in my opinion it is a sad inconsistency
01:53 _nadim left 02:05 aindilis joined
AlexDaniel m: my $x := (my $y := $x); say $x.WHAT # let's see if it is still an issue… 02:06
camelia rakudo-moar b3b24b: OUTPUT«(signal SEGV)»
02:08 kurahaupo left
AlexDaniel haha, due to mass renaming of tickets in RT the main page is now full of SEGVs :D 02:10
02:13 aindilis left 02:14 kurahaupo joined 02:16 aindilis joined 02:18 tphilipp left
Xliff Hello. 02:18
My class definition starts with the following: 02:19
class XQC_Implementation_s is repr('CStruct') is export
02:19 kurahaupo left
Xliff Why is there no self reference in this class? 02:19
m: class A { method b { say self; } }; $a = A.new.b() 02:20
camelia rakudo-moar b3b24b: OUTPUT«5===SORRY!5=== Error while compiling /tmp/GrjwczkEhQ␤Variable '$a' is not declared␤at /tmp/GrjwczkEhQ:1␤------> 3class A { method b { say self; } }; 7⏏5$a = A.new.b()␤»
Xliff m: class A { method b { say self; } }; my $a = A.new.b()
camelia rakudo-moar b3b24b: OUTPUT«A.new␤»
02:24 _nadim joined 02:27 _nadim left 02:33 sortiz joined
sortiz \o #perl6 02:34
Xliff Sortiz.... how do you specify destructor for class that has access to self? 02:35
method DESTROY {}
?
sortiz, (Oh, and good evening... sorry...focused)
sortiz Use 'submethod DESTROY() { ... }' 02:36
Xliff Thanks. Will "say" produce any output if used within that method?
sortiz Yes, but don't expect that destruction happen in an deterministic time! 02:37
Xliff Ah. So expecting it to happen in -e one-liner is probably too much to hope for? 02:38
02:38 raoulvdberge left
sortiz Yep. 02:38
Xliff kk. Thanks.
sortiz I see you are working with native bindings, so I suggest you implement some kind of .dispose methods when need explicit deallocation, for example. 02:40
02:40 Herby_ joined
Herby_ Evening, everyone! 02:41
sortiz \o Herby_
Herby_ o/
02:42 noganex_ joined
nchambers o 02:42
o/
Herby_ \o/
nchambers whats everyone up to tonight? 02:43
Herby_ trying to find an interesting project to tackle with perl 6 02:44
coming up empty so far
yourself?
02:45 noganex left
sortiz Converting Oracle::Native to OO :) 02:45
BenGoldberg Herby_, how about this: create a perl6 irc plugin for </insert favorite irc client here> ! ;) 02:46
Hotkeys yes please do one for weechat and hexchat 02:47
Herby_ hmm. can't say i know much about that business. you know of a good starting point?
BenGoldberg Well, what's your irc client? 02:48
BenGoldberg is a hexchat user.
sortiz hexchat too 02:49
nchambers Herby_, installing an ubuntu server, considering downloading the new a-team movie (well "new"), thinking of some more things I could write in perl
Herby_ webchat.freenode.net :(
nchambers lame
02:49 skids joined
nchambers at least use kiwiirc 02:49
Herby_ BenGoldberg: reading up on the hexchat plugin interface now 02:50
BenGoldberg Hexchat has a decently documented C API for plugins; the python plugin and perl(5) plugins make use of the C API 02:51
Herby_ i'm a rookie that hasn't dealt too much with APIs or plugins... this seem pretty doable with perl 6?
BenGoldberg How's your C skills? 02:52
Herby_ I can spell it
i've dabbled some :)
BenGoldberg Basically, to create a perl6 plugin for hexchat, you would have to create a .dll file, which has a function named hexchat_plugin_init, which will get called by hexchat after it loads the .dll file. This entry point does all the heavy lifting, e.g., loading the perl6 interpreter. 02:55
02:55 nadim joined
Xliff \o Herby 02:57
Herby_ Xliff!
BenGoldberg Each real plugin (perl, python, whatever) can create "fake" plugins, usually one for each script. These fake plugins show up on the plugin list, and you can click on them, and unload/reload. 02:58
Herby_ BenGoldberg: sounds interesting/challenging. I'll see what I can dig up
02:58 telex left
Xliff Ouch. 02:59
OK. I have a NativeCall implementation that passes back a C struct with callback pointers.
02:59 nadim left
Xliff How can I execute the callbacks? 02:59
03:00 telex joined
Xliff I'm getting the following error when I try to use the callbacks as a method call 03:01
» Too many positionals passed; expected 1 argument but got 5
sortiz Xliff, If you have a pointer to a C func, you need to attach to it a signature first. 03:03
Xliff OK
sortiz See github.com/rakudo/rakudo/blob/nom/...pointers.t for an example.
Xliff Thanks much! 03:04
sortiz For attach the signature you need 'nativecast'
yw 03:05
Xliff Hrm. Where are actual docs on nativecast()? 03:07
Skarsnik there is none ^^ 03:08
Xliff Yikes!
03:09 Skarsnik left, rindolf left
Xliff So...if I understand this right.... 03:16
sortiz Add more NC docs is a task that I have queued.
Xliff my $func_ptr_w_sig = nativecast(:(type, type[, ...type] --> return_type, $func_ptr) 03:17
Or...
my $func_ptr_w_sig = nativecast(:(type, type[, ...type] --> return_type), $func_ptr)
sortiz Yep.
Xliff ok.
Yow... that makes this a little... harder....LOL! 03:18
sortiz Better: my &func_ptr_w_sig = nativecast(:(type, type[, ...type] --> return_type), $func_ptr); # See the '&' sigil.
Xliff OK. So no clean way to do it without defining methods and making the call. 03:19
So. 03:20
teatime you gotta know the arguments to call a function, if all you have is its address :)
sortiz Can't be a way for NC to infer that, you only have a pointer.
Xliff m: class A { has Pointer $!meth1; method meth1(Int) { say "Hi!" } }; say A.new.meth1(1)
camelia rakudo-moar b3b24b: OUTPUT«5===SORRY!5===␤Type 'Pointer' is not declared␤at /tmp/DY3lcLzr37:1␤------> 3class A { has Pointer7⏏5 $!meth1; method meth1(Int) { say "Hi!" ␤Malformed has␤at /tmp/DY3lcLzr37:1␤------> 3class A { has7⏏5 Pointer $!meth1; method met…»
03:21 kaare_ joined
Xliff m: class A { has Str $!meth1; method meth1(Int) { say "Hi!" } }; say A.new.meth1(1) 03:21
camelia rakudo-moar b3b24b: OUTPUT«Hi!␤True␤»
Xliff Oh, good!
m: class A { has Str $!meth1; method meth1(Int) { say "Hi!" } method meth2 { $!meth1 = "A" x 3; say $!meth1 } }; say A.new.meth1(1) 03:22
camelia rakudo-moar b3b24b: OUTPUT«5===SORRY!5=== Error while compiling /tmp/SjW79owpFO␤Strange text after block (missing semicolon or comma?)␤at /tmp/SjW79owpFO:1␤------> 3$!meth1; method meth1(Int) { say "Hi!" }7⏏5 method meth2 { $!meth1 = "A" x 3; say $␤ expecting an…»
Xliff m: class A { has Str $!meth1; method meth1(Int) { say "Hi!" } method meth2 { $!meth1 = "A" x 3; say $!meth1; } }; say A.new.meth1(1)
camelia rakudo-moar b3b24b: OUTPUT«5===SORRY!5=== Error while compiling /tmp/Ad4XmTpSnl␤Strange text after block (missing semicolon or comma?)␤at /tmp/Ad4XmTpSnl:1␤------> 3$!meth1; method meth1(Int) { say "Hi!" }7⏏5 method meth2 { $!meth1 = "A" x 3; say $␤ expecting an…»
Xliff m: class A { has Str $!meth1; method meth1(Int) { say "Hi!" }; method meth2 { $!meth1 = "A" x 3; say $!meth1; } }; say A.new.meth1(1);
camelia rakudo-moar b3b24b: OUTPUT«Hi!␤True␤»
Xliff m: class A { has Str $!meth1; method meth1(Int) { say "Hi!" }; method meth2 { $!meth1 = "A" x 3; say $!meth1; } }; my $a = A.new; $a.meth1(1) $a.meth2(); 03:23
camelia rakudo-moar b3b24b: OUTPUT«5===SORRY!5=== Error while compiling /tmp/1KBi5hFj32␤Two terms in a row␤at /tmp/1KBi5hFj32:1␤------> 3$!meth1; } }; my $a = A.new; $a.meth1(1)7⏏5 $a.meth2();␤ expecting any of:␤ infix␤ infix stopper␤ statemen…»
Xliff m: class A { has Str $!meth1; method meth1(Int) { say "Hi!" }; method meth2 { $!meth1 = "A" x 3; say $!meth1; } }; my $a = A.new; $a.meth1(1); $a.meth2();
camelia rakudo-moar b3b24b: OUTPUT«Hi!␤AAA␤»
03:28 AlexDaniel left
Xliff OK. So if a function is expecting a pointer to a struct (or class), can I just pass that class instance? 03:32
my $i = ClassName.new; func_expects_class_ptr($i); <- ??? 03:33
03:46 nadim joined 03:48 nadim left
diakopter maybe of interest - KestrelInstitute open-sourced Specware (language name MetaSlang) on github 03:54
www.specware.org/documentation/4.2/...Manual.pdf 03:56
03:56 kid511 left 03:58 Ben_Goldberg joined 03:59 BenGoldberg left, Ben_Goldberg is now known as BenGoldberg 04:02 Vlavv_ left 04:03 labster left 04:14 geekosaur left, geekosaur joined 04:15 Vlavv_ joined 04:17 _nadim joined 04:18 _nadim left 04:25 nadim joined
Xliff Does anyone know if NativeCall can handle C's FILE* ? 04:25
And how that could be passed to a NativeCall routine?
teatime if you already have the FILE* returned from something else native, then you can pass to something native like any other pointer. 04:27
04:28 Sgeo__ left 04:29 Sgeo joined 04:30 cdg left 04:31 nadim left
teatime you can get a FILE* from a Perl IO::Handle by passing .native-descriptor to native fdopen()... and you can get a file descriptor from a FILE* with fileno(), but I don't know how to turn that into a Perl IO object. I would be interested to know if there's anything in NativeCall to help w/ any of that, don't remember seeing anything. 04:33
04:35 labster joined
BenGoldberg Well, one thing you can do is write: class FILE is repr('CPointer') { }, to make C FILE* pointers easier to deal with... 04:37
teatime I've seen that example before; how does it help over just using OpaquePointer or Pointer ? 04:38
just that you can call it FILE fp in your code?
skids Maybe because you can add methods? 04:39
teatime ah, that makes sense. 04:40
but you cannot add attributes, or did I mis-understand that?
04:41 Cabanossi left
skids Right, no attributes because the REPR does not support it. 04:41
teatime and methods don't count as a kind of attribute?
04:42 nadim joined
teatime I guess when I read no attributes I assumed that meant no methods either. 04:42
skids Basically things that are stored per-class instead of per-instance are allowed.
methods are per-class. 04:43
04:43 Cabanossi joined
teatime perfect, thanks. 04:43
BenGoldberg For that matter, you can put such things as 'my sub feof(FILE) returns int is native { ... }' inside of the 'class FILE { ... }' definition, where they won't be externally visibile.
In this case, it's a silly way to do it, since the stdio interface won't ever change, but for some other library, you might want to 'hide' the C API, and present only perlish methods. 04:45
So if the underlying C library changes it's API in the future, there will be less risk that someone using your code will be relying on those private functions. 04:46
04:48 nadim left
teatime if you did need to track more state on the perl side, your class could also be a normal class w/ an attribute that's a pointer, right? 04:48
BenGoldberg If you wanted to, sure. 04:49
skids Sure, and you could have both -- the CPointer-based class as an attribute.
04:51 _nadim joined 04:54 _nadim left 04:56 Ben_Goldberg joined, _nadim joined 04:58 BenGoldberg left, Ben_Goldberg is now known as BenGoldberg
Xliff <teatime> you can get a FILE* from a Perl IO::Handle by passing .native-descriptor to native fdopen() 04:59
Wow... OK.
Working with NativeCall is more .... interesting... than I thought.
05:01 _nadim left
Xliff I hope to avoid making a true class, but it's looking like that might not be in the cards. 05:01
Mainly because the C API is a wrapper to C++ classes and methods.
teatime At least, I assume that's true; I haven't tried it.
Xliff So the C API I am trying to wrap is a struct filled with function pointers.
05:01 labster left
Xliff And they use a lot of **X where X is a struct/class for returning data. *sigh* 05:02
MadcapJake Xliff: yeah that sounds complicated
Xliff ErrStruct * = functionCall(arg1, arg2, **X) 05:03
MadcapJake maybe right a C file that has a few helper methods that pull out struct's internal data
Xliff It's fairly nifty for a C implementation, but moving that to Perl6 is showing a few difficulties... especially with my understanding of Perl6.
It's a great learning opportunity, but one that I'm probably not ready for at this moment. 05:04
Soo.... 05:10
sub fdopen(int, char)
is nativelib('libc')
returns Pointer { * };
teatime heh, it appears you're testing my theory :) 05:11
Xliff Yeah. 05:12
05:12 nadim joined
Xliff I'll let you know if it blows up in my face. It's a good idea, though. 05:12
Oh.
my $a = "/path/to/file"; die "BZZZT!" unless $a.IO.e; <-- this is valid, right? 05:13
m: my $a = "/path/to/file"; die "BZZZT!" unless $a.IO.e;
camelia rakudo-moar b3b24b: OUTPUT«BZZZT!␤ in block <unit> at /tmp/S7_wiTRnjw line 1␤␤»
Xliff HAH! At least it compiles.
I hope the evalbot is protected against IO hacks like that.
teatime works here.
Xliff Thanks. 05:14
teatime m: say my $a = "/etc/passwd"; die "BZZZT!" unless $a.IO.e;
camelia rakudo-moar b3b24b: OUTPUT«/etc/passwd␤»
teatime m: say my $a = "/etc/NotAFile"; die "BZZZT!" unless $a.IO.e; 05:15
camelia rakudo-moar b3b24b: OUTPUT«/etc/NotAFile␤BZZZT!␤ in block <unit> at /tmp/Bhjooy6SKc line 1␤␤»
05:16 nadim left
Xliff Ahh crap. Would I need native free() to handle the FILE* once I'm done with it? 05:18
05:18 nadim joined 05:19 nadim left 05:20 Herby_ left
teatime hrm, that's a good question... normally no, you'd fclose() it... but that would also close() the fd Perl knows about, not sure if that would break stuff? 05:23
05:24 nadim joined
teatime and not fclose()'ing would be a mem leak, I beleive. 05:24
awwaiid To read a single line from stdin, should I do $*IN.lines(1).first ? 05:27
05:29 nadim left
awwaiid oh, 'get' 05:29
05:44 nadim joined 05:49 nadim left
Xliff my $f = open "API.pm",:r; <-- Is this the right way to open a file in perl6? I am getting "error at :" when I try. 05:51
05:56 buharin joined
Xliff Oh crap. Using "perl" instead of "perl6" again. 05:56
Definite sign of sleep deficiency. 05:57
saaki :) 06:03
Xliff It's either that or NativeCall is eating my brain! 06:05
Probably both.
06:08 CIAvash joined
sortiz Xliff, yep Start learning NC produces these symptoms at first :-) 06:08
06:14 Khisanth left 06:17 rindolf joined 06:20 BenGoldberg left
awwaiid Xliff: some slight sugar, I think you can do: my $f = open "API.pm" :r; # space instead of comma. Also :r is the default. I think you can also do: my $f = "API.pm".IO 06:21
Xliff awwaiid, thanks! 06:23
OK. How can I specify Unsigned Integer in NativeCall where I do not have to worry about word size of the processor?
Will "Int" work regardless of 32-bit or 64-bit processor?
teatime I imagine Int would map to a signed int? 06:25
if you want a specific size you need to use the uint64_t -style types. 06:26
Xliff That's the problem. I don't want to map to a specific size. I want to use a single type and let rakudo and the c-lib duke it out as to what should be used. 06:27
teatime well, at least, in C. Probably not in Perl, since Perl's definitions can't depend on the specific compiler used, which is what would really determin the size of 'unsigned int'?
Xliff Shit.
Because I can't assume that "unsigned int" is uint64 on a 32 bit lib, right?
teatime what is it for?
06:28 skids left
teatime there's size_t, garunteed to hold the maximum array index, but that also only seems to me to have meaning for a specific compiler, not for an architecture/word-size. 06:28
06:28 BenGoldberg joined
Xliff read(void *, unsigned int) <- I need to convert that to something suitable to nativecall() 06:28
06:29 Khisanth joined
Xliff nativecall(:(Pointer, uint32)....) would be dangerous on a 64 bit machine. 06:29
See my problem?
06:29 _nadim joined
teatime ssize_t read(int fd, void *buf, size_t count); 06:29
Xliff Not quite libc's read. 06:30
teatime yeah sorry copied wrong one, sec
Xliff It's XQilla's XQC_Input_Stream's method but I am trying to simplify so as to not confuse ppl.
teatime I see. 06:31
Xliff However, if you really want the confusion....
xqilla.sourceforge.net/docs/xqc-api...aa5a0e0c66 06:32
sortiz Right now NC don't do that magic, your code should test for that.
Xliff sortiz: OK. How can I test for word size in P6?
sortiz You can use, nativesizeof(Pointer) for example.
06:32 Ben_Goldberg joined
teatime I don't think that's the question you need to ask. 06:32
Xliff (was worried about that) 06:33
sortiz m: use NativeCall; say nativesizeof(Pointer);
camelia rakudo-moar b3b24b: OUTPUT«8␤»
Xliff m: use NativeCall; say nativesizeof(Int) 06:34
camelia rakudo-moar b3b24b: OUTPUT«NativeCall op sizeof expected type with CPointer, CStruct, CArray, P6int or P6num representation, but got a P6opaque␤ in sub nativesizeof at /home/camelia/rakudo-m-inst-1/share/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) line 399…»
Xliff m: use NativeCall; say nativesizeof(P6Int)
camelia rakudo-moar b3b24b: OUTPUT«5===SORRY!5=== Error while compiling /tmp/Q4HeewSnmz␤Undeclared name:␤ P6Int used at line 1␤␤»
06:34 _nadim left
Xliff m: use NativeCall; say nativesizeof(P6int) 06:34
camelia rakudo-moar b3b24b: OUTPUT«5===SORRY!5=== Error while compiling /tmp/J2foV6liHB␤Undeclared name:␤ P6int used at line 1␤␤»
Xliff m: use NativeCall; say nativesizeof(CPointer)
camelia rakudo-moar b3b24b: OUTPUT«5===SORRY!5=== Error while compiling /tmp/KDaBaU1Gyc␤Undeclared name:␤ CPointer used at line 1. Did you mean 'Pointer'?␤␤»
06:35 BenGoldberg left
Xliff m: use NativeCall; say nativesizeof(int) 06:35
camelia rakudo-moar b3b24b: OUTPUT«8␤»
sortiz And you can only use nativesizeof with native types.
teatime Xliff: unsigned int must be 2 bytes, so I think the right answer might be use an int type ≥ 2 bytes and never pass a value larger than 2^16-1 ?
06:35 BenGoldberg joined
Xliff teatime: Short answer-"Use uint32" 06:36
06:36 djbkd joined
teatime sortiz: how does it work if 2 compilers that use different values for sizeof(int) compile 2 libs you want to use; I assume you have to know sizes to use an ABI, and I assume most .h's specify specific sizes for their public ABIs, but it seems like a lot of stuff expects you to be writing C and using their .h so a type like 'int' works fine even if it compiles as different sizes on different platforms... 06:37
06:38 Ben_Goldberg left
teatime I realize that's a rambling and open-ended question, but what would I look up to learn more about these issues? 06:38
Xliff: rather, must be *at least* 2 bytes. 06:39
BenGoldberg Are you cross compileing?
Xliff BenGoldberg, no. 06:40
NativeCall module
teatime: Well, I will start with uint32 and then test it on a 64-bit machine and see if it breaks. 06:41
BenGoldberg If two compilers on the same machine have different sizes of int, then you will not be able to reliably use int for parameters of a function in a .dll
teatime BenGoldberg: I'm just trying to figure out how to get from the C world where I am OK with knowing "I'm using the same type both places and I know it's at least n bytes" to the Perl world where I need to actually know the exact size of the type.
Xliff That's the safest route I see.
teatime yeah, I was just thinking, what I need to read more about probably is shared libraries.
sortiz Yep, is a difficult question. I recommend to look the code of some projects to see some working solutions.
BenGoldberg Even in the C world, "int" is only the same both places if the compilers are configured the same. 06:42
teatime yes.
Xliff sortiz, Yeah. However I don't have time to search *all* of the projects for useful answers.
I'm lazy that way.
I'd need more detailed directions! =) 06:43
However, I think I have progressed far enough, today.
Much in part due to the help I have found here.
Thank you!
sortiz Te best advice I can give you is to use the *.h file and define and use compatible types. For example see github.com/perl6/DBIish/blob/maste...ve.pm6#L11 06:44
Xliff Now to poke at King's Road for a few minutes.
06:44 labster joined
BenGoldberg One way to deal with the problem is to compile a tiny C program which does nothing more than output sizeof(int) and exit. 06:44
BenGoldberg just realized it's waaay past his bedtime, g'night folks. 06:45
06:45 BenGoldberg left
Xliff It's not that I don't know sizeof(int). It's not a question of that. It's a question of where this code will eventually run. 06:45
Well....LOL.
stmuk_ ugexe: ok thanks 06:46
06:47 cpage__ joined 06:48 cpage_ left, cpage__ is now known as cpage_ 06:52 rindolf left 06:55 kurahaupo joined 06:57 djbkd_ joined 06:58 djbkd left, djbkd_ is now known as djbkd
djbkd 3 06:59
07:00 djbkd left 07:13 djbkd_ joined, buharin left 07:27 djbkd_ left, RabidGravy joined 07:34 firstdayonthejob joined 07:38 wamba joined 07:47 domidumont joined 07:51 domidumont left 07:52 domidumont joined 08:14 darutoko joined
RabidGravy Boom 08:25
yoleaux 2 Apr 2016 23:21Z <AlexDaniel> RabidGravy: just in case: if some website is not accepting your [email@hidden.address] email, then use my.n....a...me@gmail.com, because 100% websites accept dots in emails and gmail ignores them all.
teatime I thought the gmail addr w/o dots was unique from the addr w/ one or more dots 08:27
but all of the one-or-more dots addrs were equiv
08:27 Actualeyes joined 08:33 pecastro joined 08:34 keix joined 08:43 Actualeyes left
RabidGravy no, I think in the case of gmail the reverse is true 08:43
08:44 pecastro left
RabidGravy at least it was 08:45
AlexDaniel, I have a simpler solution. If some website doesn't accept a perfectly compliant e-mail address then I don't use it as it is fairly good indication the programmers don't know what they are doing 08:47
.seen supernovus 08:50
yoleaux I saw supernovus 28 Dec 2015 18:21Z in #perl6: <supernovus> At some point I should look at rakudobrew to replace my moon script that I've been using for the last 4 years.
08:51 pecastro joined
RabidGravy going to have a tinker with Template6 later, looks like he is merging PRs at any rate 08:53
08:55 _nadim joined, _nadim left, _nadim joined 09:12 domidumont left 09:17 geekosaur left 09:18 buharin joined 09:19 geekosaur joined 09:20 frithnanth joined 09:23 buharin left 09:24 buharin joined 09:25 Actualeyes joined 09:27 buharin left, wamba left
dalek ar: 377eb1f | (Naoum Hankache)++ | README:
fix typo
09:28
ar: 4a0028d | (Steve Mynott)++ | README:
Merge pull request #67 from hankache/patch-1

fix typo
09:29 buharin joined, spider-mario joined 09:30 buharin_ joined 09:31 wamba joined, buharin left, buharin_ left 09:39 pecastro left, Khisanth left 09:43 cyberviking joined, cyberviking left 09:44 buharin joined 09:48 cyberviking joined, cyberviking left 09:50 pecastro joined 09:51 TimToady joined 09:53 CIAvash left, TreyHarris left 09:55 Khisanth joined 09:58 TreyHarris joined 09:59 TEttinger left 10:01 frithnanth left 10:03 Khisanth left, Actualeyes left 10:04 Actualeyes joined 10:08 buharin left 10:13 buharin joined
_nadim Good morning. Here is something that I find very surprising when using roles and multis nopaste.linux-dev.org/?1041278 10:13
10:14 pecastro left
_nadim I can see why I would get that error message but it feels a bit wrong because it doesn't let one use roles to compose behavior based on the arguments passed to methods (IMHO) 10:14
what's even more surprising is that I ave another example where the error message is not displayed at all 10:16
And it doesn't do what I xpect it to either (but that is more open to debate) 10:17
10:21 pecastro joined
sortiz m: say Array ~~ List; # At first remember that Array is List. 10:21
camelia rakudo-moar b3b24b: OUTPUT«True␤»
_nadim I certainly do
I expected the role that matches the most closely the argument to have its method called 10:22
sortiz So, when the multi in B matches both cases.
_nadim but apart from that expectation, I have another example, larger unfortunately, where the error message is not displayed 10:23
and where method that matches is the one that is the furthest from the type, it just happens to be te one in the last "done" role.
this also means that multis can not be refined via roles and in that case I wonder what would be used (short of implementing it "manually") 10:29
psch _nadim: a golf of the case where it seems to do the wrong thing would be interesting
_nadim: the paste behaves exactly as i'd expect
...i think 10:30
i'll grab another cup of coffee and get back to you... :)
_nadim psch: As I wrote above, my expectations are open for discussions ;) And Yes it does what it should if you are not expecting the new role to refine existing multis. So it works in the pasted example. 10:33
two problems remain. #1 refining a multi can not be done by a new role, that sucks a bit. Now if there is another way to add a multi to an existing object, I am alll ears. 10:34
#2 the example I have where I believe that it doesn't show the error it should ( according to how you think it should work (and does)), that is difficult to golf but I'll push a branch somewhere with the example in a little moment. 10:35
sortiz _nadim, As you see, the new B role refine the existing List multi, but add an ambiguity regards the Array multi. And that is the problem, thought. 10:36
10:38 buharin left
psch m: class A { multi method m (List $) { "list" } }; A.^add_multi_method("m", my multi method m (Array $) { "array" }); say A.m((1,2)); say A.m([1,2]) 10:38
camelia rakudo-moar b3b24b: OUTPUT«list␤list␤»
timotimo are yo usure you don't have to .^compose or something after adding a multi method like that? 10:39
psch m: class A { multi method m (List $) { "list" } }; A.^add_multi_method("m", my multi method m (Array $) { "array" }); A.^compose; say A.m((1,2)); say A.m([1,2])
camelia rakudo-moar b3b24b: OUTPUT«list␤Ambiguous call to 'm'; these signatures all match:␤:(A $: List $, *%_)␤:(Mu $: Array $, *%_)␤ in block <unit> at /tmp/9hEa0qKRNm line 1␤␤»
psch timotimo++
probably r-j making me used to method cache being borky :) 10:40
timotimo m: class A { multi method m (List $) { "list" } }; A.^add_multi_method("m", my multi method m (Int $a) { "int" }); say A.m(1, 2); say A.m(1);
camelia rakudo-moar b3b24b: OUTPUT«Cannot call m(A: Int, Int); none of these signatures match:␤ (A $: List, *%_)␤ in block <unit> at /tmp/oqKdMe7yx6 line 1␤␤»
timotimo m: class A { multi method m (List $) { "list" } }; A.^add_multi_method("m", my multi method m (Int $a) { "int" }); say A.m((1, 2)); say A.m(1);
camelia rakudo-moar b3b24b: OUTPUT«list␤Cannot call m(A: Int); none of these signatures match:␤ (A $: List, *%_)␤ in block <unit> at /tmp/4D4GJ8wD8k line 1␤␤»
Xliff How would I limit parameter argument to a Str array?
psch Xliff: depends on how much you want your users to suffer
choices are "not at all" and "a little maybe" 10:41
Xliff psch: It's gotta link to a NativeCall.
I think I will have to check manually, then. Thanks.
10:41 labster left
timotimo in that case it'll have to be a CArray anyway 10:41
Xliff Yeah.
psch Xliff: if it's for NativeCall bindings i'd probably expose a wrapper instead of the actual is-native traited sub
timotimo the thing is, if you want to expose a regular perl6 API, you'll have to go through the whole list anyway to push things into a CArray 10:42
Xliff But I don't want the P6 consumer to have to worry about that. They pass a perl array and the nativecall wrapper will create the CArray
timotimo so you can actually do proper checking there
10:42 buharin joined
Xliff Yeah. 10:42
Figured.
It's what I had started doing, then thought "Hey... maybe a better way exists?"
psch m: class A { multi method m (List $) { "list" }; multi method m (Array $) { "array" } }; say A.m((1,2)); say A.m([1,2]) 10:43
camelia rakudo-moar b3b24b: OUTPUT«list␤array␤»
Xliff This is what happens when you stop coding. Take a break playing a frustrating game. Then come back to your even more frustrating code.
psch okay, i think something is weird there
timotimo hah
psch .^add_multi + .^compose don't dispatch the same way as directly declaring both multis
timotimo yeah, you'll end up having composed twice 10:44
psch timotimo: right, but why does adding the multi make it ambiguous?
timotimo maybe there's some caches or something that keeps data around
it could be adding a multi method is about adding a proto rather than just a candidate? not sure.
calling .^compose twice may just be a contract validation 10:45
Xliff m: my $a = [1, 2, 3]; for ($a) { .print } 10:46
camelia rakudo-moar b3b24b: OUTPUT«1 2 3»
Xliff m: my $v = "This"; say $v ~~ Str; 10:48
camelia rakudo-moar b3b24b: OUTPUT«True␤»
dalek ar: 2f64d94 | (Steve Mynott)++ | README.star:
no longer for early adopters
10:56
10:56 rindolf joined
Xliff m: say 2^16 - 1 10:58
camelia rakudo-moar b3b24b: OUTPUT«one(2, 15)␤»
Xliff m: say 2 ** 16 - 1 10:59
camelia rakudo-moar b3b24b: OUTPUT«65535␤»
Xliff *sob*
psch m: say 2¹⁶ - 1 11:00
camelia rakudo-moar b3b24b: OUTPUT«65535␤»
Xliff \o/ 11:01
How did you get superscript!?!??
lizmat .u superscript
yoleaux U+00B2 SUPERSCRIPT TWO [No] (²)
U+00B3 SUPERSCRIPT THREE [No] (³)
U+00B9 SUPERSCRIPT ONE [No] (¹)
Xliff o
2⁴ 11:02
^_^
wincompose++
moritz welcome to the wonderful world of Unicode :-)
_nadim Xliff: if you want to superscribe longer strings, there's a Superscribe role in the Data::Dump::Tree module 11:05
Xliff moritz: Been visiting for a couple of weeks now. Thinking of moving here. :p 11:08
_nadim, I will have to look into that at some point. Thanks! 11:09
m: Say 3.1415962.WHAT
camelia rakudo-moar b3b24b: OUTPUT«5===SORRY!5=== Error while compiling /tmp/h9iJxqUrvj␤Undeclared name:␤ Say used at line 1␤␤»
Xliff m: Say (3.1415962).WHAT
camelia rakudo-moar b3b24b: OUTPUT«5===SORRY!5=== Error while compiling /tmp/P57AOZr4QM␤Undeclared name:␤ Say used at line 1␤␤»
Xliff m: say 3.1415962.WHAT
camelia rakudo-moar b3b24b: OUTPUT«(Rat)␤»
11:10 espadrine joined 11:12 nadim joined 11:15 _nadim left 11:18 cyberviking joined
Xliff m: say 3.14156 is Real 11:25
camelia rakudo-moar b3b24b: OUTPUT«5===SORRY!5=== Error while compiling /tmp/RyLAW3EtIp␤Two terms in a row␤at /tmp/RyLAW3EtIp:1␤------> 3say 3.141567⏏5 is Real␤ expecting any of:␤ infix␤ infix stopper␤ postfix␤ statement end␤ …»
Xliff Hrm.
11:26 pierrot left, pierrot joined
sortiz m: say 3.1415 ~~ Real; 11:27
camelia rakudo-moar b3b24b: OUTPUT«True␤»
psch m: use Test; 3.14156 [&isnt] Real
camelia rakudo-moar b3b24b: OUTPUT«ok 1 - ␤»
psch ... :S
Xliff m: say 3.14156 has Real 11:28
camelia rakudo-moar b3b24b: OUTPUT«5===SORRY!5=== Error while compiling /tmp/5swhiucPk9␤Two terms in a row␤at /tmp/5swhiucPk9:1␤------> 3say 3.141567⏏5 has Real␤ expecting any of:␤ infix␤ infix stopper␤ postfix␤ statement end␤ …»
Xliff m: say 3.14156 ~~ Real 11:29
camelia rakudo-moar b3b24b: OUTPUT«True␤»
Xliff Oh good.
psch m: say 3.14156.does(Real)
camelia rakudo-moar b3b24b: OUTPUT«True␤»
sortiz m: say 3.1415 ~~ Num; # Num is float 11:30
camelia rakudo-moar b3b24b: OUTPUT«False␤»
Xliff So is .does() preferred over ~~? 11:33
nadim sortiz: yes it's a bit funny that the method in the second role clashes with a multi of another type in the first role but displays no error message when it redefined a method of the same signature. I'll live with it but I thin it is a surprising behavior, It' would have predered it to be an error in both cases, at least that is consequent. 11:34
Xliff OK. That's one "class" implemented via NativeCall. I have to do one more before I can start any reasonable test cases.