»ö« Welcome to Perl 6! | perl6.org/ | evalbot usage: 'p6: say 3;' or rakudo:, std:, or /msg camelia p6: ... | irclog: irc.perl6.org | UTF-8 is our friend!
Set by moritz on 25 December 2014.
00:11 Ven joined 00:22 Ven left 00:24 spider-mario left 00:28 kjs_ left
raydiak back 00:44
00:44 Ven joined 00:48 davido_ left 00:49 davido_ joined 00:53 telex left 00:54 telex joined 01:04 PZt joined 01:05 dayangkun joined 01:08 yeahnoob joined
tadzik not sure how complicated would that be 01:16
01:25 dayangkun left
raydiak still investigating, looking at p5's git::pureperl (which is only 1600 lines of p5 for a complete implementation, less 1 dependency I'm not sure about) 01:35
but gotta run again...busy day, I guess
adu tadzik: I wonder how much better everyone's life would be if the zip part of tarball was a Content-Encoding header so that the file you downloaded was technically a .tar 01:38
tadzik adu: harder for our Perl 6 HTTP client :) 01:39
01:39 yeahnoob left
japhb So this afternoon I hit for about the sixth time the type discontinuity between < foo bar > and < foo >, which comes up often when I am inspecting or iterating over some configuration and finding that suddenly it no longer binds to Positional. 01:44
Is this something that will be addressed in the GLR, or is there an idiom I can use to ensure that the list always stays a list, even as elements are added and removed? 01:45
(I use 'list' in lowercase to mean any list-like thing, not necessarily a List or Array or whatever.)
For now, I'm using [< foo >], but that's kinda ugly and feels redundant. 01:46
TimToady, pmichaud: ^^
TimToady I doubt that's gonna change, since we specifically call out <1/2> as a Rat literal, for instance 01:47
and (1) is not a list either 01:48
and @foo<bar> is not a slice
er, %foo
in general we make up for it by treating Any as a list of 1 element 01:49
so I think you're stuck with [< >] for composition
if you want it mutable 01:50
it's not like <foo bar> should really be considered mutable either... 01:51
m: my @a := <foo bar>; push @a, 'baz'; say @a
+camelia rakudo-moar 80b912: OUTPUT«Cannot call 'push'; none of these signatures match:␤:(Any:U \SELF: *@values, *%_)␤ in sub push at src/gen/m-CORE.setting:9364␤ in block <unit> at /tmp/gU7YwumWPG:1␤␤»
Ven I agree I always get surprised when <foo> doesn't return a list 02:05
japhb: you can <foo>.flat, though 02:06
japhb TimToady: I wasn't really looking for mutability, just for things like: my %config := { monster_filter => < large green > }; my @filter_keys := %config<monster_filter>; # works, but remove 'green' and it doesn't. 02:07
02:07 grondilu_ left 02:18 mickcy_ca joined 02:20 rmgk_ joined, rmgk left, rmgk_ is now known as rmgk
TimToady japhb: otoh it'd work if you used = instead of := 02:36
people who use := are expected to think harder :)
(2nd := I mean) 02:37
and anyway, you probably want monster_filter => < large green >.any 02:39
and that would work too
or .all
anyway, you don't have to work very hard to make an item behave as a list 02:41
02:41 yeahnoob joined
TimToady and I suspect the opposite behavior would produce even more WATs 02:42
02:50 tinyblak_ left
ugexe raydiak: there will be soon 02:50
02:50 tinyblak joined
ugexe we are addressing all of those problems 02:53
mickcy_ca Hello Perl6 02:54
raydiak ugexe: nice, good to know 02:59
hi mickcy_ca
mickcy_ca Alas ... I am getting frustrated with this grammar I have been hacking at for the last couple of days. 03:03
I keeps hanging when I attempt to add + to a term ... even though it matches when I duplicate the line manually. Very frustrating. 03:04
03:04 dayangkun joined
mickcy_ca Will post a gist if anyone wants to look at it. 03:05
Ven mickcy_ca: have you tried running the debugger? 03:07
mickcy_ca Noob here ... there is a debugger? 03:08
03:09 Mso150 joined
raydiak Grammar::Debugger 03:10
mickcy_ca Thanks ... just picked it up through panda. 03:11
OK, looking at the debugger and I am wondering why any line that starts line #include ends up on two lines, first one '#' and the second one 'include' 03:15
<err> ... starts like $include ...
Not a big deal for me, even though I would like to be able to find #include directly. 03:16
Actulally, '/' and '*' also do the same thing. 03:17
03:20 sirdancealot left 03:21 yeahnoob left 03:35 hagirikan joined 03:36 hagirikan is now known as hagiri
raydiak might have more luck by just pasting a (short) gist than waiting for someone to ask for it :) 03:36
mickcy_ca Found part of my problem ... working through it now. 03:38
03:38 xinming_ joined
raydiak nice...debugger helps 03:39
03:41 xinming left 03:45 tinyblak_ joined, noganex joined 03:48 tinyblak left, noganex_ left
mickcy_ca It does ... very much so. 03:52
03:52 Mso150 left 03:56 tinyblak_ left 04:04 raiph joined 04:07 kaare_ joined
mickcy_ca OK ... it turns out I don't know how to figure this issue out ... see pastebin.com/JqepMjQ9 and check out the offender at line 11 ... do [<sp><enumerated>]+.*? and the whole thing fails. Help would be appreciated. 04:12
aargh ... shortened to the actual routines that I am testing and it is blowing up on me. 04:18
raydiak try changing .*? on that line to <-[}]>* 04:21
afk
04:30 dayangkun left 04:35 Ven left
raydiak back...and no that's not what you're trying to do I see now 04:35
mickcy_ca YAY ... got it to work! 04:36
It was my definition of <define> that mucked me up for the evening. 04:37
raydiak congrats 04:39
mickcy_ca Now, would someone be able to elucidate me on why the apparently grammar chops non word characters off the beginning of a line. See pastebin.com/JE2SNfZy for an example ... this one does match what I want, but still strips the leading '#' off of all lines. 04:41
04:48 adu left 04:50 Rounin left
TimToady mickcy_ca: what are you expecting <-[\n\s]> to do? It seems wrong to me several ways 04:57
in the first place, \n is a subset of \s, so is meaningless 04:58
secondly, you're always matching it first, so it's always going to match unless there's whitespace 04:59
and it will eat that first character
and exclude all the other possibilities because of the ||, even if they were a longer token match
generally you should let your rules soak up whitespace, and otherwise not be trying to match it negatively 05:01
otoh, if you're doing line-oriented parsing, it's usually a mistake to use rules at all 05:02
unless you redefine ws to just mean \h* 05:03
because any implicit call to <.ws> is going to chew through your line delimiter
and any leading whitespace on the next line 05:04
05:04 hagiri left
TimToady I can see why you're trying to mix them, though, since C preprocessor is line-oriented and C isn't 05:05
if you're going to try to do this, you have to be very picky about what can or cannot match newline though 05:06
TimToady would probably try to handle all line-oriented stuff inside a custom ws rule, whenever it sees a \n 05:07
then again, if I were doing this, I'd write a full parser, and not try to second-guess the formatting conventions, because there are always violations of conventions 05:09
05:09 kaare_ left
TimToady (you can really only get away with the convention approach if you define the conventions in advance, as we did with the test fudger) 05:10
mickcy_ca TimToady: I do not know the difference between the convention approach and what a full parser would be. 05:14
05:14 yeahnoob joined
mickcy_ca Basically, I thought that I was writing a parser ... :-/ 05:17
05:22 raiph left
mickcy_ca The <-[\n\s]> to shortcut out blank lines ... if it eats char 1 ... then out it goes. 05:24
05:24 BenGoldberg left
mickcy_ca As far as the || goes ... I am not looking for the "longest" match, but the best match. That said, if you look closely, in rule lines, I am looking for <definition> and in rule enumerated I am also looking for <definition>. If I didn't use the exclusive or it would always match the longest ... not what I intended. 05:26
05:36 kaare_ joined
TimToady if you want to shortcut a blank line, that's just $$, or maybe \h*$$ 05:39
mickcy_ca That does the trick! 05:40
TimToady: So, if I were to give up on this approach, and go ahead to just write a parser for C-header files ... I can see some other ways of going about it ... but I can only see grammars as the most efficient way. I there an alternative to this that you could point me towards? 05:46
TimToady grammars is also how you write a full parser, so just keep developing this, and eventually you'll get one :) 05:50
mickcy_ca I have found that the beauty of the line by line approach in this case, is that each rule / token / regex can automagially eat up subsequent lines if needed. 05:53
raydiak pretty sure more than one c grammar has been toyed with, you might find a link to a gist or something in the irclog with some searching, if you wanted to build on existing work or use ideas from it 05:57
mickcy_ca Why didn't I think of that ... P5 solution ... Parse-RecDescent-1.967_010 on C-Pan. 05:58
06:04 adu joined
mickcy_ca GCC socket.h -fdump-translation-unit will produce a socket.h.pth file ... Does anybody know what that is? Perhaps and how to peruse it in P6? 06:04
raydiak should I be using EXPR and/or other stuff from the P6 grammar in my own expression grammars? if so, is there anything helpful/related to read about how to go about that? 06:05
I'm sure Math::Symbolic contains a very suboptimal reimplementation of these things :) 06:06
06:07 raiph joined
mickcy_ca OK ... giving up on c header parsing ... close to 800 lines of parser at gist.github.com/andydude/5268163 06:09
06:12 sunnavy left
raydiak nice, maybe that one will suit your purposes? 06:13
mickcy_ca Looking at it ...
It is much more than I need ... but if I am correct, everything that is in a header file is valid in a C program, is it not? 06:14
06:14 sunnavy joined, raiph left
mickcy_ca If I use that code ... "all" I have to do is write the action class to pull out the matches. 06:15
+dalek ast: 64c0122 | TimToady++ | / (3 files):
remove inadvertent shape declarations from tests

