»ö« Welcome to Perl 6! | perl6.org/ | evalbot usage: 'perl6: say 3;' or rakudo:, niecza:, std:, or /msg camelia perl6: ... | irclog: irc.perl6.org | UTF-8 is our friend!
Set by sorear on 25 June 2013.
cognominal notes he always ask questions when everyone is away and when he is exhausted. Not the best way for meaningful interactions. 00:08
lue cognominal: that line is inside a token { }, which means it doesn't backtrack. 00:14
nvm, I think I misread your question. <![<]> is still useful for documentation purposes, if nothing else. :) 00:15
cognominal so '<'+ eats the longest possible sequences of '+', does not backtrack, so there is any left. 00:16
cognominal ok. 00:16
thx, lue++
geekosaur wasn't ratchet broken in rakudo for a while? 00:18
(or NYI?)
cognominal geekosaur, I have no idea 00:28
BenGoldberg Is it possible to run perl6 in a java applet? 00:30
liztormato_ Seems we hit something in the air. We lost one engine but are now safe on the ground at JFK 02:23
colomon_ woah 02:32
PerlJam (safe on the ground)++
BenGoldberg birds in engines -- ? 02:35
liztormato Waiting for luggage and vouchers. Seems we're going to spend the night in NY 03:15
The line is long. :-(
liztormato No more flights to Europe today from JFK 03:16
awwaiid on the REPL, is there a way to get a list of all infix: operators? 05:00
moritz m: say ::.keys.grep(/infix/) 05:33
camelia rakudo-moar 77024f: OUTPUT«␤»
moritz m: say MY.keys.grep(/infix/) 05:34
camelia rakudo-moar 77024f: OUTPUT«␤»
moritz m: say OUTER.keys.grep(/infix/)
camelia rakudo-moar 77024f: OUTPUT«␤»
moritz m: say OUTER::OUTER.keys.grep(/infix/)
camelia rakudo-moar 77024f: OUTPUT«␤»
moritz m: say CORE.keys
camelia rakudo-moar 77024f: OUTPUT«␤»
moritz m: say CORE::.keys
camelia rakudo-moar 77024f: OUTPUT«%DEPRECATIONS @UNITS &zip %pvalcodecache %propcodecache $?TABSTOP $UINT64_UPPER $sprintfHandlerInitialized $default &samewith &lastcall &nextsame &callsame &nextwith &callwith &proceed &succeed &redo &next &last &take &take-rw &return &return-rw &RETURN-PA…»
moritz m: say CORE::.keys.grep(/infix/)
camelia rakudo-moar 77024f: OUTPUT«&infix:<~~> &infix:<=:=> &infix:<eqv> &infix:<~> &infix:<x> &infix:<leg> &infix:<eq> &infix:<ne> &infix:<lt> &infix:<le> &infix:<gt> &infix:<ge> &infix:<~|> &infix:<~^> &infix:<~&> &infix:<===> &infix:<before> &infix:<after> &infix:<min> &infix:<max> &infi…»
moritz awwaiid: ^^
timotimo o/ 06:44
nwc10 \o
sergot morning o/ 07:22
timotimo panda still can't get its ecosystem connection thingie 07:35
moritz: did tadzik enable you to fix it?
i'm not sufficiently awake to actually think about this clearly, but: how do we handle situations where our commandline arguments could be "binary nonsense" and we blow up trying to parse it as utf8? how hard is it for us to switch stdin to read bufs instead of utf8 strings? IIRC outputting binary stuff is simple enough, though 07:41
also: do we do something dumb like python where if the stdout returns false for "isatty"?
a friend pointed out that an invalid utf8 string may be a valid filename
timotimo touch $(printf '\xff\xff\xff') 07:44
perl6-m -e '.say' \Xff\Xff\Xff
Unhandled exception: Malformed UTF-8 at line 1 col 1
timotimo generating a Buf instead of a Str if we encounter invalid UTF8 doesn't seem like a good fix, as that would likely break user programs a few lines later ... 07:45
and having Buf in the arguments array also sounds quite annoying 07:46
nwc10 what's the correct place to report spectest bugs? t/spec/S32-list/roll.t should be using ./perl6-m 07:46
right now it's wrongly assuming that . is in $PATH
(or that I'm running Windows)
timotimo if we make our MAIN automatically try to decode Buf into Str when there's a Str argument, that could "work" but give the exact same situation as we have at the moment 07:47
our whole I/O shouldn't consider all filenames/paths to be valid utf8 ...
nwc10 aye, that was a mistake Python 3.0 made, which had to be fixed in 3.1 07:48
timotimo we should absolutely not make that same mistake
nwc10 no, brave new mistakes please
timotimo aye
quote from my friend: "but on a traditional unix filesystem, all you've got is bytes, and people'll just point and laugh at you if you put too much trust into the locale" 07:49
and since Buf is harder to use for common things than Str is ... ouch ... 07:50
the best solution may be to stay the way we are, put fingers in our ears and go "LA LA LA LA" 07:52
because this whole ordeal is shitty. 07:53
timotimo if we offer @*ARGV as a list of bufs, we'll just prompt every single user to include "@*ARGS = @*ARGS>>.decode('utf8') 07:55
" at the beginning of their scripts and we move the exception from internal to user program
which sucks, too
masak good late morning, #perl6 08:13
FROGGS morning
nwc10: IMO it should use $*EXECUTABLE which should always give you an absolute path to the interpreter 08:14
masak lizmat: glad you're safe.
FROGGS timotimo: I'd like to see Buf handling easier... that's why there is a subbuf-rw now, and also why I'd like to add Buf.split 08:16
made easier* 08:17
or so
arnsholt o/ 08:27
jnthn o/ 08:28
FROGGS hi arnsholt! 08:38
arnsholt: how is everything?
arnsholt Pretty good 08:39
FROGGS sounds good :o)
arnsholt Was at $work conference all last week in the US, came back yesterday, so we'll see how this working day goes =)
unnisworld hi all 08:41
masak hi unnisworld. bye unnisworld. 08:42
tadzik timotimo: panda things should work 11:06
I see plenty of 200s in the backlog
moritz \o 11:27
brrt \o moritz 11:36
colomon_ o/ 11:39
ChoHag How do you say without the \n? 11:44
Never mind. 11:45
masak ChoHag: :D 11:48
m: say "OH HAI"; print "\b"
camelia rakudo-moar 77024f: OUTPUT«OH HAI␤»
masak that doesn't work, though. 11:49
FROGGS that... doesn't ring a bell
masak FROGGS: you're thinking of "\a"
m: sub say-without-newline(*@stuff) { print @stuff }; say-without-newline "OH HAI" 11:50
camelia rakudo-moar 77024f: OUTPUT«OH HAI»
masak ChoHag: that's one solution.
FROGGS masak: ahh right, \a for alarm
masak FROGGS: www.funnyjunk.com/funny_pictures/46...s+Alarmed/ 11:51
ChoHag Yes. Maybe perl 6's catch phrase should be There Are More Ways To Do It Now.
masak well, it's more like "There Should Be One Obvious Way To Do It, But We Also Recognize That You Sometimes Want One Of The Others" 11:52
but that's more pithily summarized in "easy things easy, hard things possible"
smls o/ 12:19
timotimo: I think Qt, for example, pretends that filenames are valid UTF strings 12:21
that's why KDE programs cannot handle files with non-UTF8 bytes 12:22
but they don't seem in a hurry to fix it
smls As for Perl 6 MAIN, if commandline parsing were allowed to use the type information of the MAIN signatures (as I proposed a while ago), users could easily decide themselves whether they want to get a Str or Buf 12:24
multi MAIN (Buf $file, :$opt1, :$opt2) { ... } # like so 12:26
moritz prototype it
smls yes, yes
moritz if it works, it'll get adapted :-)
smls haven't even gotten through jnthn++'s NQP course material yet... :)
colomon_ smls: not sure that would help any with hacking MAIN. 12:32
colomon_ admits he's at least a complete overhaul of rakudo behind on how MAIN's internals work. 12:33
sergot m: class A { has $.method; }; say A.new.method;
camelia rakudo-moar 77024f: OUTPUT«(Any)␤»
awwaiid moritz: Thanks! that is most excellent! 12:34
(re: getting list of all infix ops)
moritz awwaiid: you're welcome 12:38
moritz (note that if you look in CORE, you'll miss custom infixes imported from modules; those should be in MY:: or soemwhere in OUTER chain) 12:38
awwaiid ok 12:39
awwaiid sometimes when I use unicode in the repl and then backspace over them, I get my cursor being a few spots to the right visibly from where it actually is. This a common problem? 12:41
moritz awwaiid: are you using moarvm as the backend? 12:43
I think parrot simply uses readline
awwaiid yes
moritz and moarvm its own thingy
might be a bug in moarvms readline replacement
awwaiid ah. lemme try others
moritz but I don't use the REPL much, so I can't tell 12:44
timotimo Could not download module metadata: Failed to connect: connection refused
carlin timotimo: are you on IPv6? 12:46
awwaiid huh. jvm backend works perfectly, parrot is even worse than moarvm. Maybe it's something on this end. Running Rakudo Star 2014.04 12:47
timotimo carlin: i'd hope so! :)(
:)
awwaiid oh well, not worth going into right now
carlin Someone was saying a few days ago that feather's port 3000 service isn't listening for IPv6 connections 12:48
timotimo that's not good 12:50
jnthn It's not moarvm's readline repalcement per se, it's another library (liblinenoise) that it builds if you don't request readline. 12:51
moritz tadzik: could we run the panda metadata server with starman? that supports serving over ipv6, I've read 12:54
FROGGS moritz: we probably need to update panda before we are doing this... because panda does not now about transfer-encoding for example 12:57
I guess the service behind port 3000 is kinda special to spit it out in a way panda can handle 12:58
tadzik moritz: oh, I thought we did that
fixed now 12:59
moritz tadzik: thanks 13:02
tadzik thanks for reporting 13:10
timotimo what kind of program does that, btw?
and should panda learn to optionally use our HTTP::UserAgent module if available?
tadzik oh yes
jnthn For anybody in need of a distraction, another of my talks that got filmed has landed on the web... www.infoq.com/presentations/termino...-collector 13:14
masak \o/ 13:15
cognominal jnthn++
brrt that site doesn't seem helpful at all
(although your presentation might be awesome :-))
FROGGS nice 13:16
jnthn brrt: Oh?
FROGGS jnthn++
brrt i can't actually... see the slides, it seems
oh....
my bad, i don't have flash installed :-) 13:17
FROGGS timotimo and me also had that 'oh...' moment last time :o)
cognominal yafgjt yet another f... good Jonathan talk. 13:20
brrt is watching the talk now 13:35
carlin has dalek beeen abducted by Time Lords again 13:48
timotimo i really like how jnthn pronounces "bump" in his talk 14:31
FROGGS I also like how he says 'instruction' :o) 14:32
carlin (jnthn's accent)++ 14:33
masak British people tend to ask him if he's an American :D 14:38
FROGGS *g* 14:46
masak just accidentally wrote /[.!?]$/ in a Perl 6 regex 14:55
std: /[.!?]$/
camelia std 0f2049c: OUTPUT«===SORRY!===␤Unrecognized regex metacharacter ! (must be quoted to match literally) at /tmp/EXoH_4H4Ky line 1:␤------> /[.!⏏?]$/␤Unable to parse bracketed regex at /tmp/EXoH_4H4Ky line 1:␤------> /⏏[…»
masak m: /[.!?]$/ 14:56
camelia rakudo-moar 77024f: OUTPUT«===SORRY!===␤Unrecognized regex metacharacter ! (must be quoted to match literally)␤at /tmp/l4mvbMrOnD:1␤------> /[.⏏!?]$/␤Unable to parse expression in metachar:sym<[ ]>; couldn't find final ']' ␤at /tmp/l4…»
hoelzro morning #perl6 14:59
FROGGS hi hoelzro 15:00
lizmat catches up on the clogs while sitting in the lobby of the Holiday Inn Jamaica 15:48
jnthn Jamaica? o.O 15:49
lizmat well, hardly 15:50
but it had a room with a bed
and wifi
ChoHag Is there an explanation of how perl 6 deals with nested hashes data structures via '%new = (%a, %b)'? 15:53
lizmat ChoHag: by default, keys are strings 15:58
lizmat so you will have a stringified %a as the key 15:58
hmm... guess not 15:59
seems it flattens first
lizmat m: my %a=(a=>1); my %b=(b=>2); my %c=(%a,%b); say %c 16:00
camelia rakudo-moar 77024f: OUTPUT«("a" => 1, "b" => 2).hash␤»
ChoHag It's quite reassuring when the regulars here also consistently forget what perl 6 does and how.
lizmat m: my %a=(a=>1); my %b=(b=>2); my %c=($%a,$%b); say %c
camelia rakudo-moar 77024f: OUTPUT«("a" => 1, "b" => 2).hash␤»
lizmat now *that* I find off
*odd
ChoHag: regulars are still newbies in many areas :-) 16:01
jnthn %h = %a, %b; # will flatten, of course. Just like in Perl 5, no? 16:02
jnthn $%a flattening, otoh, is kinda odd 16:03
lizmat that's what I'm saying :-)
jnthn I'm guessing Hash.STORE might just be looking at type, not containerness
lizmat m: my %a=(a=>1); my %b=(b=>2); ($%a,$%b).perl.say 16:04
camelia rakudo-moar 77024f: OUTPUT«({"a" => 1}, {"b" => 2})␤»
lizmat jnthn: I guess the: 16:05
elsif EnumMap.ACCEPTS($x) {
for $x.list { self.STORE_AT_KEY(.key, .value) }
is not checking containerness...
jnthn right 16:06
Also, should use nqp::istype($x, EnumMap)
lizmat you fix or I fix ? 16:07
jnthn Go for it, I'm working on an async sockets bug. 16:09
lizmat ok 16:10
lizmat is not really awake yet
how do I check for containerness again? nqp::something?
jnthn nqp::iscont
lizmat right 16:11
jnthn++
lizmat jnthn: it seems that the setting is depending on flattening behaviour :-( 16:20
jnthn "fun" 16:21
lizmat fsvo fun 16:24
like landing a 747-400 without using the flaps 16:25
:-)
while being escorted with fire engines with the full lightshow on 16:26
timotimo i think i'm going to need some more help finding things to report in the weekly 16:31
timotimo i remember performance improvements, some benchmark additions ... hmm 16:32
jnthn lizmat: That sounds rather concerning...
timotimo gotta run now, though 16:33
jnthn timotimo: OSR landed, inlining leanred ext ops, various other bits of performance work
timotimo yeah, those i remember well :)
jnthn timotimo: And some threads/async socket fixes from me today
lizmat jnthn: it was concerning when we where up there, down on the ground not so much
[Coke] . o O (Nevada) 16:34
timotimo thank you :) 16:36
vendethiel what's the perl 6 bench page against ? can't find it anymore 16:37
timotimo there's not "a page" 16:44
i just have a folder where i drop off lots of results
timotimo japhb/perl6-bench is the repository on github 16:44
lizmat this seems wrong: 16:58
my %args = { :$!year, :$!month, :$!day, :$!hour, :$!minute,
:$!second, :$!timezone, :&!formatter, %_ };
jnthn yeah; wants to be parens or binding 17:00
^
& even
lizmat ok, builds now, spectest definitely not clean 17:03
:-(
timotimo jnthn: did you see kamils mail on the users list? i see the same failure 17:04
the imcc complains about emitted code after we check for poisoning mumble mumble
psch hi #perl6 17:04
timotimo p6weekly.wordpress.com/?p=189&s...198981e6b1 - here's the first draft of the weekly, i hope i've missed a lot of things :P
i'm going grocery shopping now-ish. 17:05
lizmat if my fix for Hash.STORE is breaking this many spectests: gist.github.com/lizmat/d217d59d0138c8ea0fd9 17:08
I wonder what it will do to the ecosystem and DarkPAN
lizmat m: my %hash = {a => 1, b => 2}; 17:09
camelia ( no output )
lizmat with my fix, this now breaks with: 17:10
$ 6 'my %hash = {a => 1, b => 2};'
Odd number of elements found where hash expected
TimToady: do you have an opinion on this behaviour?
jnthn Ouch 17:14
Yes, let's get TimToady++'s take before putting it in nom
Can commit it in a branch for now, of course.
timotimo what kind of problem does it fix? 17:16
jnthn timotimo: A case of seemingly unwanted flattening. 17:17
Or surprsing flattening, at least.
timotimo isn't it always? ;) 17:18
jnthn Generally, no, but places where the rules get broken mostly aid the perception that it is. 17:21
lizmat oddly enough, it seems at least one TODO is pasing now 17:22
passing 17:23
#?rakudo todo 'non-flattening hash refs'
so it would appear that it is the intent to have it work this way
looking at the spectests so far, it seems they mostly suffer from the misunderstanding that my %h = {...} is the same as my %h = (...) 17:25
ChoHag Can I tell whether an attribute has been set by the hard-coded default, arguments to new or run-time use of the accessor? 17:29
The only case I really care about right now is hard-coded vs. everything else. 17:30
lizmat not sure you can, unless you do something like: 17:31
has $!foo = 42 but hardcoded;
ChoHag Alternatively, can I wrap somehow the code which actually sets the default?
the '= ...' magic is just a trait_mod sub with a callable argument somewhere isn't it? 17:32
(FSVO 'just')
jnthn Can't quite remember, but I know that the callable is accessible on the Attribute instance.
And it's some kind of routine, iirc...it's probably wrappable. 17:33
m: say Attribute.^methods(:local)
camelia rakudo-moar 77024f: OUTPUT«<anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> compose apply_handles get_value set_value container has-accessor readonly package Str gist␤»
moritz iirc it's not a routine is the LHS is a constant
jnthn Oh, yeah. 17:34
jnthn A handy optimization until this point :) 17:34
m: say Attribute.^method_table.keys
camelia rakudo-moar 77024f: OUTPUT«new name type container_descriptor auto_viv_container has_accessor rw set_rw set_readonly default_to_rw set_build build set_box_target box_target positional_delegate associative_delegate is_generic instantiate_generic compose apply_handles get_value set_va…»
jnthn .build I'd guess
lizmat I think I'm going to correct the %hash = {} thinko's in the test-suite, when they're clearly wrong 17:35
they should still work without the container check in Hash.STORE
.oO( dalek, oooo, dalek, kitty kitty kitty, where aaaarre you? )
17:38
ChoHag How about another angle. I already have an attribute trait_mod function where it's relevant. Can I tell in there if a default value has been supplied to the attribute? 17:42
And, as an aside, when does that default-setting block actually run? 17:43
carlin dalek is off fighting time lords again 17:48
xfix rn: say eval "2 + 2" 17:50
camelia rakudo-jvm 77024f: OUTPUT«(timeout)»
..niecza v24-109-g48a8de3: OUTPUT«===SORRY!===␤␤Undeclared routine:␤ 'eval' used at line 1␤␤Unhandled exception: Check failed␤␤ at /home/p6eval/niecza/boot/lib/CORE.setting line 1502 (die @ 5) ␤ at /home/p6eval/niecza/src/STD.pm6 line 1147 (P6.comp_…»
..rakudo-{parrot,moar} 77024f: OUTPUT«4␤Saw 1 call to deprecated code during execution.␤================================================================================␤Sub eval (from GLOBAL) called at:␤ /tmp/tmpfile, line 1␤Please use 'EVAL' instead.␤--------------------…»
lizmat lunch and commute to JFK& 17:56
timotimo chohag, the default buildall does the invocation 18:25
try throwing an exception in the default value and look at the trace
vendethiel has convinced those two that Perl 6 is A Great Thing
one of them is happily hacking away
timotimo may need to use - ll-exception 18:26
vendethiel do we have any kind of docs on using jvm libs from perl6-jvm ? 18:28
FROGGS vendethiel: there might be a jnthn-talk somewhere 18:30
from like april of last year
vendethiel yep, found it, thanks. Man, what'd we do without the jnthn++ :) 18:31
FROGGS ohh, something less fun I guess :o) 18:32
vendethiel ah, it's on the internals :( 18:38
jnthn vendethiel: Somehwere in there is an example of calling a JVM lib 18:44
ChoHag God damn it. Hack. Run. Hack. Fail. Undo. Fail.
jnthn ChoHag: It's called from the BUILDALL, after all the BUILDs have had a chance to run and any supplied values have been applied.
ChoHag <-- idiot 18:49
FROGGS we all are
psch too! 18:50
i can't quite figure out how to sensibly implement timotimo++'s suggested optimization for tr///
FROGGS good that I forgot what it was a few days ago that made me feel idiotic :o)
psch i.e. returning an object that only calculates the changes when it's evaluated somewhere where an Int is requested
aside from that i'd call tr/// working in my branch, which is good i guess :) 18:51
although i don't know how good an idea adding a &distance method to Str was 18:52
FROGGS the Failure type does some magic when being used as an Int
not really magic, but it does something 18:53
jnthn Implement a method Int that does the calc and probably a method Numeric to delegate to it
psch the "getting it into an object" part was what i was having problems with 19:01
i rewrote Str.distance to return an anon class that does Int, Numeric and Bool as makes sense there
masak what's your favorite way of saying "given @list, there are no two objects with the same .name" ?
psch but my local repo broke again it seems... 19:02
timotimo masak: (bag @list>>.name) == @list 19:03
jnthn ?one(@list>>.name) # cute but not the most efficient
timotimo er, not bag
psch p5-think made me want map to Pairs just now
timotimo set would probably be correct 19:04
jnthn oh, wait...what was I thinking :)
timotimo yeah, what the hell were you thinking? :)
jnthn blames tasty distracting icecream :P
not defined @list.first-index({ (state %){.name}++ }) # maybe 19:05
timotimo that's ... wordy 19:11
doesn't first-index also want a matcher?
like, don't you have to search for "2" or something?
jnthn A closure will do as a matcher :) 19:12
masak I prefer timotimo++'s solution so far. jnthn's is far too stateful for me :) 19:13
timotimo oh, because it's *post*increment
jnthn masak: Local state isn't generally the problem :) 19:14
masak actually, I think I prefer timotimo's to mine, which involved .uniq(:as(*.name))
jnthn: I know, but it tickles my "declarative vs imperative" sense wrongly...
jnthn masak: I'll note that only my one so far can bial as soon as it finds the first duplicate.
masak jnthn: this problem doesn't feel to me like it should have moving parts.
jnthn *ail
masak jnthn: point.
oh, this problem is a monoid, then.
jnthn masak: All problems have moving parts on the inside. Just put what I wrote in a sub and it's pure again :P 19:15
masak like, we could solve it with MapReduce.
jnthn: :)
jnthn: your solution is clever, I'll give you that.
jnthn: but I really don't like to mutate things inside of a .map 19:16
(or any other HOP function, like .first-index in this case)
colomon_ +1 19:21
masak m: class Duper { has %.seen; method add($key) { return %.seen{$key}++ } }; my $d = Duper.new; say ! [||] $d.add($_) for <a b c d e f g> 19:36
camelia rakudo-moar 77024f: OUTPUT«True␤True␤True␤True␤True␤True␤True␤»
masak hm.
m: class Duper { has %.seen; method add($key) { return %.seen{$key}++ } }; my $d = Duper.new; say ! [||]($d.add($_) for <a b c d e f g>)
camelia rakudo-moar 77024f: OUTPUT«===SORRY!=== Error while compiling /tmp/1Aw99Cawhh␤Unable to parse expression in argument list; couldn't find final ')' ␤at /tmp/1Aw99Cawhh:1␤------> y $d = Duper.new; say ! [||]($d.add($_) ⏏for <a b c d e f g>)…»
masak m: class Duper { has %.seen; method add($key) { return %.seen{$key}++ } }; my $d = Duper.new; say ! [||] ($d.add($_) for <a b c d e f g>) 19:37
camelia rakudo-moar 77024f: OUTPUT«True␤»
masak m: class Duper { has %.seen; method add($key) { return %.seen{$key}++ } }; my $d = Duper.new; say ! [||] ($d.add($_) for <a b c d e b g>)
camelia rakudo-moar 77024f: OUTPUT«False␤»
masak ...that's the OO version of jnthn's stately solution.
though ISTR that [||] doesn't short-circuit.
jnthn If the list it gets is lazy then it can evaluate it only as far as needed, I think... 19:38
I'm really not sure what the class adds here :)
masak it doesn't add anything.
I'm only exposing the implicit class that your function-and-state created ;) 19:39
timotimo well, the set solution also doesn't short-circuit
jnthn BTW, today - or maybe tomorrow - is last day to submit YAPC::EU talks. 19:40
masak aye. 19:43
m: my @list = map { (class { has $.name }).new(:name($_)) }, <a b c d e f g>; say so all((bag @list>>.name).values) == 1
camelia rakudo-moar 77024f: OUTPUT«True␤»
masak m: my @list = map { (class { has $.name }).new(:name($_)) }, <a b c d e b g>; say so all((bag @list>>.name).values) == 1
camelia rakudo-moar 77024f: OUTPUT«False␤»
masak this is my favorite solution so far, I think.
jnthn doesn't suggest benchmarking the competing solutions :)
masak I'm dealing with arrays of < 10 elements here. I'm not so terribly worried about performance. 19:44
jnthn Ah, then fine :)
masak I'm just looking for a neat/clean way to express "there are no duplicates". 19:45
jnthn Yeah. It's just that folks here are often way too good at finding cute ways to do things and neglecting performance considerations, then saying "oh noes Perl 6 is slow" :) 19:46
timotimo i got no feedback for my blog post, so i'll publish it now
jnthn timotimo: I missed the link...guess I was doing dinner
timotimo ah
one sec :)
p6weekly.wordpress.com/?p=189&s...198981e6b1 19:47
psch alright, Str.distance now returns a Bool with an anon role that does a lazy-ish Int, i.e. calculates the result when first called
jnthn I mean, in my solution we traverse a list and make a hash. This one products an intermediate list, then turns it into a bag, then produces a list of values in the bag, then makes a junction o fthose values, then auto-threads an operation over that junction. :)
psch if anyone wants to look it over, in case i'm doing something horrible: github.com/peschwa/rakudo/compare/implement_tr
masak jnthn: yes, your point is well taken.
jnthn It *is* a cute solution though :) 19:48
masak and yours is very... industrially sound.
:P
psch i guess the review would happen anyway when i open a PR, so i'll just do that :)
jnthn timotimo: " like in a for loop with many iterations." - I'd remove the 2for"
timotimo: I think japhb++ did some other work on perl6-bench besides the new benchmarks, btw 19:49
jnthn timotimo: You forgot the other inlining improvements too :) 19:50
timotimo mhm 19:52
what would i do without you people :) 19:53
colomon_ jnthn: one thing I've noticed over the years is every book on functional programming I've read starts out with "see how beautiful this functional code is!" and then ten pages later is telling you how to make a much uglier but efficient version. ;) 19:54
vendethiel masak: `+@a.uniq(:by(*.name)) == +@a` :P 19:58
masak vendethiel: yes, that's how I usually imagined it (only without the explicit prefix:<+>) 19:59
s/usually/originally/
I might still go with that solution.
FROGGS that one is actually readable
masak m: my $foo = "OH HAI"; role R[$bar] { method x { say $bar } }; class C does R[$foo] {}; C.new.x 20:00
camelia rakudo-moar 77024f: OUTPUT«(Any)␤»
masak I wonder if we shouldn't emit a warning at 'does R[$foo]'... 20:01
I just did this one by mistake in code -- yes, I ought to know better, but sometimes the brain slips.
masak a warning would've let me know something was amiss. 20:01
it's really the same kind of situation as this:
m: my $foo = "OH HAI"; BEGIN say $foo
camelia rakudo-moar 77024f: OUTPUT«(Any)␤»
masak (which could also do with a warning)
simple examples like this are easy to catch, but when stuff is in the middle of a bigger program... 20:02
masak m: class C { method foo { say "computing"; return 42 } }; given C.new { say .foo; say .foo } 20:04
camelia rakudo-moar 77024f: OUTPUT«computing␤42␤computing␤42␤»
masak m: class C { method foo is cached { say "computing"; return 42 } }; given C.new { say .foo; say .foo }
camelia rakudo-moar 77024f: OUTPUT«computing␤42␤42␤»
masak oh, nice. 'is cached' works on methods.
(whoever implemented that)++
FROGGS lizmat++
moritz probably lizmat++ 20:05
masak I think it was lizmat++, yes.
m: class C { method foo is cached { say "computing"; return 42 } }; say C.new.foo; say C.new.foo 20:06
camelia rakudo-moar 77024f: OUTPUT«computing␤42␤42␤»
masak hm, but that could be a problem, depending on what the user expected. 20:07
I think I would expect caching to be per-object.
FROGGS nqp-m: my $foo := "OH HAI"; my role R[$bar] { method x() { say($bar) } }; class C {}; my $c := C.new(); $c.HOW.mixin($c, R.HOW.curry(R, $foo)); $c.x() 20:08
camelia nqp-moarvm: OUTPUT«OH HAI␤»
FROGGS masak: so it could work I guess
colomon_ m: class C { has $.x; method foo is cached { say "computing"; return 42 } }; say C.new(x => 2).foo; say C.new(x => 1).foo
camelia rakudo-moar 77024f: OUTPUT«computing␤42␤computing␤42␤»
colomon_ masak: presumably its cached on self as well
*it's 20:09
timotimo does somebody remember who added what to rosettacode recently?
FROGGS masak: nvm
masak FROGGS: :) 20:10
FROGGS: compile-time, run-time.
FROGGS yeah
but still
:o)
masak colomon_: if it is, then why does it only run once for two different selfs?
colomon_ masak: ….. hmm 20:11
FROGGS m: class C { method foo is cached { say "computing"; return 42 } }; say C.new.WHICH; say C.new.WHICH
camelia rakudo-moar 77024f: OUTPUT«C|139757346896128␤C|139757346904040␤»
FROGGS I though this was the key.... 20:12
timotimo publish'd
FROGGS timotimo++
colomon_ masak: my $key := c.gist; 20:13
m: class C { method foo is cached { say "computing"; return 42 } }; say C.new.gist; say C.new.gist
camelia rakudo-moar 77024f: OUTPUT«C.new()␤C.new()␤»
colomon_ that's why
FROGGS hmmm
colomon_ thinks, anyway
FROGGS iiinteresting 20:14
colomon_ m: class C { has $.x is rw; method foo is cached { say "computing"; return 42 } }; my $c = C.new(x=>2); say $c.foo; $c.x++; say $c.foo; 20:15
camelia rakudo-moar 77024f: OUTPUT«computing␤42␤computing␤42␤»
masak colomon++ 20:24
I don't know which part of that oughta change, but I don't think self should be cached that way ;)
colomon_ seems to me that's a fine first approximation to a solution. 20:30
masak well, what do you know -- my "does it have duplicates" solution ended up looking quite different, because the real question my code was asking was "which are the duplicates"... 20:38
timotimo oh 20:39
so more like .bag + grep(2)? :)
jnthn *>2
*>=2
but yeah, sounds cute
timotimo m: say 2 ~~ 2; say 3 ~~ 2 20:40
camelia rakudo-moar 77024f: OUTPUT«True␤False␤»
timotimo depends on your definition of "duplicate"
jnthn true :)
masak at-least-duplicate :) 20:51
non-unique 20:52
timotimo multiples? :)
slava-wr0k heredoc adverbs confuse me ... :(
masak it's almost as if I were grasping for a method .nonuniq ;) 20:53
moritz :to<END>:confusing
masak :to<DIE>:to<SLEEP>
moritz good idea
o/
masak hopes moritz choose the "sleep" option o.O
moritz too
masak :)
slava-wr0k I have XML that I want to generate (repeating the same block with differing values), so I have a loop that goes through all the values I need, I can't figure out the right operator with the right adverb, since in some cases it tries to interpret <TAG> as if it is the <> operator 20:54
timotimo as a quick fix: you could also use :to/foo/ 20:55
slava-wr0k for @values -> $myvalue { say q:to/END/; <mytag>$myvalue</mytag> END }
something like that
timotimo ah, hehe.
slava-wr0k I think I want to use :single 20:56
timotimo well, q should never interpolate
slava-wr0k but I am confused when
slava-wr0k qq:heredoc:s? 20:56
timotimo that would
and $foobar<test> would surely look like you wanted to do a hash access
would it be bad to always wrap your interpolated values in { }?
jnthn Yeah, that may be easiest 20:57
And then q:c:to/END/
timotimo i think in that case you can also use q? if not, q:c
slava-wr0k qq:heredoc:single with {} around variable
works
ty
I think I get it now
{} is always a good idea to denote access
timotimo "single" is hard to search for in the synopses >_> 20:58
slava-wr0k hmm, just qq:heredoc is fine
timotimo at least with the google search widget
slava-wr0k ty :)
masak m: sub foo {}; for foo -> $x {}; say "alive" 21:03
camelia rakudo-moar 77024f: OUTPUT«===SORRY!===␤Function foo needs parens to avoid taking the block.␤at /tmp/TusXAJFOjz:1␤------> sub foo {}; for foo -> $x {}⏏; say "alive"␤Missing block (apparently taken by 'foo')␤at /tmp/TusXAJFOjz:1␤----…»
masak std: sub foo {}; for foo -> $x {}; say "alive"
camelia std 0f2049c: OUTPUT«===SORRY!===␤Function 'foo' needs parens to avoid gobbling block at /tmp/NN0oiQaAMg line 1:␤------> sub foo {}; for foo⏏ -> $x {}; say "alive"␤Missing block (apparently gobbled by 'foo') at /tmp/NN0oiQaAMg line 1:␤--…»
masak how come Rakudo prefers "taking" to "gobbling" there?
I always found "gobbling" rather charming, and descriptive. 21:04
jnthn You haz a commitbitz0r... 21:04
psch i don't remember if it rakudo used "gobble" before i added the typed exception, but i definitely used "take" for it... 21:06
sorry for removing a bit of charm :)
masak I can definitely change it back, just wanted to check for reasons first :)
"take" for me conveys accepting arguments, which isn't incorrect in this case. 21:07
but "gobble" conveys the parsing angle, which is the more fundamental problem.
jnthn psch++ # making it give an error at all
psch yeah, that makes sense; "gobble" didn't seem formal/professional enough to me, the difference wrt parsing angle/arguments didn't occur to me 21:08
timotimo when are we ever formal/professional? :) 21:11
FROGGS it is also interesting to see where std sets the eject 21:13
TimToady professionals communicate clearly, and "gobble" is precisely what it does :) 21:18
masak right. 21:21
masak changes it
psch vows to pay close attention to existing wording. :P 21:22
masak psch: everybody wins. nice. :) 21:24
change made. building it.
jnthn psch: In 5e19a4bef09, I notice you go to the trouble of creating an anonymous lexical for orig_lhs, but here I think a local would do? 21:25
psch: Then ops :op<bind> to store in it
s/ops/use/
Instead of :op<p6store> 21:26
Then it won't leak.
psch jnthn: i tried binding, but binding changes the value i want to compare later on 21:26
timotimo missing a decont?
jnthn psch: Oh...what timotimo++ just said, though. QAST::Op.new( :op('decont'), ... ) around the lookup of $_ 21:27
psch alright, i'll correct that, thanks 21:28
timotimo wow! i actually sniffed out a missing decont! :)
i'm getting better at this whole thing
jnthn psch: Mostly it's worth correcting 'cus otherwise orig_lhs will leak 21:28
masak regrets that Perl 6 didn't nail eta reduction for methods :/ 21:39
timotimo well, it's a hard thing, IMO. 21:40
masak I'm not so sure. 21:41
masak the hardest thing is probably that the "natural" syntax for it -- $obj.method -- already means "call .method on $obj" 21:42
and there's no natural analogue to &naming_not_calling_a_sub 21:43
though maybe &($obj.method) could be made to fly -- would need to be caught at parse time, though. 21:44
masak something tells me that won't be pretty. 21:44
psch jnthn: i fixed it as per your and timotimo++'s instructions
lue masak: way I see it, either we redefine .&sub-as-meth to be an uncalled method, or we find some unicode symbol for an amerpsandy dot, with the texas version something like $obj(.)method or $obj(&)method :) 21:45
*ampersandy
masak lue: I'm rather fond of .&sub-as-meth by now. I use it to define ad-hoc lexically scoped "exomethods" :) 21:48
lue: and I am always *very* skeptical to any unicode-y part of core. 21:49
I'm a traditionalist. I don't even like ¢
lue Perhaps we need a new, vaguely m-shaped sigil. 21:50
lue masak: I'm the opposite, I wish we never got rid of ¢apture, just because it meant I could use ¢ :) 21:50
masak lue: methods and subs are indistinguishable if you look deep enough.
timotimo &(obj.method) sounds really fishy
masak timotimo: yes, exactly.
timotimo: it's mostly a measure of my desperation.
lue I'm looking at my keyboard, and I can't immediately think of a good symbol for "give me this method" in place of the * in $obj.*meth 21:53
vendethiel I'm on windows and I despise these unicode symbols :( 21:57
lue vendethiel: why? I thought windows had a better grip on things.
vendethiel how so ?
Requiring me to type alt+WXYZ everytime I want a symbol is something I will not accept out of a language
masak m: sub foo(&match) { say "matches" if match("foo") }; foo(/foo/) 21:58
camelia rakudo-moar 77024f: OUTPUT«No such method '!cursor_start' for invocant of type 'Str'␤ in sub foo at /tmp/mmpaWWJaCJ:1␤ in block at /tmp/mmpaWWJaCJ:1␤␤»
masak m: sub foo(&match) { say "matches" if "foo" ~~ &match }; foo(/foo/)
camelia rakudo-moar 77024f: OUTPUT«matches␤»
flussence and entering non-latin1 chars on windows using alt-codes requires a regedit too...
lue vendethiel: I'd look into some sort of compose-key-ish solution. Compose + < + < is an easy way to type «, for example :) (or maybe ask jnthn how he handles it (or doesn't)) 22:00
vendethiel lue: no, that's still annoying as hell. I want to be able to see this stuff on my keyboard 22:01
and I don't have an APL one (though that'd be fun :P)
lue vendethiel: I don't know how feasible that desire is, 0x11_000 keys requires a lot of space :) 22:02
vendethiel mmh ? 22:03
lue (There's also the OSX solution that creates additional levels of modifier keys, similar to what Shift does)
sorry, 0x11_0000
lue would suggest a hand-writing based input method, instead of keyboards, were it not for all the confusables. 22:06
timotimo on windows, you can type these characters easily if you have the neo2 layout 22:16
but unfortunately it's a variant of the german layout
so you'll also have üöä directly on their own keys
lue timotimo: biggest problem for me using a german layout is that I don't have the extra keys to do it :) 22:17
timotimo extra keys? 22:21
lue Yeah, I have a US keyboard, so I'm missing a couple keys in (I think) the middle and bottom rows. 22:22
timotimo oh? i didn't know that 22:23
well, neo2 is a pleasure to work with, IMO 22:24
kinda sad i can't recommend it to you properly
masak 'night, #perl6 22:26
jnthn o/ masak
lue timotimo: I'm kinda used to how easily I can access all the symbols on my keyboard, so I'm not sure I want to demote them all to level 3. At least it gets ß ↔ ẞ right, unlike the standardized layout :) 22:27
masak o/
vendethiel m: say (flat (%(1 => 2, 3 => 4), ('foo', 'bar'))).perl 22:30
camelia rakudo-moar 77024f: OUTPUT«("1" => 2, "3" => 4, "foo", "bar").list␤»
timotimo heh 22:34
i feel quite comfortable using layer 3 for all the symbols