»ö« 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:01
Peter__R left
00:02
Peter_R joined
00:04
adu joined
|
|||
Adriaaan | Hmm k, thanks :D | 00:05 | |
raydiak_ | m: my $b = Buf.new; $b[$_] = (rand*256).Int for ^1e6; $b[10..20]; # if you want them all up-front, this is faster and lighter on memory, at least under moar, than reifying a 1M-elem lazy list | ||
camelia | ( no output ) | 00:06 | |
raydiak_ | m: my $b = Buf.new; $b[$_] = (rand*256).Int for ^1e6; say $b[10..20]; | ||
camelia | rakudo-moar 243c16: OUTPUT«123 40 187 193 207 221 119 32 58 245 82» | ||
raydiak_ | m: my $b = Buf.new; $b[$_] = (rand*256).Int for ^1e6; say $b[10..20]; say now - BEGIN now | 00:08 | |
camelia | rakudo-moar 243c16: OUTPUT«73 31 57 102 32 3 210 95 126 206 23710.3548619» | 00:09 | |
jercos | is there currently a way to work with arbitrary FDs in rakudo-moar? | ||
e.g., ./something.pl 3</tmp/foo, can I read from FD 3, and close it when I'm done? | 00:10 | ||
I mean, specific to Linux with a mounted /proc I know I can open /proc/PID/fd/3 and get a dup of it | 00:11 | ||
00:16
gfldex left
|
|||
masak | jercos: not to my knowledge. | 00:16 | |
raydiak_ | would nativecall to posix functions be more portable? | ||
jercos | Probably, at least within Unix-like platforms. | 00:17 | |
That would also allow for closing the FD, which to my knowledge can't be done with /proc | |||
raydiak_ | I think the notion of file descriptors like that pretty much rules out windows anyway, no? | ||
geekosaur | I don't think the point was /proc | 00:18 | |
Adriaaan | thanks raydiak_ | ||
geekosaur | perl5 can do open my $fh, '<&3' on both posix and windows | ||
raydiak_ | hm | ||
what does that do? | |||
yw Adriaaan :) | 00:19 | ||
jercos | If that dups (which it looks like it should), then it's still not useful for closing the original file descriptor | ||
which still leaves nativecall as the best option for that specific need | |||
I'll uh, give it a test :p | |||
geekosaur | that won't close the original, no | 00:20 | |
if you want sysopen, you're looking at nativecall. probably a wrapper that does the posix or windows versions as appropriate | 00:21 | ||
perl5 probably should have done that except that I don't think the machinery was in place for that kind of thing when sysopen and friends were added | 00:22 | ||
(which iirc was lateish in perl3) | |||
jercos | heh, well, `our sub sysclose(int32) returns int32 is native("libc.so.6") is symbol("close") { * }` works fine for the moment :) | 00:28 | |
00:37
fil_ joined
|
|||
masak | fil_! \o/ | 00:37 | |
fil_ | hey | 00:38 | |
question | |||
So I'm looking at github.com/supernovus/exemel/blob/...ib/XML.pm6 | |||
thinking about how to print out indented XML | |||
and I see that I really just want to shim a few lines of code into a couple of methods | |||
in that class | |||
masak | *nod* | ||
fil_ | is there some kind of aop I could use to do that? | ||
masak | I would just use multi subs. | 00:39 | |
why complicate life, eh? | |||
multis are awesome for this. | |||
AOP solves all your problems, but at the cost of someone or something's sanity. | 00:40 | ||
we like sanity | |||
(believe it or not) | |||
fil_ | so the method I want to modify is XML::Element::Str() | 00:41 | |
masak | oh, an existing method. | ||
I think my multi approach is still viable | 00:42 | ||
00:42
Mouq joined
|
|||
fil_ | this method calls itself recursively | 00:43 | |
so it's not clear to me how I would use multi to solve it... | |||
masak | dang :/ | ||
no | |||
Mouq | .wrap-ing? | 00:44 | |
fil_ | I thought I saw some AOP type stuff in the docs | ||
masak | it exists | ||
doesn't mean I endorse it | |||
fil_ | I think they're called Phasers | 00:45 | |
masak | augmenting stuff is anti-social | ||
Mouq | or doing an `augment` and then doing $indent ~ nextsame | ||
skids | No phasers are flow control. | ||
If you can get the rest of the classes to use a subclass of XML::Element, you could just subclass and supply your own .say. | |||
I mean .Str | 00:46 | ||
fil_ | It's a pretty big method | ||
And I only need to change a couple of lines | |||
hmmm | |||
maybe I need to take a different approach | |||
it just seems like a waste to not use the XML structure and recursive print already done... | |||
I guess I could just treat it as a string | 00:47 | ||
I was hoping there would be some way to intercept the call of XML::Element::Str() and then inject a few lines of code... | 00:48 | ||
masak doesn't consider most AOP to be good OOP | 00:50 | ||
fil_ | Well it's not that big a method. Only 30 lines. Can I overwrite it? | ||
masak | `augment class` | ||
fil_ | I agree AOP makes for horribly complicated code that's impossible to follow / debug. | ||
masak | it causes a power struggle between auths of classes | 00:53 | |
fil_ | Can I overwrite a method using augment, or do I need to use supercede? | ||
I mean supersede | |||
masak | supersede replaces the class entirely | 00:54 | |
fil_ | I just need to replace a method | ||
masak | yes | ||
I believe `augment` should work for your use case. | 00:58 | ||
last time I tried, it didn't (and jnthn claimed that was intended) | |||
even if it did work, I know of no good way to refer to the method being replaced from the replacing one | 00:59 | ||
no bad way either, for that matter | |||
fil_ | augment class XML::Element { multi Str() { | 01:00 | |
that takes | |||
but within the method I get the error: Variable $.name used where no 'self' is available | |||
interesting... | |||
masak | heh | ||
Mouq | multi makes a sub | ||
you want multi method | 01:01 | ||
masak | yes | ||
fil_ | I don't know of my multi would take precedence over the original sub, but it won't compile because it doesn't have a self... | 01:02 | |
masak | you don't want a sub at all | 01:03 | |
skids | ^^ What Mouq said | ||
masak | `self` is not available in a sub | ||
(or rather, outside of a method) | |||
fil_ | ===SORRY!=== Cannot have a multi candidate for 'Str' when an only method is also in the packa ge 'XML::Element' | 01:04 | |
01:04
atroxaper joined
|
|||
masak | that'd be the original method | 01:04 | |
fil_ | :-) | 01:05 | |
masak | it's `only`, meaning not `multi` | ||
fil_ | Well I guess that's a good thing that you can't override other classes methods... | ||
masak | meaning the original author did not intend for you to add a `multi` afterward | 01:06 | |
yes, but it kinda makes `augment` a lot less powerful | |||
fil_ | ok I guess it's plan B | ||
just forget the XML structure and treat it as a string match/replace problem | 01:07 | ||
masak | or just copy/modify the logic in your own routine | ||
01:08
atroxaper left
|
|||
fil_ | I'd need to do the whole class because of the recursion | 01:08 | |
I want to make something other ppl can use | 01:09 | ||
raiph | fil_: did you see irclog.perlgeek.de/perl6/2015-01-24#i_9997806? | 01:11 | |
yoleaux | 23 Jan 2015 12:53Z <psch> raiph: i apparently missed fixing marshalling of List-y types for non-overloaded methods. that's the error you're seeing with "method/update/([B)V" | ||
raiph | fil_: I think FROGGS was suggesting that A) you can use his new module and B) .gist is a better place for indenting logic than .Str | 01:13 | |
fil_ | looking at XML::LibXML now | 01:16 | |
FROGGS says "will soon be able to prettify XML" | |||
How soon is soon? | |||
what does "gist" mean? | 01:18 | ||
01:18
prevost left
|
|||
raiph | Returns a string representation of the invocant, optimized for fast recognition by humans. | 01:18 | |
japhb | So I'm thinking of pitching Perl 6 to people who are on the fence about it as an excellent language for prototyping, because of the multi-paradigm aspect that makes that statement true almost whatever the "final" language will be, combined with much more compact syntax than most other languages, with the follow-up that they may find the prototype is good enough to not need total replacement (at least in the post-6.0.0 era). Thoughts? | 01:19 | |
fil_ | I'd investigate how mature the bindings are to front-end and db frameworks | 01:21 | |
japhb | fil_: Meaning, without mature for those two things, it's not ready to pitch as a prototyping language? | 01:22 | |
fil_ | gist() has the same problem as Str() so I can't override it. I'm making good progress with the string approach. I won't bother sharing it as it sounds like a more permanent solution is coming. | ||
colomon | japhb: I’ve had some decent luck prototyping in p6. Though in the biggest case the project got canceled before I could start mangling it into C++... | 01:23 | |
fil_ | I'm new to perl6, so I'm not a good person to ask. But in my experience, prototyping needs speed, and speed needs no-brainer bindings to front-end and back-end. | ||
skids | Also now we have Inline::Perl5 to take the pressure off the ecosystem needs a bit. | ||
fil_ | node.js / angular is good for prototyping. | 01:24 | |
it has it all | |||
it could be that perl6 has it too | |||
perl6 is a dream language if you're doing parsing / integration type work | |||
01:25
fil_ left
|
|||
masak | yep. | 01:26 | |
'night, #perl6 | |||
colomon | o/ | ||
japhb | fil_: OK, good input, thank you. | 01:29 | |
skids: Decent point. Last I looked it could use a little more sugar to make it really smooth, but as a technology, very cool. | 01:30 | ||
01:33
agentzh left
|
|||
Peter_R | I often see a lot of cool features of p6 using very unreadable looking syntax though :s | 01:34 | |
I hope there is a longer hand, more self explanatory way to use those things | 01:35 | ||
01:38
yeahnoob joined
01:43
telex left
|
|||
skids | Peter_R: people like to show off, is all. | 01:44 | |
01:44
telex joined
|
|||
Peter_R | Ah, thank goodness | 01:45 | |
01:55
raiph left
|
|||
vendethiel | Peter_R: right. it's just a "I can do it that way, lol" like we were doing with indirectly named calls earlier | 02:00 | |
02:02
Peter_R left,
Peter_R joined
|
|||
japhb | Peter_R: Yeah, generally you have a pretty smooth knob for complexity per character of code in Perl 6. We who have been here a while tend to use shorthand, or even as mentioned above play around and show off. But you can definitely be more verbose and approachable to beginners, while *still* being more compact than many other languages. | 02:05 | |
02:06
Peter_R left,
Peter_R joined
02:09
Peter_R left
02:12
Peter_R joined
02:13
Sysaxed` left
|
|||
Mouq | moritz: So I'm going to manually index the various bits from regexes.pod via X<|> (+, *, <[ ]>, <-[ ]>, etc.)... my question is what category should these things be? "Regex Syntax"? "Regex Metacharacter"? My concern is that the category name(s) should be pithy so it actually fits in the search suggestion list | 02:17 | |
skids | I dunno "Rx Slang?" | 02:24 | |
Mouq | "℞ Metachar" seems a little far | 02:27 | |
02:35
lsm-desktop left
02:55
atroxaper joined
02:59
atroxaper left
03:00
vendethiel left
03:02
vendethiel joined
03:12
Ben_Goldberg joined
03:15
espadrine left
03:16
BenGoldberg left
03:18
Patterner joined
03:22
Psyche^ left
03:23
vendethiel left
03:27
chenryn joined,
vendethiel joined
03:28
skids left
03:30
skids joined
03:31
jluis_ joined
03:49
noganex joined
|
|||
dalek | c: a3701a0 | Mouq++ | lib/Language/regexes.pod: Index the various bits of regex syntax |
03:49 | |
c: 36a7751 | Mouq++ | lib/Perl6/TypeGraph/Viz.pm: Fix deprecated code warning (uniq -> unique) |
|||
03:51
noganex_ left
04:07
chenryn left
04:11
vendethiel left
|
|||
TimToady | m: say (1..100000).roll(1000) | 04:24 | |
camelia | rakudo-moar 243c16: OUTPUT«95331 55844 33254 83882 47805 18876 76896 10775 62979 92343 18244 38064 40059 4978 35662 48270 68573 3512 32207 65144 87412 39775 86642 1309 33914 2836 62423 57913 74684 30618 89642 72568 67256 56071 41681 15280 24688 77655 89858 40629 87495 55608 52267 14…» | ||
TimToady | that's probably a better way to produce lots of random integers | ||
I guess the original wanted (^100000).roll(1000000) or so | 04:25 | ||
wrt the xml method, I'd want to know what in the design prevents overriding/wrapping a method via normal subclassing | 04:29 | ||
something is behaving non-virtually to make that difficult, it would seem | 04:30 | ||
04:38
Ben_Goldberg left
04:41
BenGoldberg joined
04:53
chenryn joined
05:18
vendethiel joined
05:34
jluis_ left
05:40
erdic left
05:41
vendethiel left
|
|||
dalek | kudo/coerce-multi: 9faa0e7 | hoelzro++ | src/ (2 files): Start on implementation of COERCE COERCE is a multi that takes a value and a type object; users wishing to define special semantics for how a value of a given type is coerced to other type may implement the appropriate candidate for COERCE to perform that coercion. The default is call a method of the same name as the type object's class on the value. This implementation doesn't work on; it fails a few spec tests, because sometimes, it seems, COERCE refers to a Null repr? |
05:44 | |
hoelzro | so I started working on an implementation of COERCE, per the discussion last week | 05:45 | |
unfortunately, some of the spec tests fail on my code; it seems that in BOOTSTRAP.nqp, it can't find COERCE, which I defined in Any.pm | |||
the line in question is this: github.com/rakudo/rakudo/blob/coer....nqp#L2649 | |||
if someone could help me diagnose the problem, I'd be grateful! | 05:46 | ||
sleep & | |||
moritz | Mouq: I'd index them just as "regex \N" or so | 05:50 | |
Mouq | moritz: Hmm, yeah | 05:52 | |
dalek | c: 1c80bad | Mouq++ | lib/Language/regexes.pod: Classify regex metachars as "regex". moritz++ |
05:53 | |
05:54
adu left
|
|||
moritz | just for the record, this is the first time I'm doing such big/complex documentation project, so my opinion is as good as any other | 05:55 | |
05:58
vendethiel joined
05:59
mr-foobar left
|
|||
Mouq | moritz: Right, but a) you're really good at documentation b) I hadn't considered just using "regex", kind of an "Oh, duh" moment there | 06:08 | |
06:21
vendethiel left
06:31
bjz joined
06:32
kurahaupo joined
06:33
atroxaper joined
06:36
BenGoldberg left
06:40
atroxaper left,
xfix joined
06:48
bjz left
06:50
erdic joined
06:57
erdic left,
Rounin joined
07:00
RPu left
07:03
erdic joined
07:12
yeahnoob left
07:13
dj_goku left
07:18
jakesyl left
07:20
dj_goku joined,
dj_goku left,
dj_goku joined
07:22
FROGGS joined,
vendethiel joined
07:25
kaleem joined,
Mouq left
07:26
gfldex joined
07:28
darutoko joined
07:45
vendethiel left
07:46
bjz joined
07:50
gfldex left
07:57
jluis left
08:04
prime left
08:05
prime- joined
|
|||
[Tux] | FWIW The Nil is only droppen on assignment | 08:09 | |
08:09
vendethiel joined
|
|||
[Tux] | m: (1,Nil,2).perl.say | 08:09 | |
camelia | rakudo-moar 243c16: OUTPUT«(1, Nil, 2)» | ||
[Tux] | m: my@x=(1,Nil,2);@x.perl.say | 08:10 | |
camelia | rakudo-moar 243c16: OUTPUT«Array.new(1, 2)» | ||
08:12
zakharyas joined
08:25
rindolf joined
08:28
xinming left
|
|||
dalek | c: 2385768 | moritz++ | lib/Language/regexes.pod: Prevent a newline from breaking apart a code block |
08:29 | |
moritz | feedback to the pod folks: I find highly annoying that newlines in indented code blocks break up that code block into two | ||
08:32
yeahnoob joined,
vendethiel left,
xinming joined,
virtualsue joined
08:33
rurban_ joined
08:38
vendethiel joined
08:40
daxim_ left
08:41
yeahnoob left
08:43
yeahnoob joined
08:44
abraxxa joined
08:46
yeahnoob left
08:49
chenryn left
08:51
jluis joined
09:00
vendethiel left
09:09
kurahaupo left
09:10
yeahnoob joined
|
|||
dalek | kudo/nom: da6755b | lizmat++ | src/core/Any.pm: Fix adverbed slices on the JVM Apparently, doing an nqp::atkey on an key that does not exist, creates some internal confusion on the JVM, causing adverbed slice breakage after my last optimization in that area. |
09:13 | |
09:13
brrt joined
|
|||
brrt | \o | 09:13 | |
just a thought that occured to me; in python something i'd really want is a shorthand for 'does this compute without raising an exception, and if so, what is it's value'.... | 09:14 | ||
that's what failures are for, aren't they | |||
nwc10 | are you prepared to wait forever for your answer? :-) | 09:16 | |
I believe a certain Turing chap would have advice for you if you wanted to say "No" | |||
brrt | hmm | ||
that's not really the kind of thing i'm aiming at | |||
nwc10 | so, "not sure" is an acceptable answer from your function? | 09:17 | |
brrt | if this only applies to guaranteed-to-terminate functions, like most coercions are, then i'm quite happy | ||
m: my $x = "foo"; say $x.Int; | |||
camelia | rakudo-moar 243c16: OUTPUT«Cannot convert string to number: base-10 number must begin with valid digits or '.' in '⏏foo' (indicated by ⏏) in method Int at src/gen/m-CORE.setting:14131 in method Int at src/gen/m-CORE.setting:6334 in block <unit> at /tmp/AISzqMEl5J:1…» | ||
brrt | right, and that'd be something where i'd want a softer version, something that said '.IntPls' | 09:18 | |
:-) | |||
or even: my $x = please $y.Int; | 09:19 | ||
which i'd think be the perlish thing to do | 09:20 | ||
09:20
chenryn joined,
andreoss joined
|
|||
brrt | and my suspicion is that this is already in the language and that i don't know it | 09:20 | |
FROGGS | m: my $x = "foo"; say $x.?Int; | 09:24 | |
camelia | rakudo-moar 243c16: OUTPUT«Cannot convert string to number: base-10 number must begin with valid digits or '.' in '⏏foo' (indicated by ⏏) in method Int at src/gen/m-CORE.setting:14131 in method Int at src/gen/m-CORE.setting:6334 in block <unit> at /tmp/nCsrdHsP2x:1…» | ||
FROGGS | m: my $x = "foo"; say $x.?hurz; | ||
camelia | rakudo-moar 243c16: OUTPUT«Nil» | ||
FROGGS | m: my $x = "foo"; say $x.hurz; | ||
camelia | rakudo-moar 243c16: OUTPUT«No such method 'hurz' for invocant of type 'Str' in block <unit> at /tmp/lbuCWDQvQ_:1» | ||
FROGGS | m: my $x = "foo"; say $x.Int.WHAT; | 09:25 | |
camelia | rakudo-moar 243c16: OUTPUT«Cannot convert string to number: base-10 number must begin with valid digits or '.' in '⏏foo' (indicated by ⏏) in method Int at src/gen/m-CORE.setting:14131 in method Int at src/gen/m-CORE.setting:6334 in block <unit> at /tmp/QCSjRVUTD3:1…» | ||
FROGGS | so, it dies instead of failing | ||
brrt | m: my $x = "foo"; try { say $x.Int; } CATCH { say "OH NO"; } | 09:26 | |
camelia | rakudo-moar 243c16: OUTPUT«===SORRY!=== Error while compiling /tmp/0D481pW9JVTwo terms in a rowat /tmp/0D481pW9JV:1------> my $x = "foo"; try { say $x.Int; } ⏏CATCH { say "OH NO"; } expecting any of: infix stopper …» | ||
09:26
mvuets joined
|
|||
brrt | ugh | 09:26 | |
FROGGS | m: my $x = "foo"; try { say $x.Int; CATCH { say "OH NO"; } } | ||
camelia | rakudo-moar 243c16: OUTPUT«OH NOCannot convert string to number: base-10 number must begin with valid digits or '.' in '⏏foo' (indicated by ⏏) in method Int at src/gen/m-CORE.setting:14131 in method Int at src/gen/m-CORE.setting:6334 in block <unit> at /tmp/SNMDAC…» | ||
FROGGS | m: my $x = "foo"; try { say $x.Int; CATCH { default { say "OH NO" } } } | ||
camelia | rakudo-moar 243c16: OUTPUT«OH NO» | ||
FROGGS | hmmm | 09:27 | |
there was an RT ticket about that IIRC | |||
brrt | about which of them | 09:28 | |
FROGGS | about not catchable exceptions and .?foo misbehaviour | ||
09:30
dakkar joined
|
|||
psch | irclog.perlgeek.de/perl6/2014-10-25#i_9564960 # this is related | 09:32 | |
coercion passes through CATCH for some reason currently, which is buggy | |||
i'm not aware of any .?-misbehavior | |||
#123053 a ticket | 09:33 | ||
synopsebot | Link: rt.perl.org/rt3//Public/Bug/Displa...?id=123053 | ||
09:37
yeahnoob left
09:47
Kristien joined
|
|||
Kristien | fortune just told me a quote from TimToady | 09:47 | |
does this mean today is my lucky day? | |||
moritz | Kristien: it means today is your Perl 6 day :-) | 09:52 | |
Kristien | :D | ||
09:57
espadrine joined
09:58
yeahnoob joined
10:03
kaare_ left,
kjs_ joined
|
|||
brrt | oh, try as expression already makes a failure | 10:04 | |
that's more sensible than my suggestion | |||
10:04
kaare_ joined
|
|||
psch | hm, &die goes past try but fail doesn't, except in "foo".Numeric..? | 10:09 | |
10:09
Kristien left
|
|||
psch | m: sub foo { die "bar" }; say try foo; | 10:10 | |
camelia | rakudo-moar 243c16: OUTPUT«Nil» | ||
psch | m: class Foo { method Numeric { fail "can't .Numeric Foo!" }; }; my $foo = Foo.new; say (try $foo.Numeric).WHAT; say ($foo.?Numeric).perl | ||
camelia | rakudo-moar 243c16: OUTPUT«(Failure)Failure.new(exception => X::AdHoc.new(payload => "can't .Numeric Foo!"))» | ||
psch | m: class Foo { method Numeric { die "can't .Numeric Foo!" }; }; my $foo = Foo.new; say (try $foo.Numeric).WHAT; say ($foo.?Numeric).perl | ||
camelia | rakudo-moar 243c16: OUTPUT«Nilcan't .Numeric Foo! in method Numeric at /tmp/9AV_wkjPUF:1 in block <unit> at /tmp/9AV_wkjPUF:1» | ||
psch | i'm confused :P | ||
10:12
fhelmberger joined
|
|||
psch | m: sub foo { fail "bar }; say try foo | 10:14 | |
camelia | rakudo-moar 243c16: OUTPUT«===SORRY!=== Error while compiling /tmp/2X3zVQPoANUnable to parse expression in double quotes; couldn't find final '"' at /tmp/2X3zVQPoAN:1------> sub foo { fail "bar }; say try foo⏏<EOL> expecting any …» | ||
psch | m: sub foo { fail "bar" }; say try foo | ||
camelia | rakudo-moar 243c16: OUTPUT«bar in method gist at src/gen/m-CORE.setting:14135 in sub say at src/gen/m-CORE.setting:16907 in block <unit> at /tmp/F0h4_hdEjv:1» | ||
psch | which one of sub and method is wrong there? it seems to me like that should be consistent... | ||
in sub, fail goes through try, in method die goes through try | |||
10:19
pecastro joined
10:28
osfameron left
10:29
osfameron joined
10:32
kjs_ left
10:51
vendethiel joined
10:59
virtualsue left
11:02
telex left
11:04
telex joined
11:05
vendethiel left
11:12
kjs_ joined
11:18
vendethiel joined
11:22
Kristien joined
|
|||
lizmat | m: say (^10).map: { $_ if $_ > 5 } # this idiom will not work post GLR, right ? | 11:25 | |
camelia | rakudo-moar 243c16: OUTPUT«6 7 8 9» | ||
lizmat | m: say (^10).map: { next unless $_ > 5; $_ } # a better idiom? | 11:26 | |
camelia | rakudo-moar 243c16: OUTPUT«6 7 8 9» | ||
vendethiel | m: say (^10).grep: { $_ > 5 }; # the better idiom? | ||
camelia | rakudo-moar 243c16: OUTPUT«6 7 8 9» | ||
lizmat | vendethiel: yes, but grep is built on top of map :-) | 11:27 | |
vendethiel | that seems like an implementation detail, tho :) | ||
lizmat | in any case, it's not really an answer to my question :-) | ||
andreoss | m: say (^10).map: { last if $_ > 5 ; $_ } | 11:28 | |
camelia | rakudo-moar 243c16: OUTPUT«0 1 2 3 4 5» | ||
lizmat | I think the first case depends on Nil disappearing in lists when it shouldn't | 11:29 | |
Kristien | vendethiel: what did you mean by flattening yesterday? | 11:30 | |
vendethiel | Kristien: flattening in general | 11:31 | |
Kristien | could you give an example? | ||
vendethiel | m: for (1, (2, (3, (4)))) { .say } | ||
camelia | rakudo-moar 243c16: OUTPUT«1234» | ||
masak | good afternoon, #perl6 | ||
Kristien | vendethiel, Oh I see. | 11:32 | |
m: for [1, [2, [3, [4]]]] { .say } | 11:33 | ||
camelia | rakudo-moar 243c16: OUTPUT«1 2 3 4» | ||
Kristien | m: for [1, [2, [3, [4]]]] { .gist.say } | ||
camelia | rakudo-moar 243c16: OUTPUT«1 2 3 4» | ||
Kristien | :O | ||
psch | Kristien: that's subject to change, see pmthium.com/2014/10/apw2014/ | ||
eh, wait | |||
it's not, op-ish for stays flattening iirc | 11:34 | ||
anyway, pmichaud++'s blog has details about how we rather want it | |||
vendethiel | Kristien: [] doesn't flatten | 11:35 | |
m: for [1, [2, [3, [4]]]] { .perl.say; say "||";} | 11:36 | ||
camelia | rakudo-moar 243c16: OUTPUT«[1, [2, [3, [4]]]]||» | ||
Kristien | oh right should use .perl not .gist | ||
psch | m: my @a = 1,2,3; my @b = 0, @a; .perl.say for @b | ||
camelia | rakudo-moar 243c16: OUTPUT«0123» | ||
psch | m: my @a = 1,2,3; my $b = [0, @a]; .perl.say for $b | 11:37 | |
camelia | rakudo-moar 243c16: OUTPUT«[0, 1, 2, 3]» | ||
psch | m: my @a = 1,2,3; my $b = [0, @a]; .perl.say for @$b | ||
camelia | rakudo-moar 243c16: OUTPUT«0123» | ||
11:39
kjs_ left
|
|||
masak | for some reason, no other language has looked at Perl and gone "wow, flattening! gotta copy that feature!"... | 11:39 | |
vendethiel | yeah, for "some" reason ;-) | ||
Kristien | JavaScript did it with futures | ||
and it turned out to be a horrible idea in that case | |||
masak | Kristien: really? url? | ||
Kristien | goodbye generic code | ||
psch | lizmat: how do you expect (^10).map: { $_ if $_ > 5 } do turn out post GLR? having ^10 inside $_ and returning the whole Range? | 11:40 | |
Kristien | masak: robotlolita.me/2013/06/28/promises-...similation | ||
lizmat | psch: good question: I would need to look at pmichaud's post again :-) | 11:41 | |
Kristien | so instead of having map and flatMap (which you should), you have then, which does both depending on the return value of the callback has a property with a certiain name | ||
s/depending on/depending on whether/ | 11:42 | ||
lizmat | psch: that would iterate over a single range object | 11:44 | |
m: say (^10).flat.map: { next unless $_ > 5; $_ } # need to flatten the range post GLR | |||
camelia | rakudo-moar 243c16: OUTPUT«6 7 8 9» | ||
lizmat | m: say (^10).for: { next unless $_ > 5; $_ } # would still flatten post GLR | 11:45 | |
camelia | rakudo-moar 243c16: OUTPUT«6 7 8 9» | ||
psch | lizmat: that's how i read it as well, with (^10).for: { ... } probably being the best candidate for a "new" idiom | ||
lizmat | psch: yep | 11:46 | |
psch | (^10, 10..^20).map: { #`[ work on two Ranges ] } | ||
i have that right too, right? :) | |||
lizmat | psch: yeah, that's the idea | 11:49 | |
masak | Kristien: oh, that discussion. | 11:57 | |
Kristien | yes :D | ||
11:57
Kristien left
|
|||
masak | Kristien: I mentally summarized it as "the JavaScript world split between formalists (in minority) and people who just want to get stuff done" | 11:57 | |
I'm usually on the formalists' side, and they usually end up being "right". | 11:58 | ||
but I don't fully grok what this discussion was about, despite reading lots about it. | |||
including one gargantual github issue in some promises repo. | |||
dalek | kudo/nom: f65b4c0 | lizmat++ | src/core/Any.pm: Fix post-GLR mapping behaviour (^10).for: { $_ if $_ > 5 } will not work post-GLR: the grep family and all of the filtering slice adverbs were depending on this behaviour. |
11:59 | |
11:59
chenryn left
12:04
BenGoldberg joined,
kaleem left
12:10
virtualsue joined
|
|||
masak | gargantuan* | 12:22 | |
lizmat | would it ever make sense to use "gather map {}, @list" instead of "gather for @list {}" ? | 12:25 | |
masak | lizmat: that's hard to answer. | ||
lizmat | I mean, inside the map we do a conditional take | 12:26 | |
masak | lizmat: but I do have a "useless use of gather/take" meme, which sometimes makes me replace "gather/take" with just "map". | ||
lizmat | seems like that's mixing metaphors | ||
masak | yes, that's my feeling too. | ||
but I wouldn't go so far as outlawing it, or saying it would never make sense. | |||
for example, conceivably, the `map` might compute something, and *also*, at the same time, emit stuff through `take`. | 12:27 | ||
lizmat | yeah, but it doesn't in the case I'm looking at | ||
masak | oh, I didn't know you had a case. you said "ever", which made me go hunt for contingenceis. | 12:28 | |
contingencies* | |||
lizmat | yeah, ok, so there *might* be a case | ||
masak | also, you managed to trigger my "no-one will *ever* need this" fallacy alarm. | ||
lizmat | hehe | 12:29 | |
ok, fair enough | |||
ab5tract | lizmat: are you saying that the two are functionally equivalent? i think flattening will be the "list context"-like gotcha for perl6 .. so when it is possible to remove equivalent approaches, it reduces the strain on the programmer to remember whether this different way of doing a thing actually does anything differently, or if its just a different way to say it | 12:31 | |
dalek | kudo/nom: d671638 | lizmat++ | src/core/List.pm: Stop mixing the metaphors! Commit 52262988372 added a gather to fix $a.= uniq. But that made the map a bit bogus. So use a loop instead of a map, for clearer code. This does not seem to have any efficiency effects. |
12:32 | |
ab5tract | for instance, is map { }, @things the same as map { } <=== @things ? i think there is an optimal level (N) of linguistic variety after which the advantages of saying things N+Y different ways diminish | 12:36 | |
ab5tract might be committing heresy? | 12:37 | ||
12:38
rmgk_ joined,
rmgk left,
rmgk_ is now known as rmgk
|
|||
psch | ab5tract: ==> and <== are strictly lazy, while map { }, @list is mostly lazy | 12:40 | |
hoelzro | good morning, #perl6! | ||
masak | \o | 12:41 | |
psch | hoelzro \o | ||
ab5tract: that distinction is NYI though, afair | |||
ab5tract | psch: so mostly lazy would be, "lazy until demonstrably finite" ? | 12:42 | |
psch | S07:Levels of laziness | ||
synopsebot | Link: perlcabal.org/syn/S07.html#Levels_of_laziness | ||
ab5tract | hiya hoelzro :) | ||
ab5tract notices that synopsebot is still linking to perlcabal | |||
psch | ab5tract: so mostly lazy is "eager until encountering something lazy" | 12:43 | |
* + caveats, i suppose | |||
masak | ab5tract: github.com/tadzik/synopsebot | ||
hoelzro | is there a special thing one has to do when invoking Perl 6 multis from NQP land? | 12:44 | |
masak | don't think so | ||
hoelzro | I'm trying to implement my COERCE idea, but some of the spec tests fail because of "Cannot invoke this object (REPR: Null, cs = 0)" | 12:45 | |
psch | hoelzro: for the deprecation for :from<java> i got the sub with $*W.find_symbol, but i don't think you have $*W in BOOTSTRAP | ||
ab5tract | okay, i'll withhold tuits from worrying about levels of laziness, map {} vs .map, etc until after the GLR | ||
hoelzro | hmm | ||
psch | hoelzro: you could try bindhllsym and getcurhllsym, like it's done for the ModuleLoader, but i don't know how sensible that is or if it actually works | 12:46 | |
*gethllsym rather, getcurhllsym does lexical lookup i think | 12:47 | ||
12:48
Kristien joined
|
|||
FROGGS | the 'cur' is about the current high level language, like 'nqp' or 'perl6' | 12:48 | |
psch | ah ok | ||
12:49
chenryn joined
|
|||
Kristien | Should .perl use fully qualified names? | 12:49 | |
12:49
chenryn left
12:50
kaleem joined
|
|||
Kristien | m: module M { class C { } }; M::C.new.perl | 12:53 | |
camelia | ( no output ) | ||
Kristien | m: module M { class C { } }; M::C.new.perl.say | ||
camelia | rakudo-moar 243c16: OUTPUT«C.new()» | ||
Kristien | hmm | ||
12:53
chenryn joined
12:54
kjs_ joined,
kjs_ left
|
|||
psch | m: { die "foo"; CATCH { default { .perl.say } } } | 12:54 | |
camelia | rakudo-moar 243c16: OUTPUT«X::AdHoc.new(payload => "foo")» | ||
psch | m: module M { class C { method perl { "M::C.new()" } } }; M::C.new.perl.say | 12:55 | |
camelia | rakudo-moar 243c16: OUTPUT«M::C.new()» | ||
12:56
test123456 joined
|
|||
ab5tract | m: module Q { my $deep = 15; my sub ex( $x ) { $deep * 15 }; our sub give_ex { &ex } }; my $sub = Q::give_ex; $sub(88).say; | 13:03 | |
camelia | rakudo-moar 243c16: OUTPUT«225» | ||
psch | m: module M { class C { } }; my $c = EVAL M::C.new.perl; say $c.perl # it does break the .perl contract like this | 13:04 | |
camelia | rakudo-moar 243c16: OUTPUT«===SORRY!=== Error while compiling EVAL_0Undeclared name: C used at line 1» | ||
ab5tract | does the value of $deep get inlined into &ex? or does it do a lexotic lookup? | ||
13:05
BenGoldberg left
13:09
test123456 left
13:10
chenryn left
13:11
chenryn joined,
Kristien left
13:14
sqirrel joined
13:15
andreoss left,
andreoss joined
|
|||
ab5tract | and how could i determine which of the two is happening, if possible? | 13:16 | |
13:22
atroxaper joined,
atroxaper left
|
|||
ab5tract | masak: that link implies that synopsebot already should be pointing to design.perl6.org | 13:24 | |
13:29
adu joined
13:30
GREATFOLLOW joined
13:31
kaare_ left
|
|||
GREATFOLLOW | hello guys | 13:31 | |
lizmat | GREATFOLLOW o/ | 13:32 | |
13:33
GREATFOLLOW left
13:36
slavik1 left
|
|||
hoelzro | thanks for the help, everyone! I got it working | 13:39 | |
dalek | kudo/coerce-multi: 0ef2b67 | hoelzro++ | src/ (2 files): Start on implementation of COERCE COERCE is a multi that takes a value and a type object; users wishing to define special semantics for how a value of a given type is coerced to other type may implement the appropriate candidate for COERCE to perform that coercion. The default is call a method of the same name as the type object's class on the value. This implementation doesn't work on; it fails a few spec tests, because sometimes, it seems, COERCE refers to a Null repr? |
13:40 | |
13:40
kjs_ joined
|
|||
ab5tract | hoelzro++ | 13:42 | |
13:42
chenryn left
|
|||
dalek | kudo/coerce-multi: c3de05f | hoelzro++ | src/ (2 files): Start on implementation of COERCE COERCE is a multi that takes a value and a type object; users wishing to define special semantics for how a value of a given type is coerced to other type may implement the appropriate candidate for COERCE to perform that coercion. The default is call a method of the same name as the type object's class on the value. |
13:44 | |
hoelzro | sorry for the spam | ||
the part of the commit message saying how it doesn't work was no longer relevant =) | |||
13:48
sqirrel left
13:50
btyler left
|
|||
dalek | ast/coerce-multi: 03ed810 | hoelzro++ | S02-types/COERCE.t: Start implementing tests for COERCE |
13:53 | |
13:54
Kristien joined
|
|||
ab5tract must have been really tired when reading the lexotic stuff in the synopses, as it is not related at all to his earlier question | 14:00 | ||
i was using the perl6 spec as bed time reading over the holidays, which clearly is a double-edged sword ;) | 14:01 | ||
dalek | kudo/coerce-multi: 27c6f9a | hoelzro++ | t/spectest.data: Use new COERCE test in roast |
14:03 |