Postcircumfixes on parameter variables are reserved for shape declarations. Generally whitespace or a colon is needed to disambiguate.
06:23
raydiak what is the problem you're trying to solve? are you trying to parse one specific file, or any c header? 06:24
b/c if you're trying to solve the general case, then yeah it's a fairly extensive undertaking, though I certainly don't mean to dissuade you 06:25
+dalek kudo/nom: dd5687c | TimToady++ | src/Perl6/Grammar.nqp:
Give meaningful redirects on NYI shape declartions

Sloppy subsigs or functions with sigs are no longer allowed, since declaring a variable with an immediately following postcircumfix is construed as a shape.
06:26
raydiak if you're just trying to one-off something, then it's not unreasonable to expect to be able to hack something together that could accomplish the specific task at hand, as long as your input is fairly clean
mickcy_ca The end result I am going for is the general case ... although I can see that my original tact would have been very insufficient to the task. 06:28
And re-inventing the wheel is not my idea of fun. 06:29
Does anyone know how to get that those files included in my project? 06:30
raydiak ah...if you're not wanting to write a c parser from scratch, then I'd just use what you found, personally...don't know that the action class would be all that bad to write, for the subset you need 06:31
mickcy_ca That was my thought indeed.
raydiak maybe send him a message on github or something? 06:32
don't know who that is, myself
mickcy_ca Planning to do that.
TimToady or get someone to translate it to P6 for you :) 06:33
mickcy_ca ??
raydiak it is p6
TimToady oh, that is a P6 parser already 06:34
mickcy_ca Exactly ... now back to getting that into my project without adding all those lines to my part of the project. 06:35
TimToady yeah, we should get that into the ecosystem somehow
mickcy_ca Without a github sign in ... is there a way to send anyone a message on github? 06:37
xiaomiao mickcy_ca: unlikely 06:38
mickcy_ca That is what I thought ...
06:38 skids left
mickcy_ca With a github account ... how to send message to a specific user? 06:42
06:42 skids joined
raydiak dug up an e-mail: andjrob [at] gmail.com 06:42
mickcy_ca Thanks. 06:43
raydiak you're welcome 06:44
adu what
that's me
raydiak oh we love your C parser and want it in the ecosystem :)
adu raydiak: sweet
can I help? 06:45
raydiak adu: interested in maintaining it as a module?
adu I just wish it was better/faster/stronger
06:45 dayangkun joined
adu raydiak: yes, what do I do? 06:45
raydiak I think doc.perl6.org/language/modules is most of what you need to know 06:46
adu I haven't spent much time on it lately, but I would imagine to make it a module I would have to separate out the parser from the DROXActions 06:47
raydiak: just to be sure, are you talking about github.com/andydude/droxtools/tree...erl6/lib/C 06:48
raydiak we were looking at gist.github.com/andydude/5268163 that we dug up from the irclogs somewhere :) 06:49
adu oh
that's super old
raydiak well, we don't have a C parser in the ecosystem, so in whatever form, if you'd like to package your work up into a module, it'd be cool to have 06:51
adu raydiak: yeah, I can separate it out from the drox stuff, what should it be called?
raydiak hmmm 06:52
most of the ones I see are Something::Parse/Parser/Parsing 06:53
adu Language::C::Parser?
raydiak is not really all that familiar with the conventions tbh 06:54
not sure if we have any really settled yet anyway, so sure why not? 06:55
06:56 dayangkun left
adu nah, C::Parser is good 06:57
pmichaud m: $_ = 'xyz'; say 'abc' ~~ m/.../; 07:08
+camelia rakudo-moar 80b912: OUTPUT«「abc」␤␤»
07:08 yeahnoob left
pmichaud m: $_ = 'xyz'; say m/.../; 07:08
+camelia rakudo-moar 80b912: OUTPUT«「xyz」␤␤»
adu raydiak: like this? github.com/andydude/p6-c-parser
07:08 skids left
pmichaud m: $_ = 'xyz'; say 'abc' !~~ m/.../; 07:09
+camelia rakudo-moar 80b912: OUTPUT«False␤»
raydiak adu: looks good, lemme try it out
adu raydiak: it's slow and incomplete, just a warning 07:10
pmichaud m: $_ = 'wxyz'; say 'abc' !~~ m/..../; 07:12
+camelia rakudo-moar 80b912: OUTPUT«True␤»
raydiak adu: nice, builds and installs fine here
mickcy_ca raydiak: how do you do that? 07:14
Got the source package, how do I compile and install? 07:15
raydiak mickcy_ca: 'panda install .' iirc
mickcy_ca OK.
07:16 sven_123 left
mickcy_ca Worked here to. 07:17
adu raydiak: best not to throw the linux kernel at it, it's still having trouble with "int main() { return 0; }"
raydiak adu: yeah I don't have a specific use for it atm, was originally just answering questions :) though I did earlier this year want to use p6 to autogen ffi bindings for luajit 07:18
adu that sounds fun
07:19 jluis joined
mickcy_ca adu: Was looking at implement a parser for header files ... turns out I was re-inventing the wheel. 07:19
I get "undeclared routine" when I do use "C::Parser" 07:20
raydiak yeah I had one problem or another with every binding I tried...think it was for 0mq, ended up one-offing a script w/a bunch of regex to do it iirc, but would much rather have a reuasable solution obviously 07:21
pmichaud m: $_ = 'wxyz'; say abc !~~ m/{ .say } ./
+camelia rakudo-moar 80b912: OUTPUT«===SORRY!=== Error while compiling /tmp/Dxp9Qf0EW1␤Undeclared routine:␤ abc used at line 1. Did you mean 'abs'?␤␤»
07:21 yeahnoob joined
pmichaud m: $_ = 'wxyz'; say 'abc' !~~ m/{ .say } ./ 07:21
+camelia rakudo-moar 80b912: OUTPUT«abc␤False␤»
mickcy_ca Ah.
Anyway, it has been a hoot. Good Night Perl 6 07:22
07:22 mickcy_ca left 07:25 darutoko joined
adu github.com/andydude/p6-c-parser/bl.../cdump.pl6 07:25
that's the tool I usually test with
raydiak ah nice 07:26
be aware that things in bin get installed by panda, theoretically into the user's $PATH 07:27
adu is cdump a common name? 07:28
raydiak *shrug*
adu or are you saying that it shouldn't have an extension? 07:30
raydiak not really saying anything specific, just letting you know...I'm not completely sure the place they all get installed to is automatically added to the PATH yet anyway 07:31
I am not an expert, if this wasn't already apparent :) 07:32
adu raydiak: well, that's for the nudge :)
s/that's/thanks/
raydiak you're welcome, thanks for the awesome work, it's kinda intimidating-looking when I came across it 07:33
adu I hope to make it less intimidating with ASTs and PODs, assuming I learn how they work
raydiak adu: a little bit in the README goes a long way too 07:34
adu I should put an experimental warning
raydiak oh and when you have time, a basic front end in C/Parser.pm6, even if it's just a passthrough to .parse like you have in that script, would be cool so people can just "use C::Parser;" 07:35
adu raydiak: I'm not sure I understand 07:36
07:37 sven_123 joined
adu oh, so you can call C::Parse(...) instead of that long thing? 07:37
raydiak much of the time people will expect to be able to load your module simply by passing the namde of your module to 'use'...so making "use C::Parser" do something useful w/out the additional ::StdWhatever part might be worthwhile 07:38
adu oh 07:39
raydiak just prettyness of the API for your users, basically...potentially less to have to remember to type or look up
07:41 bjz joined
raydiak adu: oh anyway, to make this actually part of the ecosystem, you can either ask around when more people are active (next few hours usually) to get added to the perl6 github org, then you'll be abel to commit to the ecosystem list 07:42
adu I'm actually already a member
raydiak oh nice
adu I just haven't done much 07:43
raydiak you can commit to the ecosystem list then
adu where is it?
raydiak github.com/perl6/ecosystem/blob/ma.../META.list
+dalek p: ccb0ef3 | TimToady++ | Configure.pl:
slightly saner default build order
07:44
kudo/nom: 66309df | TimToady++ | Configure.pl:
tweak default build order a bit

