»ö« Welcome to Perl 6! | perl6.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: irc.perl6.org or colabti.org/irclogger/irclogger_log/perl6 | UTF-8 is our friend! 🦋
Set by Zoffix on 25 July 2018.
cpan-p6 New module released to CPAN! Smack (0.4.0) by 03HANENKAMP 02:15
Xliff m: say |($random-size ?? 50..100.rand.Int !! 50) xx 2; 04:31
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable '$random-size' is not declared
at <tmp>:1
------> 3say |(7⏏5$random-size ?? 50..100.rand.Int !! 50)
Xliff m: say |Bool.pick ?? 50..100.rand.Int !! 50) xx 2;
camelia 5===SORRY!5=== Error while compiling <tmp>
Unexpected closing bracket
at <tmp>:1
------> 3say |Bool.pick ?? 50..100.rand.Int !! 507⏏5) xx 2;
Xliff m: say |(Bool.pick ?? 50..100.rand.Int !! 50) xx 2;
camelia (50)
Xliff m: say |(Bool.pick ?? 50..100.rand.Int !! 50) xx 2;
camelia (50 51 52 53 54 55 56 57)
Xliff m: say (Bool.pick ?? 50..100.rand.Int !! 50) xx 2;
camelia (50..53 50)
Xliff m: say (Bool.pick ?? 50..100.rand.Int !! 50) xx 2;
camelia (50..84 50)
Xliff m: say (Bool.pick ?? (50..100).rand.Int !! 50) xx 2; 04:32
camelia (50 95)
Xliff m: say (Bool.pick ?? (50..100).rand.Int !! 50) xx 2;
camelia (50 65)
Xliff m: say (Bool.pick ?? (50..100).rand.Int !! 50) xx 2;
camelia (79 82)
Xliff m: say (Bool.pick ?? (50..100).rand.Int !! 50) xx 2;
camelia (50 69)
Xliff m: say (Bool.pick ?? (50..100).rand.Int !! 50) xx 2;
camelia (77 50)
Xliff m: my $a = Bool.pick; say ($a ?? (50..100).rand.Int !! 50) xx 2;
camelia (94 51)
Xliff m: my $a = Bool.pick; say ($a ?? (50..100).rand.Int !! 50) xx 2;
camelia (50 50)
Xliff m: my $a = Bool.pick; say ($a ?? (50..100).rand.Int !! 50) xx 2;
camelia (50 50)
Xliff m: my $a = Bool.pick; say ($a ?? (50..100).rand.Int !! 50) xx 2;
camelia (50 50)
Xliff m: my $a = Bool.pick; say ($a ?? (50..100).rand.Int !! 50) xx 2;
camelia (71 53)
Xliff m: my $a = Bool.pick; say |(($a ?? (50..100).rand.Int !! 50) xx 2);
camelia 5050
Xliff m: my $a = Bool.pick; say |(($a ?? (50..100).eager.rand.Int !! 50) xx 2); 04:36
camelia 5050
Xliff m: my $a = Bool.pick; say |(($a ?? (50..100).eager.rand.Int !! 50) xx 2);
camelia 836
Xliff m: my $a = Bool.pick; say |(($a ?? (50..100).eager.rand.Int !! 50) xx 2);
camelia 4338
Xliff m: my $a = Bool.pick; say |(($a ?? (50...100).rand.Int !! 50) xx 2); 04:36
camelia 2230
Xliff m: my $a = Bool.pick; say |(($a ?? (50...100).pick.Int !! 50) xx 2); 04:36
camelia 5475
Xliff m: my $a = Bool.pick; say |(($a ?? (50...100).pick.Int !! 50) xx 2);
camelia 7396
Xliff m: my $a = Bool.pick; say |(($a ?? (50...100).pick.Int !! 50) xx 2);
camelia 5050
Xliff m: my $a = Bool.pick; say |(($a ?? (50...100).pick.Int !! 50) xx 2);
camelia 5671
Xliff m: my $a = Bool.pick; say |(($a ?? ((50...100).pick.Int) !! 50) xx 2); 04:37
camelia 5050
Xliff m: my $a = Bool.pick; say |(($a ?? ((50...100).pick.Int) !! 50) xx 2);
camelia 5050
Xliff m: my $a = Bool.pick; say |(($a ?? ((50...100).pick.Int) !! 50) xx 2);
camelia 5050
Xliff m: my $a = Bool.pick; say |(($a ?? ((50...100).pick.Int) !! 50) xx 2);
camelia 7065
Xliff m: my $a = Bool.pick; say |(($a ?? ((50...100).pick.Int) !! 50) xx 2);
camelia 9069
Xliff m: my $a = Bool.pick; my $r = (50...100).pick.Int; say |(($a ?? $r !! 50) xx 2);
camelia 9191
Xliff m: my $a = Bool.pick; my $r = (50...100).pick.Int; say |(($a ?? $r !! 50) xx 2);
camelia 6969
Xliff m: my $a = Bool.pick; my $r = (50...100).pick.Int; say |($a ?? $r !! 50 xx 2); 04:44
camelia 95
Xliff m: my $a = Bool.pick; my $r = (50...100).pick.Int; say |($a ?? $r !! 50) xx 2);
camelia 5===SORRY!5=== Error while compiling <tmp>
Unexpected closing bracket
at <tmp>:1
------> 0300).pick.Int; say |($a ?? $r !! 50) xx 27⏏5);
Xliff m: my $a = Bool.pick; my $r = (50...100).pick.Int; say |($a ?? $r !! 50) xx 2;
camelia (50 50)
Xliff m: my $a = Bool.pick; my $r = (50...100).pick.Int; say |($a ?? $r !! 50) xx 2;
camelia (76 76)
Xliff m: my $a = Bool.pick; my $r = (50...100).pick.Int; say |($a ?? $r !! 50) xx 2; 04:44
camelia (50 50)
Xliff m: my $a = Bool.pick; say |($a ?? (50...100).pick.Int !! 50) xx 2; 04:45
camelia (70 53)
Xliff m: my $a = Bool.pick; say |($a ?? (50...100).pick.Int !! 50) xx 2;
camelia (50 50)
Xliff m: my $a = Bool.pick; say |($a ?? (50...100).pick.Int !! 50) xx 2;
camelia (68 98)
Xliff m: my $a = Bool.pick; say |($a ?? (50...100).pick.Int !! 50) xx 2;
camelia (50 50)
Xliff m: my $a = Bool.pick; say |($a ?? (50...100).pick.Int !! 50) xx 2;
camelia (50 50)
Xliff m: my $a = Bool.pick; say |($a ?? (50...100).pick.Int !! 50) xx 2;
camelia (50 50)
Xliff m: my $a = Bool.pick; say |($a ?? (50...100).pick.Int !! 50) xx 2;
camelia (93 69)
Xliff m: class A does Positional { method AT-POS(\c) { say c }; }; A.new[0] 06:28
camelia 0
Xliff m: class A does Positional { method AT-POS(\c) { say c }; }; A.new[2]
camelia 2
Xliff m: class A does Positional { has $.p1; has $.p2; has $.p3; method AT-POS(\c) { self."p{c - 1}"() }; }; A.new[2] 06:29
camelia ( no output )
Xliff m: class A does Positional { has $.p1; has $.p2; has $.p3; method AT-POS(\c) { self."p{c}"() }; }; A.new(p2 => 43)[2] 06:30
camelia ( no output )
Xliff m: class A does Positional { has $.p1; has $.p2; has $.p3; method AT-POS(\c) { self."p{c}"() }; }; A.new(p2 => 43)[2].say
camelia 43
Elronnd trying to grok grammars 07:42
I made this one sprunge.us/tllL70 for a simple language with function calls, but when I run it with print("hello world"), it hangs indefinitely 07:43
what'd I do wrong?
ahh, I figured out one problem; number and function-call need to have +, not * 07:45
that fixes parsing for 5 and print(5), but strings still don't work
moritz Elronnd: endless hangs are always nested quantifiers that don't consume any characters 07:46
so the equivalent of (a*)*
Elronnd yah
I got rid of the endless hangs
now I just get nil parses
moritz token string { '"' .* '"' }
at least use .*? instead of .* 07:47
otherwise it will parse "a", "b" as one big string
better use '"' <-["]>* '"'
Elronnd ahhh ok
actually how do I parse string escapes properly? 07:48
like "abc\"def"
moritz [ <-["\\]>+ | \\ . ]*
Elronnd I'll take your word for it :P
moritz its something "normal" on the LHS (so neither a " nor a \) 07:49
or any escaped character on the RHS
moritz elaborated more in www.apress.com/us/book/9781484232279 :D 07:49
Elronnd that's expensive tho 07:51
hmmm, I seem to have a parse problem if I have two types of expressions hugging each other. Like print(5, "a", 5) 07:52
is there a good way to debug nil parses? Some way I can ask it to tell me where it tripped up?
fixed that problem 07:55
lizmat clckbaits p6weekly.wordpress.com/2019/06/03/...e-a-given/ 08:15
daxim news.ycombinator.com/item?id=20076781 I understand reini better than before, this post made me realise a recurring pattern, that the fundamental problem perhaps is that in the pursuit of the perfect programming language he's setting up a yardstick that's no one can satisfy, not even himself. if it's not perfect, then it's bad. evidence: presented about pony-lang less than two years ago, but 08:39
meanwhile already abandoned.
lizmat afk for a bit& 08:51
patrickb moritz: Are these perlgeek.de/static/p6/rakudo/ the full set of rakudo releases? 09:24
moritz patrickb: everything that was on the old www server 09:29
pmurias daxim: I would guess he is looking for a super solid implementation of a less perfect language rather then a less satisfactory one of a perfect one 10:57
Xliff \o 10:58
pmurias o/
Xliff camelia doesn't have DateTime::Parse installed?
Xliff Does anyone know where the specs for META6.json are? 11:26
Also... wanted to note that perl6 performance on VMs has degraded between April and now. 11:27
tyil Xliff: docs.perl6.org has the "spec" of what zef says is valid for a META6.json 13:37
Xliff: docs.perl6.org/language/modules#in...META6.json 13:38
Xliff tyil: Thanks! 13:45
pmurias Is something like this clear enough: github.com/pmurias/rakudo-tutorial (I'll expand the tutorial to show how to do more stuff later on) 13:50
msiism just started reading the perl 6 docs (new to perl). the introduction says that rakudo is "a compiler for Perl 6". why is it called a compiler? i would have thought of it as an interpreter because you don't compile a binary from a perl script before you run it. 13:54
pmurias msiism: because it compiler Perl 6 to an intermediate form before running it 13:55
msiism: rakudo can compile Perl 6 to moarvm bytecode or *experimentally* to jvm bytecode or JavaScript 13:56
msiism ok, i don't really understand that. bytecode means that rakudo transfroms the perl code into something the computer can really work with before it's run, doesn't it? 13:58
jnthn It transforms it into a form that a runtime (virtual machine) can run; it just also happens to be able to do all of that in-memory rather than having to write bytecdoe to disk for the VM to load afterwards. 14:00
msiism btw, the link to the rakudo website in the linux install section results in a 404 (perl6intro.com/#_installing_perl_6).
jnthn: ok, i see. 14:01
but would it be wrong to call it an interpreter?
jnthn Well, the whole compiler/interpreter distinction is pretty blurred these days anyway. For example, MoarVM starts off by interpreting bytecode, then JIT-compiles hot things into machine code, but if the code hits a rarely taken path it falls back to the interpreter to handle that bit, etc. 14:03
Same for most modern runtimes, I guess :)
Rakudo itself doesn't contain anything to actually execute code, though; it really is turning Perl 6 into something else that can then be either interpreted or JIT-compiled.
msiism ok, i need to read up on that again. i had read things about that in the wikipedia article a while back but was pretty confused by all that. 14:04
alexghacker I'm working on a class with private attributes (e.g. "has @!cells") and am having trouble getting it to .clone properly. The same code works fine if the attribute is public (i.e. "has @.cells"), so this is confusing and I'm not sure what I'm doing wrong. 14:15
perlpunks.de/paste/show/5cf67c7a.250d.308
this is a distilled example 14:16
timotimo clone doesn't do private attributes at all
alexghacker ah
that would be my problem.
alexghacker so how does one make a class with private attributes cloneable? or is that something that's just not possible? 14:17
pmurias timotimo: why doesn't it?
alexghacker My example does verify that .clone is making a shallow copy of the private attributes 14:18
timotimo oh, it does clone private attributes?
i think clone's tweaks hash doesn't go into private attributes 14:19
alexghacker which makes sense 14:20
timotimo you may have to `my $thecopy = callsame; $thecopy!cells = @!cells.deepmap... }
alexghacker Yes, that should work. 14:21
or not 14:25
No such private method '!cells' for invocant of type 'FooPrivate' 14:26
------> od clone { my $clone = samewith; $clone!⏏cells = @!cells.deepmap(-> $c is copy {
timotimo oops
i think the thing with clone and the tweaks hash is that private attributes are meant to be private, while putting the name of some private attribute into clone as an argument is the opposite of private
alexghacker yes, I understand that philosophical problem 14:27
timotimo can put a private method in there that updates @!cells from a given array 14:27
uzl weekly: uzluisf.gitlab.io/posts/2019/raku-attributes/ 15:11
notable6 uzl, Noted!
cpan-p6 New module released to CPAN! Ranker (0.0.2) by 03UZLUISF 15:16
ugexe why are you demonstrating BUILD instead of TWEAK? 15:27
it also reads a bit weird to claim attributes are private by default. there is no default, you must be explicit 15:29
although i guess that is how you look at it
Altreus > Note that there is no Roman numeral for zero and the largest possible Roman numeral with the above rules is 3,999. 16:03
what part of the rules limits it to 3,999? :\
I thought it had some character limit but there isn't 16:04
[Coke] anyone have a sample for how to wrap an or create one from scratch? Want to modify the stdin sent to a process without having to invoke another external process to do so. 16:37
*an IO::Handle
... Oh, it's in the docs, you say? *facepalm*
[Coke] ok, what I want is to be able to do a .lines over a file and turn that into an IO::Handle or a Proc::Async::Pipe that I can feed to bind-stdin, that looks different than the example. 16:46
m: say .log10 for 10 X** 1..4 16:50
camelia 1
2
2.9999999999999996
4
[Coke] m: say .log10 for 10 X** 1..10 # huh, it's multiples of 3. 16:51
camelia 1
2
2.9999999999999996
4
5
5.999999999999999
7
8
8.999999999999998
10
[Coke] wonders if he's returned at a weird time, or if freenode is now a wasteland. 16:51
El_Che [Coke]: it feels emptier 16:52
tobs m: sub lcfirst ($_) { S[^\w] = $/.lc }; say lcfirst "HELLO" # Xliff, timotimo (backlogging) 16:53
camelia hELLO
tobs if I ever made a list of fanciest p6 syntaxes, substitution-assignment would rank pretty high 16:54
holyghost hi 16:55
Xliff, did you see my PaganVisions2 mail ? 16:57
ugexe m: 42 R= my $a; say $a; # the fanciest syntax 17:50
camelia 42
ugexe [Coke]: i'm not sure that is possible. bind-stdin requires something with a native descriptor, not just something that is IO::Handle 17:53
i suppose you could could just write data some some file, then pass the process the handle to *that* file (which can still be written to) 17:57
uzl Hi, ugexe! The only reason why I used BUILD instead of TWEAK was because it's the submethod that bless calls, although I'm not sure if that's reason enough ;-) 18:02
uzl You says that it's a bit weird to claim attributes are private by default. Any idea on how could it be phrased better? 18:04
My mental image of $. is that it's just a shortcut for $! and an accessor. Thus declaring everything with $! would mean they couldn't be accessed w/o from outside the class. 18:08
alexghacker timotimo: I was almost defeated, even with your advice, until I used .WHAT on @!cells/@.cells to notice that, unless they were overridden with the tweaks, after each object was bound to the same array. So what looks like is necessary is to update the binding using := in the private method. 18:10
perlpunks.de/paste/show/5cf6b368.6bbb.2ff 18:11
timotimo you mean .WHERE? 18:12
alexghacker errr
No, I meant .WHICH
actually
timotimo m: say [1, 2, 3].WHICH; say [1, 2, 3].WHICH
camelia Array|73982616
Array|74695744
timotimo right
i was actually just about to go AFK
alexghacker thanks for the pointer to the right direction 18:13
timotimo glad i could help 18:14
ugexe thats why i said it depends on how you look at it. you could say $! just doesn't create accessors instead of $. creates accessors. 18:15
uzl
ugexe but yeah i dont have strong feelings either way. just noting it felt weird reading it 18:17
[Coke] ugexe: I'm not sure the native descriptor part was clear in the docs. 18:18
uzl ugexe: I see. I guess I look at it going starting from a barebone situation (so to speak) and then adding stuff to it.
[Coke] hurls docs.perl6.org/type/Proc::Async#me...bind-stdin - if you could add some color there, that'd be great. 18:19
(and thanks for the tip)
ugexe m: IO::Handle.new.open 18:21
camelia IO::Handle is disallowed in restricted setting
in sub restricted at src/RESTRICTED.setting line 2
in method new at src/RESTRICTED.setting line 23
in block <unit> at <tmp> line 1
ugexe "Invocant of method 'd' must be an object instance of type 'IO::Path', not a type object of type 'IO::Path'. Did you forget a '.new'?" 18:22
uzl BTW, what did you strike as odd with the usage of BUILD vs TWEAK? Admittedly I get confused oftentimes when deciding to use BUILD or TWEAK.
* strike you
ugexe i believe we encourage the use of TWEAK because it has the behavior most people expect
"This means that BUILD may change an attribute, but it does not have access to the contents of the attribute declared as its default; these are available only during TWEAK (see below), which can 'see' the contents of an attribute initialized in the declaration of the class." 18:24
uzl Fair enough. I'll change it ;-)! 18:25
ugexe m: class Foo { has $.attr; submethod BUILD($!attr = $!attr * 2) { } }; say Foo.new(attr => 1).attr 18:26
camelia Use of uninitialized value of type Any in numeric context
0
in code at <tmp> line 1
ugexe m: class Foo { has $.attr; submethod TWEAK($!attr = $!attr * 2) { } }; say Foo.new(attr => 1).attr
camelia 2
uzl Oh, great. Thanks! 18:27
ugexe [Coke]: I'm not sure how someone would document that. I'm not sure we have anything for working with actual file descriptors other than .native-descriptor for accessing it *if* it exists 18:30
Something backed by a file descriptor -- ok but what does "file descriptor" mean in the context of perl6? 18:31
[Coke] I'm asking because we setup p6doc's test to use awk (originally, now p5) to send input to aspell.. and I want to just use the p6 I'm in to generate that output on the fly. Guess I could save it out to a file and 'cat' it if I'm desperate to remove the p5 dep. 18:39
ugexe yeah it'd be nice if there was a way to get like a file descriptor for some sort of in-memory abstraction 19:07
ugexe i guess thats sort of what a socket is 19:07
sockets have descriptors, but a socket is not an IO::Handle (just close to it) so that doesn't help with bind-stdin 19:08
timotimo you mean like memfd? 19:10
ugexe yeah, except portable 19:12
skids m: class sayer { has $.accum is rw = ""; method print (*@s) { $.accum ~= [~] @s } }; my sayer $s .= new(); { temp $*OUT = $s; say "hello world"; say "Not really saying this yet" }; print $s.accum.uc 19:22
camelia HELLO WORLD
NOT REALLY SAYING THIS YET
ugexe well, yes, but that doesn't work with anything expecting a low level file descriptor like Proc.bind-stdin 19:23
skids Ah, I see. IO::Pipe not "portable" enough? 19:26
ugexe the issue is getting a native file descriptor to represent some perl6 data that doesn't otherwise have a file descriptor 19:30
so you could create some IO::Pipe, but without a file descriptor it doesn't matter for e.g. .bind-stdin
skids Right so why not open a pipe and supply it with that perl6 data?
And use that fd? 19:31
timotimo pushing data into pipes could block, maybe?
and you'd be copying that data around, perhaps unnecessarily
though i'm not sure moar will just allow you to get the address-in-memory of a VMArray's blob for example
ugexe i dont think you get a file descriptor from doing IO::Pipe.new(...)
i imagine its given/set a file descriptor at some point 19:32
skids If you're piping data to a process via .bins-stdin, you're copying it.
ugexe github.com/rakudo/rakudo/blob/45bb...#L231-L239 19:33
skids The only way not to is if the receiving process knows how to set up a SYSV shm or other mmap. Which I'm guessing aspell doesn't :-)
ugexe run("cat", :in("foo.pdf".IO.open)) would only copy once, instead of via an intermediary 19:39
timotimo passing a memfd also means that the other process can seek, and you can change the contents while the other program is running 19:44
skids (point taken about seeking). But, barring programs that seek, if you're modifying, you necessarily have an intermediary process doing the modifying and the data on either side of that is potentially different so... I don't get what you are trying to do... 19:52
ugexe and if you're not modifying it? 19:54
ugexe essentially what is asked is a generic source with a file descriptor that can work with any sink that uses a file descriptor 19:55
so yeah you can just write to a file while some other process reads from it, but thats not exactly ideal 19:56
skids If you're not modifying it... and it's data in your Perl6 process, then it's either A) for the 90+% of consumers that don't seek, a matter of opening a pipe fd and setting up some async to push the data to it or B) using unportable mmap/memfd features or an abstraction library (which necessarily loses some features) and putting your output into a Buf you allocate via NativeCall (thus assuming the responsibility of managing the memory) 20:48
Xliff m: DateTime.now(timezone => 'utc') 20:49
camelia Cannot convert string to number: base-10 number must begin with valid digits or '.' in '3⏏5utc' (indicated by ⏏)
in block <unit> at <tmp> line 1
Xliff Oh! It's already in UTC! /o\ 20:50
ugexe how do you open a pipe fd in perl6 without spawning another process? 21:10
because that is exactly what is otherwise being asked for (its just not possible afaik)
ugexe IO::Pipe.new(...) doesn't just create a fd though 21:11
like i said, someone could just create a temp file and write data to it while reading it from elsewhere. but there is a lot of boilerplate that needs to be carefully considered in even just setting up a temp file to accomplish this. why can't this behavior be abstracted further? 21:12
Xliff m: my ($a, $b) = "?hello".split('?'); say $a.defined; say $a.chars; 22:05
camelia True
0
Xliff m: DateTime.now.say 22:56
camelia 2019-06-05T00:56:59.481714+02:00
Xliff m: DateTime.now(timezone => 0).say 22:57
camelia 2019-06-04T22:57:28.466629Z
Xliff m: chr(0xC7).say 23:41
camelia Ç