»ö« 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.
ToddAndMargo Hi All, I am confused over "defined". `$ p6 'my Real $x; if $x.defined {say "Defined"}else{say "Undefined"};'` Undefined Didn't I just define it with `my Real`? 00:41
timotimo it's holding an undefined value, which is what was sometimes called "null" or "a nil" on the mailing list 00:42
m: my Real $x; dd $x 00:43
camelia Real $x = Real
timotimo m: my Real $x; say $x
camelia (Real)
timotimo m: my Real $x; print $x
camelia Use of uninitialized value of type Real in string context.
Methods .^name, .perl, .gist, or .say can be used to stringify it to something meaningful.
in block <unit> at <tmp> line 1
timotimo there you can see "uninitialized value"
i'm going to bed right now, but i hope that helped a little already
maybe the important bit is that .defined works on values, not on variables 00:44
in fact, you can't even "talk" about a variable that wasn't declared with a "my" or something similar
m: say $doesnotexist.defined
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable '$doesnotexist' is not declared
at <tmp>:1
------> 3say 7⏏5$doesnotexist.defined
timotimo it's already a syntax error
on top of that, you can ask literal values if they are defined
m: say 1.defined; say "".defined; say Str.defined; say Nil.defined 00:45
camelia True
True
False
False
timotimo good night!
ToddAndMargo Oh man!
Thank you
rocket_fly Hello 01:43
Perl6 does not support 'use warnings'... does anyone know why?
MasterDuke rocket_fly: it's on by default. docs.perl6.org/language/5to6-nutshell#warnings 01:47
rocket_fly O, thanks. I got it 01:49
if $name (elem) @names : this syntax seems really cool! Anyone know its academic name? 01:51
lucs To declare a type synonym, for example to have a Name be like a Str, I can do 「subset Name of Str;」 02:42
Is that the idiomatic way? 02:43
[Coke] m: subset Name of Str; my Name $a = "Guillermo"; say $a; say $a.^name; 02:46
camelia Guillermo
Str
[Coke] Aye.
m: subset Name of Str; my Name $a = "Guillermo"; say $a; say $a.^name; say $a.VAR.of; 02:47
camelia Guillermo
Str
(Name)
Geth doc: 79ab0d7929 | Coke++ | doc/Language/101-basics.pod6
whitespace
synopsebot Link: doc.perl6.org/language/101-basics
labster m: say Real.new() 03:13
camelia MoarVM panic: Memory allocation failed; could not allocate 122576 bytes
labster I've also seen SIGSEGV and SIGBUS 03:13
m: say Real.new() 03:14
camelia (signal SEGV)
labster rakudobug filed ^ 03:28
labster Man, this is fun, I haven't found a segfault in MoarVM in like 5 years! 03:39
Geth doc: 70a123af53 | (JJ Merelo)++ | 3 files
Improving presence of escape characters in the documentation

Suggestion for a new section has not been considered, since escape characters are standard and they behave in the standard way. However, some indexing and a list of all escape characters has been added. This closes #2313.
05:19
Geth doc: 0888dcc54f | (JJ Merelo)++ | doc/Language/objects.pod6
Re-indexing of new as new (method)