I got tired of building the jvm version by accident when I left out the m- bit. :) This way the fast one builds first, and then you can ^C if you don't want the slower platforms.
07:46 skids joined 07:47 sirdancealot joined
raydiak adu: once you've added your module to the ecosystem, in roughly the next hour or two it will appear in the list that panda uses at ecosystem-api.p6c.org/projects.json 07:47
then you can "panda update" followed by "panda install C::Parser", and the rest of us can too 07:48
pmichaud TimToady++ # another island of sanity 07:49
raydiak ( I'd suggest a test or two if you feel like it, too...even just one that 'use's your module and makes sure it loads successfully ) 07:50
07:50 kaleem joined
adu raydiak: I'm on team nqp, I can't make changes to ecosystem 07:53
07:53 lsm-desktop left
raydiak someone get this man a commit bit! (andydude on github) if nobody does by the time I'm back from afk in a few minutes I can add it for you if you like 07:56
moritz commit bit for whom? 07:57
\o #perl6
adu moritz: I'm already a member of nqp, but I'm trying to add my project to the ecosystem
moritz adu: what's your github ID?
adu and apparently you need to be an owner for that
"andydude"
moritz adu: no, it's a separate team; invitation sent 07:58
or added; it seems invitations are only for first joining an organization 07:59
+dalek osystem: e5ea4e9 | (Andrew Robbins)++ | META.list:
Added p6-c-parser to META.list
08:00
adu :)
moritz: thanks 08:01
08:01 skids left
adu I guess I have to write some tests now 08:01
08:03 lsm-desktop joined
TimToady adu++ 08:03
08:03 skids joined
raydiak \o/ adu++ 08:04
adu :) 08:05
raydiak adu: you might want a .gitignore for those .DS_Store files among other things 08:06
adu raydiak: already done
raydiak nice
08:13 mephinet left
raydiak alright past my bedtime...g'night #perl6 08:15
TimToady o/
08:30 virtualsue joined
adu I just updated it 08:30
08:31 Psyche^ joined, mephinet joined, Psyche^ is now known as Psyche 08:32 Psyche is now known as Patterner
+dalek c: b7c434d | moritz++ | lib/Language/regexes.pod:
Be consistent in use of <.ws> (not <ws>)
08:34
08:38 kjs_ joined 08:39 kjs_ left 08:48 avalenn joined 08:49 adu left 08:50 kjs_ joined 08:54 kjs_ left 09:04 Sir_Ragnarok joined
+dalek c: 5607c3d | moritz++ | lib/Language/regexes.pod:
Examples for overriding ws
09:05
09:10 Mso150 joined 09:24 bjz_ joined 09:26 xfix joined, rindolf joined, clkao left 09:27 clkao joined, bjz left
Woodi hallo today :) 09:32
just found: Wolfram Language (ex Mathematica ?) www.youtube.com/watch?v=_P9HqHVPeik 09:33
why that damn thing is not open source ? or at list it's database... :) 09:34
we should do some perl6 interpreter embaded in SDL "display" window...
09:35 mickcy_ca joined
mickcy_ca Has there been any progress on memoization of user subs? 09:35
Woodi also: I think that when someone works with datas separated by \n then using .lines should be first try. not grammar... 09:36
09:48 rurban joined, Guest46108 joined 09:49 Guest46108 is now known as CurtisOvidPoe
CurtisOvidPoe Trying to figure out parsing command line args: gist.github.com/Ovid/8dda7820aca6aec60124 09:49
09:56 yeahnoob left 09:58 mickcy_ca left 10:01 denis_boyun joined 10:03 skids left
FROGGS_ CurtisOvidPoe: we have the same issue when you put Str in the MAIN's signature, and you pass something that looks like an Int but can happily be a Str (because everything you pass could be) 10:07
CurtisOvidPoe So signature handling isn’t very robust yet? 10:08
FROGGS_ RT #119001
synopsebot Link: rt.perl.org/rt3//Public/Bug/Displa...?id=119001
10:10 rurban1 joined
FROGGS_ I think the problem is that when you call a multi sub from P6, the type of the args are pretty clear, and args from your shell get qualified later, and perhaps wrongish 10:10
and we cannot say that an arg is a Str|Int|Num at the same time
so, it is robust but it does not do what you mean 10:11
CurtisOvidPoe FROGGS_: thank you. Working on a P6 talk and I think I might leave the argument handling out then (not sure).
lue FROGGS_: we could if things like IntStr were implemented :) .
10:12 kjs_ joined 10:13 camelia left, nine left
FROGGS_ CurtisOvidPoe: that kinda works: 10:14
-sub MAIN(Real $num where { 0 <= $_ < 1 }, Int :$bits = 32) {
+sub MAIN($num as Num where { 0 <= $_ < 1 }, :$bits = 32) {
though if you pass something that cannot be turned into a Num: 10:15
$ perl6-m gistfile1.pl a
Cannot convert string to number: base-10 number must begin with valid digits or '.' in '⏏a' (indicated by ⏏)
CurtisOvidPoe That at least makes sense :)
So, how would I add a “> 0” constraint to $bits and still have a default? Is that possible? 10:16
moritz m: subset Positive of Cool where * > 0; sub with-default(Positive :$bits = 32) { say $bits }; with-defaults; with-defaults bits => '64'; 10:19
huh, where's camelia?
10:19 camelia joined 10:20 virtualsue left
moritz m: subset Positive of Cool where * > 0; sub with-default(Positive :$bits = 32) { say $bits }; with-defaults; with-defaults bits => '64'; 10:20
$ perl6-m -e 'subset Positive of Cool where * > 0; sub MAIN(Positive :$bits = 32) { say $bits }' 10:21
32
10:22 ChanServ sets mode: +v camelia
+camelia rakudo-moar 80b912: OUTPUT«(timeout)» 10:22
moritz m: say 42
+camelia rakudo-moar 80b912: OUTPUT«42␤»
moritz hthe server has a load of 17
*the 10:23
FROGGS_ std: sub MAIN($num as Num where { 0 <= $_ < 1 }, Int :$bits is rw where ( $bits ||= 32 > 0 )) { } # does not work in rakudo 10:24
+camelia std f9b7f55: OUTPUT«===SORRY!===␤Unable to parse signature at /tmp/Oq63vY_n20 line 1:␤------> sub MAIN⏏($num as Num where { 0 <= $_ < 1 }, Int ␤Couldn't find final ')'; gave up at /tmp/Oq63vY_n20 line 1:␤------> sub MAIN($num …»
CurtisOvidPoe Why would I use Cool instead of Int? 10:25
Oh, I guess that was just an example.
moritz CurtisOvidPoe: I was unsure how well MAIN coerces types automatically
CurtisOvidPoe: but it seems Int also works here
10:28 mvuets joined
FROGGS_ std: sub MAIN ($num as Num) { } # is std broken? 10:28
+camelia std f9b7f55: OUTPUT«===SORRY!===␤Unable to parse signature at /tmp/dRrjFPStyS line 1:␤------> sub MAIN ⏏($num as Num) { } # is std broken?␤Couldn't find final ')'; gave up at /tmp/dRrjFPStyS line 1:␤------> sub MAIN ($num ⏏…»
CurtisOvidPoe Thanks! That works great. Also, what’s the difference between using * and $_ in a subtype?
FROGGS_ $_ can be used in a block as a closure, and * in a ( ) makes a closure for you 10:29
m: say <a b c>.grep(* eq 'b')
+camelia rakudo-moar 80b912: OUTPUT«b␤»
FROGGS_ m: say <a b c>.grep({$_ eq 'b'}) # it turns into that
+camelia rakudo-moar 80b912: OUTPUT«b␤»
CurtisOvidPoe So in the subset moritz wrote, the () was implicit? 10:31
FROGGS_ I think so 10:32
well, the ( ) is needed for invoking the grep... it is not needed per se
m: say * * 42 10:33
+camelia rakudo-moar 80b912: OUTPUT«WhateverCode.new()␤»
FROGGS_ m: my &foo = * * 42; say foo 11 10:34
+camelia rakudo-moar 80b912: OUTPUT«462␤»
mvuets m: say (* * *)(2, 3)
+camelia rakudo-moar 80b912: OUTPUT«6␤»
FROGGS_ aye, there you need the parens for parsing * * * as a statement of its own 10:35
moritz CurtisOvidPoe: the * is just a short way to write a closure, where the * stands for a parameter
CurtisOvidPoe: so * > 0 is basically the same as { $_ > 0 } or -> $x { $x > 0 }
FROGGS_ or { $^a > 0 } 10:36
CurtisOvidPoe Thanks all :)
FROGGS_ pleasure :o)
CurtisOvidPoe Trying to write a Perl 6 talk for FOSDEM showing that Perl 6 is easy to use and safer than most dynamic languages. Mostly this seems true, but some implementation gotchas are tripping me up. 10:38
moritz CurtisOvidPoe: please report them (rakudobug@perl.org) so that we have a chance to fix them 10:39
:q
hugme hugs moritz, good vi(m) user!
moritz EWRONGWINDOW 10:40
CurtisOvidPoe Just want to touch base here, first, to make sure I’m not being an idiot :)
And it looks like the command line issue is already known.
moritz that's fine too
FROGGS_ to be fair, the 'as Type' trait seems a pretty sane way to do it 10:41
CurtisOvidPoe Is there a difference between “Num $foo” and “$foo as Num”?
FROGGS_ m: sub foo($a as Num) { }; sub foo(Str $s) { }; say foo("bar") 10:42
+camelia rakudo-moar 80b912: OUTPUT«===SORRY!=== Error while compiling /tmp/ZuvzzEOrq5␤Redeclaration of routine foo␤at /tmp/ZuvzzEOrq5:1␤------> foo($a as Num) { }; sub foo(Str $s) { }⏏; say foo("bar")␤ expecting any of:␤ horizontal…»
FROGGS_ m: multi foo($a as Num) { }; multi foo(Str $s) { }; say foo("bar")
+camelia rakudo-moar 80b912: OUTPUT«Nil␤»
FROGGS_ hmmm
ahh, it is fine in this case because the second foo is preferred over the first with the implicit Any 10:43
Num $foo will really only be considered if you pass something that is Num (or something that has Num as a parent)... 10:44
$foo as Num really is 'Any $foo as Num', so depending on your other multi candidates the 'Any' will matter 10:45
I'm not sure I can come up with a good example though 10:46
moritz CurtisOvidPoe: 'as Num' is a coercion (and deprecated in favor for a syntax not yet impelemented), 'Num $x' is a type constraint
CurtisOvidPoe Thank you. 10:47
pnu NativeCall test is failing [ testers.perl6.org/report/recent/5100 ] So... just adding a whitespace is the correct fix? github.com/pnu/zavolaj/commit/f8f4...e32dda2738 .. broken since a recent change in Grammar. Sorry, I'm just guessing the syntax to get my tests run ok. ;-)
moritz the new thing is sub foo(Any(Num) $x) { } where Any is the type that is accpeted, and Num the type being coerced to
CurtisOvidPoe Why is “as Num” being deprecated. I thought that syntax was there for a long time. The Any(Num) $x seems strange 10:49
(At least to me)
moritz CurtisOvidPoe: the Any(Num) exposes coercions as first-class objects (at least that's the reason I can remember) 10:50
10:53 Mso150 left 10:55 Alula left, Alula joined, camelia left 10:56 camelia joined 10:57 ChanServ sets mode: +v camelia 11:01 dakkar joined 11:02 psch joined
psch hi #perl6 \o 11:02
moritz \p psch 11:04
pnu: yes, I think that fix is correct 11:05
.tell nine I've moved the camelia.service to camelia@.service (template) and have started two instances, one for freenode, one for magnet 11:06
+yoleaux moritz: I'll pass your message to nine.
dakkar what's the idiomatic way to import a sub across packages? package One { our sub foo {...} }; package Two { our sub foo(|x) { One::foo(|x) } } ? 11:07
11:07 spider-mario joined
dakkar or something with binding? 11:07
moritz m: package One { sub foo is export { } }; import One; foo() 11:08
+camelia ( no output )
dakkar yes
I may have written my question badly
moritz m: module A { our sub b { say 42 } }; constant &alias = &A::b; alias()
+camelia rakudo-moar 80b912: OUTPUT«42␤»
dakkar aha! yes, that's the answer I was looking for 11:09
moritz dakkar: 'our' subs are nearly always unidiomatic in Perl 6
dakkar hm
moritz exporting/importing exists, and is lexical, and much sane
*saner
and analyzable at compile time
and more understanble wrt shadowing
and so on
dakkar I'm porting a js library, I'd like to keep the function names, and many of them are very short ("header","authorize") 11:10
they're functions, not methods, there's no state anywhere
so I thought of requiring them to be called with the full package name, to make the names non ambiguous 11:11
moritz does it make sense for them to be function in Perl 6 land? 11:13
dakkar what else could they be? class methods? methods on stateless singleton objects? 11:15
+dalek volaj: f8f4e1b | (Panu Ervamaa)++ | t/08-callbacks.t:
use whitespace to define subsignature for unpacking

see rakudo/rakudo@dd5687cc9fb96ce175799090675fcb6bdc3dd067
volaj: e102c8e | moritz++ | t/08-callbacks.t:
Merge pull request #54 from pnu/master

use whitespace to define subsignature for unpacking
moritz dakkar: class methods, or ordinary methods (if you change the interface a bit)
psch o/ moritz
moritz dakkar: though if functions make sense, then by all means, go for functions
dakkar I'm never sure what the conceptual difference is, between class methods, methods on singletons, and namespaced functions 11:16
they're all the same thing to me…
psch m: module Foo { module Bar is export { sub baz { } } }; use Foo; Bar::baz
+camelia rakudo-moar 80b912: OUTPUT«===SORRY!===␤Could not find Foo in any of: /home/camelia/rakudo-inst-1/languages/perl6/lib, /home/camelia/rakudo-inst-1/languages/perl6␤»
psch m: module Foo { module Bar is export { sub baz { } } }; import Foo; Bar::baz
+camelia rakudo-moar 80b912: OUTPUT«Could not find symbol '&baz'␤ in method <anon> at src/gen/m-CORE.setting:13871␤ in any find_method_fallback at src/gen/m-Metamodel.nqp:2737␤ in any find_method at src/gen/m-Metamodel.nqp:988␤ in block <unit> at /tmp/Ht4cVaH3vl:1␤␤» 11:17
psch oh our of course
m: module Foo { module Bar is export { our sub baz { } } }; import Foo; Bar::baz
+camelia ( no output )
moritz dakkar: the difference between subs and methods is that methods fall back to parent classes
m: class A { method x() { 42 }; class B is A { }; B.x
+camelia rakudo-moar 80b912: OUTPUT«===SORRY!=== Error while compiling /tmp/MSmOsJQcc3␤Unable to parse expression in block; couldn't find final '}' ␤at /tmp/MSmOsJQcc3:1␤------> method x() { 42 }; class B is A { }; B.x⏏<EOL>␤ expecting any of…»
dakkar yes, obvs 11:18
moritz m: class A { method x() { 42 }; class B is A { }; B.x()
+camelia rakudo-moar 80b912: OUTPUT«===SORRY!=== Error while compiling /tmp/TqwyD6fxsA␤Unable to parse expression in block; couldn't find final '}' ␤at /tmp/TqwyD6fxsA:1␤------> thod x() { 42 }; class B is A { }; B.x()⏏<EOL>␤ expecting any of…»
moritz too dumb
m: class A { method x() { 42 } ]; class B is A { }; B.x()
+camelia rakudo-moar 80b912: OUTPUT«===SORRY!=== Error while compiling /tmp/SlvJexee0u␤Unable to parse expression in block; couldn't find final '}' ␤at /tmp/SlvJexee0u:1␤------> class A { method x() { 42 } ⏏]; class B is A { }; B.x()␤ expecti…»
moritz m: class A { method x() { 42 } }; class B is A { }; B.x()