I couldn't think of a better way to address #2309. Generated pages don't have an intro, and adding one by hacking the generator would be a slippery slope. Order can probably be changed, but once again, this is not going to satisfy everyone; if it's hacked, same problem as above. If we want to define an order for generated routine pages, this ... (11 more lines)
06:24
synopsebot Link: doc.perl6.org/language/objects
lizmat weekly: domm.plix.at/perl/2018_09_ctrl_alt_del_yef.html 07:55
notable6 lizmat, Noted!
rindolf lizmat: hi 08:22
lizmat: sup?
lizmat almost awake
rindolf lizmat: ah 08:23
sarna hey, how can I split an array into smaller ones? ie <1 2 3 4 5 6>foo(3) -> [[1,2,3],[4,5,6]] 09:38
forgot a period :(
found it! it's called batch :^) 09:40
TisonKun sure, it is a wrapper of rotor 09:46
m: <1 2 3 4 5 6>.rotor: 3
camelia ( no output )
TisonKun m: say <1 2 3 4 5 6>.rotor: 3
camelia ((1 2 3) (4 5 6))
TisonKun blogs.perl.org/users/zoffix_znet/20...ation.html 09:47
but I wonder if there is a partition such as LIST.partition(COND) like <1 2 3>.partition: * > 1 # => ((2, 3), (1,))
sarna thanks TisonKun 09:52
buggable New CPAN upload: Array-Agnostic-0.0.3.tar.gz by ELIZABETH modules.perl6.org/dist/Array::Agnos...:ELIZABETH 09:54
jnthn TisonKun: See categorize and classify 09:57
ZzZombo TisonKun: try `classify` or the related method. 10:03
TisonKun say <1 2 3 4 5 6>.classify: * > 3 10:04
evalable6 {False => [1 2 3], True => [4 5 6]}
TisonKun powerful ^_^, thanks jnthn ZzZombo 10:05
sarna is there something like .map but eager? 10:19
I know there's a good old for loop but
TisonKun ask for the value would eagerly do it, I think 10:20
jnthn Just call .eager on the result of map 10:21
Though if it's in sink (void) context it'll be eagerly evaluated anyway
In fact, in that case it just discards the results, so it's better than eager, which would have to remember them
sarna oh! 10:23
TisonKun forget our .eager XD 10:25
sarna I love these p6 niceties 10:26
TisonKun agree. part of the passion and fun of play p6 is that when you get gradually familiar with it, things become awesome and works become elegant. 10:28
sarna :D 10:30
sarna what if I want to split a list into x smaller lists? 10:36
sarna is there an elegant solution to that? I doubt it, but it's p6 after all 10:37
lizmat sarna: batch by .elems / x ?
sarna lizmat: I have "trailing" elements because it doesn't divide evenly 10:40
lizmat (.end / x ) + 1 10:41
sarna well yeah, but then the last group is like 2 elements, while the others are 5+ 10:42
lizmat well, that's not a programming issue, but a logic issue :-) 10:43
sarna :D fair enough
lizmat of mathematical I guess
buggable New CPAN upload: Array-Sparse-0.0.2.tar.gz by ELIZABETH modules.perl6.org/dist/Array::Spars...:ELIZABETH 10:44
sarna m: say (0..1).pick; 11:05
camelia 1
sarna m: say 0..1.pick; 11:06
camelia 0..1
sarna why is the second one like this?
sena_kun precedence 11:07
second one is, in reality, 0..(1.pick), which is `0..1`.
sarna, docs.perl6.org/language/traps#Rang...precedence 11:08
sarna oh! thanks sena_kun 11:09
sena_kun np 11:10
lizmat m: say 0..1 .pick # another way to get around this precedence issue
camelia 0..1
lizmat huh?
guess not
m: say for 0..1 .pick 11:11
camelia 5===SORRY!5=== Error while compiling <tmp>
Unsupported use of bare "say"; in Perl 6 please use .say if you meant to call it as a method on $_, or use an explicit invocant or argument, or use &say to refer to the function as a noun
at <tmp>:1…
lizmat m: .say for 0..1 .pick
camelia 0
1
lizmat ok, forget about that :-) 11:11
albertferrico good afternoon everyone 11:21
sarna o/ 11:23
lizmat: haha, ok
araraloren o| 11:37
buggable New CPAN upload: Array-Agnostic-0.0.4.tar.gz by ELIZABETH modules.perl6.org/dist/Array::Agnos...:ELIZABETH 11:54
buggable New CPAN upload: Array-Sparse-0.0.3.tar.gz by ELIZABETH modules.perl6.org/dist/Array::Spars...:ELIZABETH 12:24
TisonKun it might be naughty 0..1 .pick different from 0..1.pick 13:04
TisonKun people always think whitespace is no significant :-) 13:04
timotimo there are multiple cases in perl6 where whitespace actually is significant 13:07
m: sub if($a) { say "this is if" }; if(1)
camelia this is if
timotimo m: sub if($a) { say "this is if" }; if (1)
camelia 5===SORRY!5=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> 3sub if($a) { say "this is if" }; if (1)7⏏5<EOL>
expecting any of:
block or pointy block
sena_kun m: my regex escaped { '\"' }; say '"foo\"bar"' ~~ / '"' (<escaped> | <-["]>)+ '"' / 13:16
camelia 「"foo\"bar"」
0 => 「f」
0 => 「o」
0 => 「o」
0 => 「\"」
escaped => 「\"」
0 => 「b」
0 => 「a」
0 => 「r」
sena_kun is there a better approach if I want to get a line in double quotes but with `\"` escaping? 13:16
m: my regex escaped { '\"' }; say '"foo\"bar"' ~~ / '"' [<escaped> | <-["]>]+ '"' / 13:18
camelia 「"foo\"bar"」
escaped => 「\"」
TisonKun m: "foo\"bar".perl 13:25
camelia ( no output )
TisonKun m: say "foo\"bar".perl
camelia "foo\"bar"
sena_kun oh, sorry, I meant "match it from raw text as a valid single line" instead of abstract "get" I've used. 13:26
TisonKun say '"foo\"bar"' ~~ / \".*\" / 13:29
evalable6 「"foo\"bar"」
sena_kun m: say '"foo"bar"' ~~ / \".*\" / 13:31
camelia 「"foo"bar"」
sena_kun no escaping. :S
TisonKun is there a true negative example to make topic clearly? 13:32
TisonKun '"foo"bar"' ~~ REGEX should give "foo\"bar" ? 13:33
sena_kun give me a second... 13:33
jnthn See JSON::Tiny
And how it matches strings with escapes
sena_kun oh!
jnthn And do something like that :)
sena_kun stops to abuse irc 13:33
TisonKun jnthn you know the background :) 13:34
sena_kun TisonKun, just ignore me next time. :)
araraloren It's fine, sometime we may don't understand the question 13:35
samcv i'm having an issue catching an exception 14:01
here it is throwing gist.github.com/samcv/0a76f1d5b2ef...e1-txt-L13 but the try block doesn't seem to allow the script to keep running 14:02
Roamer` samcv, are you sure that it's the .slurp that is throwing the exception and not the open itself? If it's open, then in the CATCH block $fh is not a file, but a Failure, and you can't really call $fh.close or even $fh.opened 14:09
samcv Roamer`: yeah i am 14:12
samcv i tried lives-ok instead now, and that seems to work 14:12
though i woud like to know what's going on that is making the try not work
samcv Roamer`: this works gist.github.com/fdab5d5b1d0a11ccd5...fc529337de 14:13
Zoffix samcv: what's the exception that isn't being caught? 14:13
Zoffix Roamer`: `try` fatalizes Failures 14:15
(or more precisely: it enables `use fatal` pragma, but you can turn it off if you want)
samcv: you're missing the `default` branch in your CATCH
So the exeption keeps on trucking 14:16
samcv ah ok
Zoffix samcv: also parse-names is deprecated. It's called uninames now 14:17
kensanata I want to write code where the user can pick a storage backend using an environment variable. My idea: all the modules use a Storage module; this is an object which as a private attribute with value Storage::File handling get-page and put-page. What's the idiomatic way of doing this? I found design.perl6.org/S12.html#Delegation but that doesn't seem to work. 14:31
Where "doesn't work" means "perl6 -Ilib -c lib/Storage.pm6" gives me an error at the "handles" keyword. 14:32
[Coke] those design docs are not current. 14:36
docs.perl6.org/routine/handles is more likely to work. 14:37
kensanata Yeah, I saw the note at the top.
Yeah, this looks good. Will give it a try! 14:38
robertle unlink() on IO::Path apparently only came in around 2014.10, does anyone know whether there was a good way to delete a file before that? 14:45
moritz robertle: unlink as a function, with a string argument? 14:51
[Coke] that's already before christmas. 14:52
robertle moritz: thanks, I did not know that existed! 14:59
kensanata Is there a way to specify a class using a string? Something to put around the environment variable in here: class A {method m(){say "m"}}; class C {has $.delegate handles <m> = %*ENV<STORAGE>.new()}; C.new.m; 15:03
Or a better way to do this, of course.
robertle kensanata: I ahve done stuff like "require ::($module-name)" 15:05
[Coke] m: my $a = "Int"; ::($a).new.^name.say 15:06
camelia Int
kensanata Thanks! 15:07
pmurias does it make sense to call the rakudo.js executable the npm package will install something other than perl6-js? 15:09
consistency and calling the perl6-js seems like the sanest option but know is the time to make the choice ;) 15:10
Geth doc: 1be2f24de8 | (Will "Coke" Coleda)++ | doc/Language/objects.pod6
whitespace
15:17
synopsebot Link: doc.perl6.org/language/objects
[Coke] lizmat: some docs test failures: A few things like "method STORE (::?CLASS:D: values, :$initialize)" where values isn't defined 15:19
$ xt/examples-compilation.t doc/Type/Positional.pod6 doc/Language/subscripts.pod6 doc/Type/Associative.pod6 # this shows the current errors
tyil what would be a nice solution to change a single character in a string at a given position? 16:32
tobs tyil: there's substr-rw (but I don't think it looks too nice) 16:38
m: ($_ = "tyil").substr-rw(1,1) = pick 1, 'a'..'z' and .say
camelia tuil
tyil not bad at all 16:46
my solution was heading into an s/// regex 16:47
Zoffix .tell [Coke] FYI the "grant ideas" is 404 link on this page: news.perlfoundation.org/2018/09/cal...pte-2.html might be this page is what it's meant to be: www.perlfoundation.org/grant-ideas.html 16:53
yoleaux Zoffix: I'll pass your message to [Coke].
Zoffix m: say "--------------------".subst: /.**12 <( ./, "Z"
camelia ------------Z-------
tyil hmm, this is less neat, if I put `substr-rw($string, $position, 1) = $character` as the sub body, its return value is $character, not the updated string 16:55
timotimo yeah, that's the return value of assignment
ofperfection[m] Not sure if this is what you're looking to do 16:56
timotimo otherwise you wouldn't be able to do something like substr-rw($string, $position, 1) .= uc for example
tyil I am sure I'm looking to replace a character at a given position :p
timotimo: ah, that makes sense 16:57
timotimo m: "foobarbaz".comb.splice(3,1,"X").join.say
camelia Cannot resolve caller splice(Seq, Int, Int, Str); Routine does not have any candidates. Is only the proto defined?
in block <unit> at <tmp> line 1
timotimo m: "foobarbaz".comb.list.splice(3,1,"X").join.say
camelia Cannot resolve caller splice(List, Int, Int, Str); Routine does not have any candidates. Is only the proto defined?
in block <unit> at <tmp> line 1
timotimo m: "foobarbaz".comb.Array.splice(3,1,"X").join.say
camelia b
ofperfection[m] my $string = "banana"; my@seq = $string.comb; @seq[0] = "z"; say @seq [z a n a n a]
timotimo ah, that also returns the parts cut out
ofperfection[m] you could encapsulate that in a subroutine and run it against $_ 16:58
unless I'm wrong, since I'm a big 'ol noob
timotimo i've wanted an operator for a while that signifies a return value for the outer parenthesis or something 16:59
m: my $stash; sub store($a) { $stash = $a; $a }; sub recall($a) { $stash }; "foobarbaz".comb.Array.&store.splice(3,1,"X").&recall.join.say 17:00
camelia fooXarbaz
timotimo hmm 17:01
m: sub store($a, $b is rw) { $b = $a; $a }; sub recall($a, $b) { $b }; "foobarbaz".comb.Array.&store(my $x).splice(3,1,"X").&recall($x).join.say
camelia fooXarbaz
timotimo cool.
a little postcircumfix operator would be neat for that 17:04
m: sub postcircumfix:<⎡ ⎤>($a, $b is rw) { $b = $a; $a }; sub postcircumfix:<⎣ ⎦>($a, $b) { $b }; "foobarbaz".comb.Array⎡my $x⎤.splice(3,1,"X")⎣$x⎦.join.say 17:06
camelia fooXarbaz
timotimo that's not even half bad
i wish i could omit the "my", but that'd require a full-on slang
or perhaps actually a macro as we currently have it would do?! 17:07
masakro?
aha, i've got one better 17:08
m: sub postcircumfix:<⦑ ⦒>($a, &code) { $b = $a; code($a); $b }; "foobarbaz".comb.Array⦑*.splice(3,1,"X")⦒.join.say 17:09
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable '$b' is not declared
at <tmp>:1
------> 3sub postcircumfix:<⦑ ⦒>($a, &code) { 7⏏5$b = $a; code($a); $b }; "foobarbaz".com
timotimo m: sub postcircumfix:<⦑ ⦒>($a, &code) { my $b = $a; code($a); $b }; "foobarbaz".comb.Array⦑*.splice(3,1,"X")⦒.join.say 17:10
camelia fooXarbaz
timotimo hell yeah
ofperfection[m], tyil, how do you like this? 17:11
timotimo i wonder why i didn't think of this the last time i wanted this 17:13
ofperfection[m] How do i like what? 17:14
tobs that single operator form is indeed cool 17:15
ofperfection[m] The last solutoin?
sub postcircumfix i mean
timotimo yeah 17:19
i'm a little proud of it
ofperfection[m] I always enjoy learning new things in solutions, I'm reading up on circumfixes
tobs I have a multi sub f($x) that supports multiple algorithms. Is `multi sub f($x, :$algo1 where *.so)` the most declarative way to write the signature? I tried `:$algo1!` first but that is, of course, eligible for f($x, :!algo1) 17:22
it's the tiniest of issues but I thought I ask anyway
timotimo m: multi sub one($a, :flag!) { say "flag is set" }; multi sub one($a, :other!) { say "other is set" }; multi sub one($a) { say "fallback" }; one(1, :flag); one(2, :other); one(3) 17:23
camelia 5===SORRY!5=== Error while compiling <tmp>
Malformed parameter
at <tmp>:1
------> 3multi sub one($a, :7⏏5flag!) { say "flag is set" }; multi sub
[Coke] zoffix, even better, *all* those links are dead now after the site refresh. *sigh*
yoleaux 16:53Z <Zoffix> [Coke]: FYI the "grant ideas" is 404 link on this page: news.perlfoundation.org/2018/09/cal...pte-2.html might be this page is what it's meant to be: www.perlfoundation.org/grant-ideas.html
timotimo m: multi sub one($a, :flag(True)!) { say "flag is set" }; multi sub one($a, :other(True)!) { say "other is set" }; multi sub one($a) { say "fallback" }; one(1, :flag); one(2, :other); one(3)
camelia 5===SORRY!5=== Error while compiling <tmp>
Malformed parameter
at <tmp>:1
------> 3multi sub one($a, :flag(7⏏5True)!) { say "flag is set" }; multi sub
timotimo well, not like that, clearly 17:24
timotimo so yeah, it hink the "where *.so" is the right one if you want to allow passing False for that, too 17:24
tobs alright, having written it a few times, it already looks intuitive to me 17:27
[Coke] zoffix, fixed 'em, thanks for catching that 17:29
tobs Signatures have surprisingly many features. I'd buy a small, say apress, book about them if one were being considered to be written :-)
timotimo weekly: twitter.com/loltimo/status/1041746891426463744 17:53
notable6 timotimo, Noted!
timotimo i hope i'm not too late with this :)
ofperfection[m] The comments really helped clarify for me 17:55
timotimo \o/ 17:57
ccc I'd like to go into perl6 REPL and require a file that is not a module (or a unit of any kind)and be able to use it's definitions and bindings. Do these get put into a special namespace? 18:35
tyil timotimo: thats nice (sorry, was afk for a bit) 18:36
timotimo <3 18:37
tyil I like it more than the other solutions I had so far
timotimo if you find a better unicode character, maybe one that's in typical compose files for example, that'd be cool 18:37
i could imagine an up arrow and a down arrow
maybe even an up-right and a down-right arrow
timotimo experts will make it a whole ballistic curve using a comment line above the code that connects both arrows 18:38
ccc The REPL is nice; it's helping me try out of p6 concepts, but I have to type out or paste everything in it. 18:43
buggable New CPAN upload: Image-Libexif-0.0.3.tar.gz by FRITH modules.perl6.org/dist/Image::Libexif:cpan:FRITH 18:44
uzl hi, #perl6! 18:46
m: (Array.^methods.gist).words.grep: 'sum'
camelia ( no output )
uzl m: say (Array.^methods.gist).words.grep: 'sum'
camelia (sum)
ccc m: say CORE::.keys 18:47
camelia (FileChanged Signally &signal &RETURN-LIST &tan Stash &prompt &sin &postfix:<--> &prefix:<not> &atomic-fetch-inc SIGPROF &roots &infix:<+&> 𝑒 &sleep-until Macro &prefix:<so> &infix:<≤> Exception &infix:<~|> &asin &callframe &prefix:<temp> Cursor …
ccc m: say MY::.keys
camelia ($! $=pod $_ $¢ $=finish !UNIT_MARKER GLOBALish EXPORT $?PACKAGE ::?PACKAGE $/)
uzl m: say (Array.^methods.gist).words.grep: 'push'
camelia (push)
uzl Is there a more elegant way to find out if a type has a certain method? I'm struggling to come with something nicer. 18:48
ccc uzl: Do you use the perl6 REPL a lot? 18:49
jnthn m: say ?Array.can('push') 18:50
camelia True
uzl ccc: whenever I'm testing out small code snippets
[Coke] ccc: EVALFILE lets you run a file.
ccc EVALFILE? 18:51
[Coke] but it just runs it, I don't think it'll make those items available at the REPL scope
ccc is that a command or sub?
[Coke] m: EVALFILE "foo.p6"
camelia Failed to open file /home/camelia/foo.p6: No such file or directory
in block <unit> at <tmp> line 1
ccc That's a real bummer because perl-debug-m doesn't work for me 18:52
and to test certain ideas requires a lot of typing before you get to the punch line
it would be nice to have an custom set of definitions pre-loaded into the REPL 18:53
like some option the the perl6 command like --include=startup.p6 that only works in REPL mode that acts like you just typed all that was in startup.p6 18:55
El_Che ccc: you actually want a step by step debugger?
like "perl -d" in perl 5? 18:56
ccc While perl -d was a full, very useful debugger, I used it frequently like a REPL
timotimo ccc: have you tried the jupyter notebook for perl6 yet?
there's a free online one, too 18:57
ccc timotimo: If I did, then I'd have to LEARN it too. Let easy things be easy
Just load the damn file
and if you want to put it in a special namespace fine 18:58
but tell me what that namespace is!
timotimo why are you loading it with "require", if i may ask? 18:59
ccc What I'm loading is NOT a module class role or any other kind of library 19:00
but unadorned, unpacked perl6 code
that I'd rather not have to type all over again (or paste) the next time I'm fiddling with an idea 19:01
uzl timotimo: sorry to interrupt. Any easy way to find out (in the REPL) if a function can be invoked as a function, a method or both?
ccc If the debugger worked for me the I'd use that
timotimo uzl: i think the only requirement for something to be used as a method is that it has to take one positional argument at least 19:02
ccc: to be honest, i'm the opposite of fond of the REPL as it is currently, so i barely ever even use it
ccc Well it's great for people learning the language, although I can't load any initial stuff into it other than by pasting or typing 19:04
timotimo the difference between an unordered piece of perl6 code and a module is putting either "our" in front of subs (to access them with ModuleName::the-sub) or "is export" after the signature
ccc I think it was the perl -d that allowed me to come up to speed on perl6 rather quickly 19:05
ccc tried that 19:05
[Coke] what if there was a way to have a batch of perl 6 code that dumped you into the repl when it was done, would that be better than nothing?
ccc I could use that 19:05
[Coke] asked, not remember if that worked at all. 19:06
timotimo well, you can get at Perl6::Compiler with nqp::getcomp("perl6") at the very least
timotimo m: use Perl6::Compiler 19:06
camelia ===SORRY!===
Could not find Perl6::Compiler at line 1 in:
/home/camelia/.perl6
/home/camelia/rakudo-m-inst-1/share/perl6/site
/home/camelia/rakudo-m-inst-1/share/perl6/vendor
/home/camelia/rakudo-m-inst-1/share/perl6
Co…
timotimo m: use Perl6::Compiler:from<nqp>
camelia ===SORRY!===
Could not find Perl6::Compiler at line 1 in:
/home/camelia/.perl6
/home/camelia/rakudo-m-inst-1/share/perl6/site
/home/camelia/rakudo-m-inst-1/share/perl6/vendor
/home/camelia/rakudo-m-inst-1/share/perl6
Co…
ccc And where does it put the subs and variables it finds there
timotimo m: use Perl6::Compiler:from<NQP>
camelia ( no output )
ccc What namespace are we in inside REPL? 19:07
timotimo eval has options to set a context to use 19:08
but interactive doesn't
ccc If I say to REPL sub foo {say "bar"}
where is it getting put? Into a lexical pad or a package?
[Coke] stackoverflow.com/questions/452904...-from-file
timotimo lexical pad; "sub foo" is lexical
"our sub foo" gets put into the packag
ccc what package?
timotimo the current package 19:09
m: our sub foo() {}; say ::?PACKAGE.perl
camelia GLOBAL
timotimo m: our sub foo() {}; say ::?PACKAGE::.keys
camelia 5===SORRY!5=== Error while compiling <tmp>
Confused
at <tmp>:1
------> 3our sub foo() {}; say ::?PACKAGE:7⏏5:.keys
expecting any of:
colon pair
timotimo m: our sub foo() {}; say ::?PACKAGE.keys
camelia ()
ccc perl6 says $?CURRENT is not declared
timotimo m: our sub foo() {}; say ::?PACKAGE.WHO.keys
camelia (&foo)
timotimo there it is 19:10
ccc ::?PACKAGE.WHO.keys in perl6 says: () ; (after I defined sub foo) 19:11
timotimo did you put "our" before it? 19:12
ccc Is each line in REPL a different lexical scope? 19:12
timotimo yes 19:13
they are stacked into each other
{ line 1; { line 2; { line 3; { line 4; ... } } } }
timotimo the package.who.keys thing works on my machine 19:14
ccc Then how come it runs foo?
timotimo how do you mean?
ccc I define it in REPL on one line then I say foo on another it says bar
timotimo if foo is defined to return "bar", then that matches my expectation? 19:15
ccc It matches my expectation
timotimo then i don't understand the question :) 19:16
ccc It's not found in ::?PACKAGE, so where is it getting it from? 19:16
(And I didn't put an our in front of it either) 19:17
timotimo it gets it from MY:: 19:17
ccc perl6 says No such symbol '::?MY' 19:18
timotimo m: sub foo() {}; say MY::.keys
camelia ($_ EXPORT ::?PACKAGE !UNIT_MARKER $=finish $?PACKAGE $=pod $/ GLOBALish $¢ $! &foo)
timotimo there it is
ccc > MY::.keys
($?PACKAGE GLOBALish $=pod $_ ::?PACKAGE EXPORT !UNIT_MARKER)
timotimo well, yeah
timotimo if you put it on a new line, that's the current line's scope 19:19
ccc No foo there either
timotimo you'll want OUTER:: for the previous line or OUTERS:: for every previous line
ccc > foo
bar
What happened to let easy things be easy?
timotimo the repl is one giant terrible hack 19:20
ccc Why not have SOME way to jus insert a file in place
as if you had typed it
timotimo sounds like a cool first contribution :) 19:20
er, unless of course you already contributed 19:21
in which case i apologize for not knowing about that
ccc Ha! If I know enough about rakudo, I'd consider it.
timotimo let me whip something up 19:21
do you have a local rakudo that you compiled yourself? 19:22
ccc No just downloaded the latest version of rakudo star on Sep 4, 2018 19:22
diakopter double tap 19:23
timotimo in that case it'll be a bit more difficult to apply the patch 19:24
was that a binary release or sources?
ccc As I said here a couple of days ago, I'm working on a pedagogical module for abstract algebra : groupid, semigroups, groups
Calling it Math::Algebra 19:25
s/groupoid/groupid/
timotimo ok, i don't think i can actually write that patch right now 19:26
i need to rest my wrist for a while
ccc Keep getting sidetracked though chasing an idea down some rabbit hole or trying to learn several things at once
ccc (I'm using Atom now for my perl6 project, but my fingers still think in Emacs!) 19:27
ofperfection[m] Yeah I've been using atom specifically for the dearth of perl6 plugins 19:29
ccc I tried doing my Algebra project to help me learn go (the language), but I gave up on it. I also looked at nim
ofperfection[m] once I added vim mode they transition hasn't been to bad
by dearth i mean opposite of dearth
*abundance 19:30
ccc I've been a perl hacker for a couple of decades and was sad when perl6 did not prosper 19:31
But since I downloaded the current rakudo, I've been very impressed with what it can do 19:32
ofperfection[m] Hey Timo, in that snippet you linked on twitter, is that a ligature on the postcircumfix 19:33
Nevermind, found the symbol in the docs 19:34
How does one even type that
diakopter ccc: nobody's come up with a killer app for Perl 6, where it's definitely easier/awesomer to do in Perl 6 than all other [far more widespread] environments, except for of course the application of: Implementing Perl 6
timotimo .u ⦓ ⦔
yoleaux U+0020 SPACE [Zs] ( )
U+2993 LEFT ARC LESS-THAN BRACKET [Ps] (⦓)
U+2994 RIGHT ARC GREATER-THAN BRACKET [Pe] (⦔)
diakopter I like those brackets 19:35
timotimo .u ⦕ ⦖
yoleaux U+0020 SPACE [Zs] ( )
U+2995 DOUBLE LEFT ARC GREATER-THAN BRACKET [Ps] (⦕)
U+2996 DOUBLE RIGHT ARC LESS-THAN BRACKET [Pe] (⦖)
kensanata Do we have something quick and simple like B::hash in Perl 6? 19:36
kensanata Basically what I want is to turn strings like IP numbers into four digit octals and in a Perl 5 app, this is what I used: get 32bit int, turn to octal, take first four characters, color code them... 19:38
ccc IP addresses are written in decimal 255.255.255.255 19:39
kensanata ccc: Also IPv6
ccc Assume I'm Rip Van Winkle: is IPv6 finally taking over? 19:40
silly question 19:41
I still see the xxx.xxx.xxx.xxx everywhere 19:42
kensanata I'm still interested in a quick and easy solution to the question of how to turn any string into four octal digits. 19:43
ccc kensanata: I'm still learning but I thought I saw an example of exactly that in the perl6 docs 19:43
kensanata: Trouble is I can't remember where but you could do a site search 19:44
sena_kun m: say 225.base(8); say 'a'.ord.base(8); say 'Musk'.comb>>.ord>>.base(8); 19:45
camelia 341
141
(115 165 163 153)
sena_kun like that?
sena_kun I am not really sure about "four" octal digits. 19:46
the question is how do you want to turn strings into numbers. 19:47
ccc I think he wants to do the reverse
sena_kun m: '225.225.225.225'.split('.').map(*.Int).map(*.base(8)) 19:48
camelia ( no output )
sena_kun m: '225.225.225.225'.split('.').map(*.Int).map(*.base(8)).say
camelia (341 341 341 341)
sena_kun m: '225.225.225.225'.split('.').map(*.Int).map(*.base(8)).map(*.Str).join[0..4].say 19:50
camelia Index out of range. Is: 1, should be in 0..0
in block <unit> at <tmp> line 1
jnthn .map(*.Int.base(8)) # saves 2 maps
sena_kun oh, indeed.
I am too pampered with point-free notation. :S
diakopter such composable 19:51
sena_kun m: say '225.225.225.225'.split('.').map(*.Int.base(8).Str).join.substr(0, 4)
camelia 3413
sena_kun m: say '225.225.225.225'.split('.').>>(*.Int.base(8).Str).join.substr(0, 4) 19:52
camelia Too many positionals passed; expected 1 argument but got 2
in block <unit> at <tmp> line 1
sena_kun ok, it doesn't work like that.
ccc m: sub ipaddr(uint32 $a) {my @b; loop (my $i=0; $i < 4;$i++) {@a.unshift($a & 0xff); $a>>=8;} say join('.',@a);} say ipaddr(0xc0a80002); 19:53
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable '@a' is not declared. Did you mean '$a'?
at <tmp>:1
------> 3a) {my @b; loop (my $i=0; $i < 4;$i++) {7⏏5@a.unshift($a & 0xff); $a>>=8;} say join
ccc m: sub ipaddr(uint32 $a) {my @b; loop (my $i=0; $i < 4;$i++) {@b.unshift($a & 0xff); $a>>=8;} say join('.',@b);} say ipaddr(0xc0a80002); 19:54
camelia 5===SORRY!5=== Error while compiling <tmp>
Malformed postfix
at <tmp>:1
------> 3i < 4;$i++) {@b.unshift($a & 0xff); $a>>7⏏5=8;} say join('.',@b);} say ipaddr(0xc0a
expecting any of:
postfix
ccc okay what's the operator for bit shift right?
sena_kun +& 19:55
oops.
+>>
tobs m: say 256 +> 4
camelia 16
ccc m: sub ipaddr(uint32 $a) {my @b; loop (my $i=0; $i < 4;$i++) {@b.unshift($a & 0xff); $a = >>8;} say join('.',@b);} say ipaddr(0xc0a80002);
camelia 5===SORRY!5=== Error while compiling <tmp>
Missing infix inside HYPER
at <tmp>:1
------> 3 4;$i++) {@b.unshift($a & 0xff); $a = >>7⏏058;} say join('.',@b);} say ipaddr(0xc0a8
expecting any of:
infix
infix stop…
ccc m: sub ipaddr(uint32 $a) {my @b; loop (my $i=0; $i < 4;$i++) {@b.unshift($a & 0xff); $a = $a>>8;} say join('.',@b);} say ipaddr(0xc0a80002); 19:55
camelia 5===SORRY!5=== Error while compiling <tmp>
Malformed postfix
at <tmp>:1
------> 3;$i++) {@b.unshift($a & 0xff); $a = $a>>7⏏058;} say join('.',@b);} say ipaddr(0xc0a8
expecting any of:
postfix
ccc m: sub ipaddr(uint32 $a) {my @b; loop (my $i=0; $i < 4;$i++) {@b.unshift($a & 0xff); $a = $a +>> 8;} say join('.',@b);} say ipaddr(0xc0a80002); 19:56
camelia 5===SORRY!5=== Error while compiling <tmp>
Preceding context expects a term, but found infix > instead.
at <tmp>:1
------> 3i++) {@b.unshift($a & 0xff); $a = $a +>>7⏏5 8;} say join('.',@b);} say ipaddr(0xc0a
tobs ccc: you also want to use +& instead of & for bitwise ANDing. In P6 the sole & is a junction
ccc m: sub ipaddr(uint32 $a) {my @b; loop (my $i=0; $i < 4;$i++) {@b.unshift($a & 0xff); $a = $a ~> 8;} say join('.',@b);} say ipaddr(0xc0a80002); 19:57
camelia 5===SORRY!5===
Cannot assign to readonly variable $a
at <tmp>:1
------> 3++) {@b.unshift($a & 0xff); $a = $a ~> 87⏏5;} say join('.',@b);} say ipaddr(0xc0a80
Strange text after block (missing semicolon or comma?)
at <tmp>:1
------…
ccc m: sub ipaddr($a) {my @b; loop (my $i=0; $i < 4;$i++) {@b.unshift($a & 0xff); $a = $a ~> 8;} say join('.',@b);} say ipaddr(0xc0a80002); 19:58
camelia 5===SORRY!5=== Error while compiling <tmp>
Strange text after block (missing semicolon or comma?)
at <tmp>:1
------> 3) {@b.unshift($a & 0xff); $a = $a ~> 8;}7⏏5 say join('.',@b);} say ipaddr(0xc0a8000
ccc m: sub ipaddr($a) {my @b; loop (my $i=0; $i < 4;$i++) {@b.unshift($a & 0xff); $a = $a ~> 8;}; say join('.',@b);}; say ipaddr(0xc0a80002);
camelia Cannot resolve caller infix:«~>»(Int, Int); none of these signatures match:
(Str:D \a, Int:D \b --> Str:D)
(str $a, int $b)
in sub ipaddr at <tmp> line 1
in block <unit> at <tmp> line 1
ccc Hmm - you can tell I'm new at this 20:00
tobs m: sub ipaddr($a) { my @b; loop (my $i=0; $i < 4; $i++) { @b.unshift($a +& 0xff); $a +>= 8 }; say join('.',@b) }; say ipaddr(0xc0a80002) 20:02
camelia Cannot assign to a readonly variable or a value
in sub ipaddr at <tmp> line 1
in block <unit> at <tmp> line 1
tobs m: sub ipaddr($a is copy) { my @b; loop (my $i=0; $i < 4; $i++) { @b.unshift($a +& 0xff); $a +>= 8 }; say join('.',@b) }; say ipaddr(0xc0a80002)
camelia 192.168.0.2
True
tobs and now watch this
m: 0xc0a80002.polymod(256 xx *).reverse.join('.').say
camelia 192.168.0.2 20:03
ccc m: say 6 ~> 1
camelia Cannot resolve caller infix:«~>»(Int, Int); none of these signatures match:
(Str:D \a, Int:D \b --> Str:D)
(str $a, int $b)
in block <unit> at <tmp> line 1
ccc m: say 6 +> 1
camelia 3
ccc tobs: that's nifty 20:07
tobs kensanata: as far as turning "any string into four octal digits" goes, djb2 is a simple way of doing that (assuming you want to use that to color strings like IRC nicks?)
m: "any string".comb».ord.reduce(* * 33 +^ *) mod 8**4
camelia WARNINGS for <tmp>:
Useless use of "mod" in expression ".reduce(* * 33 +^ *) mod 8**" in sink context (line 1)
tobs m: say "any string".comb».ord.reduce(* * 33 +^ *) mod 8**4
camelia 2531
kensanata tobs: Basically I want to anonymise IP numbers in log files but make it possible to group actions by the same IP visually using simple color codes, eg. here: campaignwiki.org/wiki/DerTotenfluc...showedit=1 -- two different people but it's hard to guess their IP numbers. 20:09
tobs: Your suggestion sounds very good. 20:10
vrurg Is it possible to make rakudobrew autolink scripts from moar-<num>/install/share/perl6/site/bin? 20:11
vrurg nevermind, found 20:13
ccc what is rakudobrew? 20:14
locally compiled rakudo?
vrurg ccc: yes
tobs kensanata: oops, my line above is missing the initial hash value from djb2. Not that it matters for turning strings into numbers, but if I call it that, it should be implemented correctly 20:17
m: say [5381, |"any string".comb».ord].reduce(* * 33 +^ *) mod 8**4 # maybe with a mod 2**32 inside the reduce? 20:21
camelia 2342
kensanata tobs: I cannot answer the question in the comment. :) 20:30
kensanata tobs: I'm trying to understand the answers to stackoverflow.com/questions/157972...-algorithm but I think I should go to bed... 🙂 20:34
Herby_ o/ 20:39
\o 20:40
johnjohn101 hi perl 6 20:51
buggable New CPAN upload: Sparrowdo-Cordova-OSx-Build-0.0.4.tar.gz by MELEZHIK modules.perl6.org/dist/Sparrowdo::C...n:MELEZHIK 20:54
Xliff Does perl6 allow re-export of symbols as described in S11
johnjohn101 will perl 6 be targeting the new jvm stuff? 20:56
moritz if somebody makes it so... 20:59
johnjohn101 hmm 21:02
geekosaur Xliff, as yet the export machinery's rather unformed. iirc zoffix has a module that can be used to emulate some of what is intended, but not S11-style? 21:12
Xliff geekosaur++ # Thanks 21:15
diakopter export BYOBU_CHARMAP=x ; . ~/.bashrc 21:19
aw jeez
lizmat and another Perl 6 Weekly hits the Net: p6weekly.wordpress.com/2018/09/17/...ersus-six/ 21:46
El_Che releasable6: status 21:57
releasable6 El_Che, Next release will happen when it's ready. 0 blockers. 1 out of 112 commits logged (⚠ 47 warnings)
El_Che, Details: gist.github.com/e20bdbc48d5db6e1fb...3d7b9ff6d6
AlexDaniel El_Che: colabti.org/irclogger/irclogger_log...09-16#l491 21:59
I sorta just woke up so tommorow for me is starting about now :) 22:00
.tell jmerelo what is up with this rejectionism lately in perl6/doc? :) 22:05
yoleaux AlexDaniel: I'll pass your message to jmerelo.
Zoffix lizmat++ # good weekly. P.S.: the "Could be simplified by Zoffix Znet." Tweet was from p6org 23:21
buggable New CPAN upload: GraphQL-0.5.8.tar.gz by CTILMES cpan.metacpan.org/authors/id/C/CT/...5.8.tar.gz 23:24
ttkp6 Really enjoyed the alexschroeder.ch article. It makes me want to do more work on my own fork of the old Oddmuse codebase. 23:59