»ö« Welcome to Perl 6! | perl6.org/ | evalbot usage: 'p6: say 3;' or rakudo:, or /msg camelia p6: ... | irclog: irc.perl6.org or colabti.org/irclogger/irclogger_logs/perl6 | UTF-8 is our friend! 🦋
Set by Zoffix on 25 May 2018.
benjikun welp, nvm I figured out a hacky way 00:05
00:07 chartractegg joined, chartractegg left 00:25 snef joined 00:30 snef left 00:52 markoong left, markoong joined 00:57 markoong left 01:04 molaf left
Xliff Has anyone developed a way to pad a CStruct with a certain number of bytes? 01:07
01:14 fascinum joined 01:17 molaf joined 01:59 kurahaupo left 02:01 zachk left 02:03 molaf left 02:16 molaf joined 02:26 snef joined 02:30 snef left 02:35 psychoslave joined 02:38 araraloren joined 02:47 kjk joined
kjk p6: &substr.package 02:48
camelia ( no output )
kjk In the REPL, it says: No such method 'WHERE' for invocant of type 'GLOBAL'
02:48 skids joined
kjk shouldn't it return the GLOBAL package? 02:49
02:50 lichtkind left, uzl joined
araraloren m: say ::.keys; 02:51
camelia ($?PACKAGE $=pod EXPORT $! ::?PACKAGE $_ !UNIT_MARKER $=finish GLOBALish $¢ $/)
geekosaur looks like a bug in the REPL, it works with perl6 -e 02:52
oh, this might be the change to try to find/print docs?
which IIRC is what .WHERE is for 02:53
kjk should I open a bug in rakudo?
geekosaur rakudobug it, I think
kjk ok
uzl Hello to all! 02:59
How would the class Journey in this example (docs.perl6.org/language/objects#Methods) would look like as class module?
Let's say that it's located in the directory lib/Module/Journey.pm6
I could do something like unit class Module::Journey; but how do I define the attributes? 03:00
Xliff m: use NativeCall; class A { has uint64 $.aa; }; my $a = A.new(); ($a.aa ~~ uint64).say 03:01
camelia False
Xliff m: use NativeCall; class A { has uint64 $.aa; }; my $a = A.new(); ($a.aa ~~ uint64).say; $a.aa.^name;
camelia False
Xliff m: use NativeCall; class A { has uint64 $.aa; }; my $a = A.new(); ($a.aa ~~ uint64).say; $a.aa.^name.say;
camelia False
Int
Xliff m: use NativeCall; class A { has uint64 $.aa; }; my $a = A.new(); ($a.aa ~~ Int).say; $a.aa.^name.say;
camelia True
Int
geekosaur uzl: unit module Foo; has .aa = False; # etc. 03:03
or whatever
03:04 hami joined
uzl geekosaur: What about unit class Foo? In which cases do I use it instead of unit module Foo? 03:05
geekosaur when you want the whole file to be the module or class
then you can pretennd the whole file is wrapped in the braces
(which is what "unit" means. and you'll get an error if it's not the first declaration in the file) 03:06
you can use that with package (rarely usefiul in p6), module, and class
less useful with class since you often want more than just the class in a file
Xliff m: use NativeCall; class A { has uint64 $.aa; has OpaquePointer $.bleah; }; my $a = A.new(); eval<\$a.bleah>
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared routine:
eval used at line 1. Did you mean 'EVAL', 'val'?
Xliff m: use NativeCall; class A { has uint64 $.aa; has OpaquePointer $.bleah; }; my $a = A.new(); eval { "\$a.bleah" } 03:07
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared routine:
eval used at line 1. Did you mean 'EVAL', 'val'?
Xliff m: use NativeCall; class A { has uint64 $.aa; has OpaquePointer $.bleah; }; my $a = A.new(); eval({ "\$a.bleah" })
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared routine:
eval used at line 1. Did you mean 'EVAL', 'val'?
geekosaur it's uppercase no matteer what
Xliff m: use NativeCall; class A { has uint64 $.aa; has OpaquePointer $.bleah; }; my $a = A.new(); EVAL { "\$a.bleah" }
camelia 5===SORRY!5=== Error while compiling <tmp>
EVAL is a very dangerous function!!! (use the MONKEY-SEE-NO-EVAL pragma to override this error,
but only if you're VERY sure your data contains no injection attacks)
at <tmp>:1
------> 3}; my $a …
geekosaur it also requires MONKEY-SEE-NO-EVAL no matter what
uzl geekosaur: So always use unit module if I have just a class in the whole file?
geekosaur uzl, er. you do understand the difference between a module and a class?
Xliff OK. I know I've asked this before, but how do I call a method of an object where the method name is stored in a string? 03:08
uzl geekosaur: you caught me. I'm not sure!
Xliff m: use NativeCall; class A { has uint64 $.aa; has OpaquePointer $.bleah; }; my $a = A.new(); $a."&bleah"
camelia 5===SORRY!5=== Error while compiling <tmp>
Quoted method name requires parenthesized arguments. If you meant to concatenate two strings, use '~'.
at <tmp>:1
------> 3$.bleah; }; my $a = A.new(); $a."&bleah"7⏏5<EOL>
geekosaur m: my $x = 'substr'; my $s = 'foobar'; say $s.$x(3)
camelia No such method 'CALL-ME' for invocant of type 'Str'
in block <unit> at <tmp> line 1
geekosaur m: my $x = 'substr'; my $s = 'foobar'; say $s.::($x)(3)
camelia ===SORRY!===
cannot stringify this
geekosaur whoops 03:09
methods are harder, I forget that one
Xliff m: use NativeCall; class A { has uint64 $.aa; has OpaquePointer $.bleah; }; my $a = A.new(); $n = "bleah"; $a.$n
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable '$n' is not declared
at <tmp>:1
------> 3quePointer $.bleah; }; my $a = A.new(); 7⏏5$n = "bleah"; $a.$n
03:09 hami left
geekosaur uzl, a module si a namespace in which you can put variables, packages, subs, etc. 03:09
also classes
a class is a user-defined type with behavior. most modules will declare one or more classes within them. 03:10
uzl geekosaur: oh, thanks!
geekosaur you should be able to poke aroun d the ecosystem and see how people declare modules. 03:11
03:11 mahafyi joined
Xliff geekosaur: Do the docs give that example, anywhere? 03:11
geekosaur "unit class" is really only useful if you for some reason put one class per file in a local project. usually you define modules/"libraries" and don't stick classes in their own files, because it becomes annoying
uzl geekosaur: I was looking at JSON::Tiny and trying to emulate it but still having some problems. 03:12
geekosaur docs.perl6.org/language/modules
uzl geekosaur: That makes same.
geekosaur docs.perl6.org/language/module-packages 03:13
and I apparently have to reboot my router. sih
uzl geekosaur: I'm reading it but it's somewhat dense (at least for me).
03:14 Zoffix joined
Zoffix m: my $x = 'substr'; my $s = 'foobar'; say $s."$x"(3) 03:14
camelia bar
Zoffix You need to stuff everything into a string and parens are mandatory 03:15
uzl: you can use `unit class`
03:16 uzl_ joined, uzl left
Zoffix It's really the same as `class { ... }` except you get to save an indent level and a set of curlies 03:16
03:17 uzl_ is now known as uzl
Zoffix kjk: you like want to stick a `.^name` at the end to get the name of the string with the name of the thing rather than the thing itself 03:18
kjk Zoffix: I'm actually interested in the thing itself! I'm trying various way to introspect objects from REPL 03:19
Zoffix kjk: ok, in that case you do have it. REPL just craps out when it's trying to figure out if more input is needed 03:22
(it = the thing itself)
kjk Proc.WHO.HOW 03:26
p6: Proc.WHO.HOW
camelia ( no output )
kjk says: No such method 'WHERE' for invocant of type 'Perl6::Metamodel::ClassHOW+{<anon>}' 03:27
works with perl6 -e though. I guess it's a similar issue with &substr.package
araraloren Do they create a default module if we setup a new file such as `lib/Foo.pm6` ?
geekosaur yes
araraloren, no 03:28
Zoffix kjk: yeah, I'm about to fix that
geekosaur if you don't specify, it goes into the current module (usually MAIN)
araraloren because I can `use Foo` in other file though the Foo.pm6 is empty
geekosaur (I think)
hm, UNIT, whatever that is at the time
kjk Zoffix: cool, thanks
araraloren so I know they do two step `need; import` when we using `use` import a module 03:31
what is `need` do ?
and what about the `import` ?
Zoffix araraloren: AFAIK need actually loads the… file… with the stuff and `import` brings exportable symbols into current lexical scope. So if you do `need Test;` you can use `&Test::EXPORT::DEFAULT::ok()` but not just `ok()`, but if you also do `import` then `ok` will be in current scope 03:33
m: need Test; Test::EXPORT::DEFAULT::ok(42)
camelia ok 1 -
03:33 Xliff left
Zoffix m: need Test; Test::EXPORT::DEFAULT::ok(42); ok 100 03:33
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared routine:
ok used at line 1
Zoffix m: need Test; import Test; Test::EXPORT::DEFAULT::ok(42); ok 100
camelia ok 1 -
ok 2 -
araraloren oh
intersting 03:34
Zoffix araraloren: and yeah, `use Foo` just loads the file. It can be empty. And it can even contain `our` stuff in top scope that'll end up in UNIT... Like, if you stick `our sub foo { say "meow" }` into lib/Foo.pm6 and do `perl6 -Ilib -MFoo -e 'foo' it'll actually work, despite you never exporting that sub explicitly 03:35
araraloren Zoffix thanks, so clear
so we just load the file (compunit?), not find something `unit module XXX` in some pm6 file 03:36
Zoffix And IIRC if you have a META6.json file or it's an installed module and in `provides` you have `"Foo" : "lib/Bar.pm6"` then you can do `use Foo` and it'll load lib/Bar.pm6 03:37
araraloren okay
Zoffix I think it looks for the file or whatever meta6.json lists... Dunno the details
araraloren hmm, thanks 03:38
kjk given an object, how do you tell if it's a kind of package? check .HOW.WHAT ~~ ClassHOW|ModuleHOW|PackageHOW|ParametricRoleGroupHOW ? 03:40
Zoffix benjikun: never used that module, but you could use `state $foo` or an anon state variable: 03:41
m: for ^10 { state $x = 0; say $x++; say $++ }
camelia 0
0
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
araraloren kjk may be help : docs.perl6.org/language/syntax#ind...eclaration 03:42
m: package foo { }; say foo ~~ package; 03:43
camelia 5===SORRY!5=== Error while compiling <tmp>
Whitespace required after keyword 'package'
at <tmp>:1
------> 3package foo { }; say foo ~~ package7⏏5;
03:43 psychoslave left
geekosaur m: package foo {}; say foo ~~ Package' 03:45
camelia 5===SORRY!5=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> 3package foo {}; say foo ~~ Package7⏏5'
expecting any of:
infix
infix stopper
postfix
statement end
geekosaur oops
m: package foo {}; say foo ~~ Package;
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared name:
Package used at line 1
geekosaur bleh.
m: package foo {}; say foo ~~ Stash;
camelia False
geekosaur m: package foo {}; say foo ~~ PseudoStash; 03:46
camelia False
geekosaur m: package foo {}; dd foo
camelia foo
kjk also how do you get a hold of a meta class other than calling .HOW ? I can't just say ClassHOW, doesn't work in the REPL
geekosaur m: package foo {}; say foo.^name
camelia foo
Zoffix m: package foo {}; say foo.HOW ~~ Metamodel::PackageHOW
camelia True
geekosaur it's giving you short names
03:46 uzl left
geekosaur they're all in Metamodel:: 03:46
kjk uh ic..., usually in the REPL it's mentioned with an additional Perl6:: at the front, which doesn't work either 03:47
geekosaur right, Metamodel:: is the documented name and in rakudo is an alias to its private one which has the Perl6:: in front 03:48
but it should accept it with the full qualification, modulo that error you keep getting
(.WHERE)
Zoffix m: say [.^name, $_ ~~ Metamodel::PackageHOW, $_ ~~ Metamodel::ClassHOW, $_ ~~ Metamodel::ModuleHow, $_ ~~ Metamodel::ParametricRoleGroupHOW, $_ ~~ Metamodel::ParametricRoleHOW] for Int, package {}, IO, role {}
camelia Could not find symbol '&ModuleHow'
in block <unit> at <tmp> line 1
Zoffix m: say [.^name, $_ ~~ Metamodel::PackageHOW, $_ ~~ Metamodel::ClassHOW, $_ ~~ Metamodel::ModuleHOW, $_ ~~ Metamodel::ParametricRoleGroupHOW, $_ ~~ Metamodel::ParametricRoleHOW] for Int, package {}, IO, role {} 03:49
camelia [Int False False False False False]
[<anon> False False False False False]
[IO False False False False False]
[<anon|1> False False False False False]
Zoffix :(
ah
m: say [.^name, .HOW ~~ Metamodel::PackageHOW, .HOW ~~ Metamodel::ClassHOW, .HOW ~~ Metamodel::ModuleHOW, .HOW ~~ Metamodel::ParametricRoleGroupHOW, .HOW ~~ Metamodel::ParametricRoleHOW] for Int, package {}, IO, role {}
camelia [Int False True False False False]
[<anon> True False False False False]
[IO False False False True False]
[<anon|1> False False False False True]
kjk hmm, it's hard! lol.. 03:50
Zoffix m: sub prefix:<♥> { $::OUTER::_.HOW ~~ ::("Metamodel::$($^a)HOW") }; say [.^name, ♥'Package', ♥'Class', ♥'Module', ♥'ParametricRoleGroup', ♥'ParametricRole'] for Int, package {}, IO, role {} 03:53
camelia [Int False True False False False]
[<anon> False True False False False]
[IO False True False False False]
[<anon|1> False True False False False]
Zoffix tehe
araraloren haha 03:54
Zoffix > &say.package 04:02
(low-level object `GLOBAL`)
kjk: how's what?
kjk: *how's that?
Shipped into post-release branch 04:19
04:19 Zoffix left
kjk Zoffix: nice, thanks for the quick fix! 04:19
04:25 snef joined 04:27 wamba left 04:28 n1ge joined 04:54 xtreak joined 04:55 snef left 05:00 skids left
kjk Zoffix: for testing if an object is a package, does this implementation make sense? gist.github.com/kjkuan/1ddef6d3594...ef4a5eb628 05:00
05:11 sauvin joined 05:31 fascinum left 05:32 fascinum joined 05:43 sarna joined
sarna .hug Zoffix 05:44
huggable hugs Zoffix
05:44 lainon left
sarna I've just read your blog post :) 05:44
06:44 evalable6 left, evalable6 joined 06:46 |oLa| joined 06:48 kaare_ left
u-ou .hug ilbelkyr 06:50
huggable hugs ilbelkyr
07:03 kaare_ joined 07:42 mahafyi left 07:50 rindolf joined, sarna_ joined
sarna_ hey guys, what could be the reason for my MAIN sub not working when I `perl6 foo.pm6`? 07:51
I have a `unit class App::Foo;` at the top of my file, could that be the reason 07:52
El_Che yes 07:53
sarna_ do I have to remove it? or tweak it?
ah, alright, I found a blog post. thank :) 07:55
07:57 kaare_ left, xtreak left 08:03 benjikun2 joined 08:04 benjikun left 08:09 kaare_ joined, HaraldJoerg joined 08:10 mahafyi joined
sarna_ when should I use Local as the top-level namespace? 08:11
08:11 darutoko joined
El_Che main is something for your script, commonly 08:14
(or you need to initialize the object) 08:15
08:15 xtreak joined
sarna_ El_Che: yeah, I had to create a file in bin/ :) 08:17
it's pretty confusing at first
or maybe it's just me 08:18
08:18 lalitmee joined 08:26 wamba joined 08:28 hythm_ joined 08:40 AlexDani` is now known as AlexDaniel 08:47 xtreak left 08:55 hythm_ left
araraloren sarna_ MAIN in your App::Foo, is App::Foo::MAIN, not ::MAIN 08:56
08:56 sarna_ left 08:57 sarna_ joined
sarna_ docs.perl6.org is offline :( 08:59
gfldex sarna_: if you ‚is export‘ the main and run the script with ‚perl6 -I. -Mfoo‘ it will work 09:00
sarna_ gfldex: neat, thank you 09:02
gfldex sarna_: one-page version of the docs: gist.github.com/gfldex/5a5f7898d4e...d0653c220a 09:10
sarna_ gfldex: thanks again! :D 09:12
09:14 Woodi joined
moritz FYI I'm rebooting www.p6c.org, it became unreachable 09:16
09:17 grumblr joined 09:18 lalitmee left 09:20 grumble left, grumblr is now known as grumble 09:33 sarna left
ecocode hello.. how is perl6 on jvm? is it working/stable? 09:43
09:45 kurahaupo joined
AlexDaniel generally, it is working 09:45
in my opinion it is somewhat incomplete, but you mileage may vary 09:46
sarna_ hey, how can I fix `Preceding context expects a term, but found infix == instead.`? I have a `given` after an `if` 09:48
(I wanted to use `given` as a switch/case but I guess it doesn't work that way) 09:49
AlexDaniel sarna_: can you show some code? I'm struggling to recreate this 09:54
09:59 eliasr joined
sarna_ AlexDaniel: a sec, I'll try to dumb it down 10:00
oof, I can't isolate it 10:03
AlexDaniel: p.teknik.io/HhJRk 10:05
it's really ugly but
araraloren if do given 10:06
would be work
AlexDaniel sarna_: if $c_column == $column {
sarna_: missing sigils
araraloren you miss sigil $
sarna_ AlexDaniel: oh! it tripped me up for the third time today 10:07
yay perl
:D
thank you
araraloren and the given is in if block, not after if
AlexDaniel sarna_: can you create a ticket for that?
sarna_ AlexDaniel: LTA?
AlexDaniel I am not sure if it's possible, but maybe it could've said “did you mean $c_column ?” 10:08
araraloren the error message ?
AlexDaniel yes
sarna_ AlexDaniel: alright, will do in a sec :)
araraloren yeah, it should guess what you want
AlexDaniel I think it should be possible to check if there's a variable with that name, and if so print something extra
10:11 fascinum left 10:17 Marcool joined 10:19 Marcool left
sarna_ AlexDaniel: done :) 10:24
tell me if the format is correct, the default seemed a little.. clunky 10:25
my code still yells at me :( "expression needs parens to avoid gobbling block" 10:30
oops, it was because I put a `=>` after a `when` :') 10:31
10:36 MasterDuke left 11:26 n1ge left 11:28 ExtraCrispy left 11:31 markoong joined 11:33 MasterDuke joined, mahafyi left 11:44 Khisanth left 11:47 ufobat_ joined 11:51 mahafyi joined 11:52 llfourn left 11:57 Khisanth joined 11:59 MasterDuke left 12:12 wamba left, wamba joined 12:15 itaylor57 joined 12:20 hami joined, llfourn joined 12:25 wamba left 12:27 hami left 12:30 molaf left 12:33 rabbit_ left, lizmat joined 12:46 molaf joined 12:57 n1ge joined, sarna_ left 13:04 MasterDuke joined 13:12 molaf left, MilkmanDan left 13:13 MilkmanDan joined 13:18 benjikun joined 13:20 benjikun2 left
hoelzro good news sarna, El_Che: I managed to reproduce that issue! 13:20
I'll be digging into what's going on with that
El_Che hoelzro+++
wow
hoelzro El_Che: thanks for all your help yesterday! 13:36
AlexDaniel what issue btw? Is that something I should know about? 13:39
El_Che AlexDaniel: Linenoise is broken on some installations
on different OSes
AlexDaniel is that new?
El_Che I am happy hoelzro is fixing this because Readline is also broken en recent distributions 13:40
(everything using libreadline 7)
AlexDaniel: newish
hoelzro AlexDaniel: it's at least 2 months old; it's related to different rakudo and Linenoise installation paths
13:42 subroot left 13:43 n1ge left 13:58 domidumont joined 14:02 domidumont left 14:03 domidumont joined 14:20 n1ge joined 14:21 n1ge left 14:22 n1ge joined 14:25 MasterDuke left, xtreak joined 14:32 MasterDuke joined 14:44 mahafyi left 14:49 mahafyi joined 14:54 mahafyi left 14:55 sarna joined 15:14 kjk left 15:15 kjk joined 15:20 sjoshi joined 15:35 itaipu joined 15:37 kurahaupo_ joined, kurahaupo_ left 15:38 kurahaupo_ joined 15:40 kurahaupo left 15:47 perlpilot joined 15:52 ExtraCrispy joined 15:54 kurahaupo_ is now known as kurahaupo
tbrowder_ o/ good day #perl6 15:57
any emacs users have a menu that displays unicode code points and corresponding symbol? 15:59
16:16 dha joined, fascinum joined 16:21 uzl joined 16:22 dha left 16:27 Zoffix joined
kjk how does scope work in the REPL or where/which package can I find the things I just defined? 16:28
p6: my $var = 123; say GLOBAL::.keys 16:29
camelia ()
kjk p6: our $var = 123; say GLOBAL::.keys
camelia ($var)
geekosaur "my" is never in a package 16:30
it hsould be in the lexpad
16:30 dha joined 16:31 perlpilot left
kjk geekosaur: gotcha. In this case, how would I show the my variable in the lexpad from the REPL? 16:31
Zoffix m: my $x; say MY::.keys
camelia (::?PACKAGE $/ $=finish $¢ $?PACKAGE EXPORT $_ !UNIT_MARKER $! $=pod GLOBALish $x)
16:32 sjoshi left
Zoffix kjk: doesn't show up in REPL presumably because REPL is a hack 16:32
16:33 sjoshi joined
kjk Zoffix: oh ic, that's why. Where in perl6 source can I see how REPL is implemented? 16:33
geekosaur REPL starts a new local/lexical scope for each line, iirc. it's going to be painful (and nonportable, as behavior may change in the future)
16:34 dha left
kjk so basically it just keeps nesting lexical scopes for each line? 16:34
that would make sense, I guess that's why I can "redefine" things in the REPL ? 16:35
I mean things that are lexical
uzl Do class attributes needs to declared with the twigil $.? What about class attributes that are constants? 16:36
geekosaur uzl, the actual twigil for attributes is $!
$. "autodeclares" accessors for you
Zoffix kjk: right here: github.com/rakudo/rakudo/blob/mast...e/REPL.pm6 16:37
16:37 sarna_ joined
kjk thank you Zoffix 16:37
btw, this is how I check if something is like a package: gist.github.com/kjkuan/1ddef6d3594...ef4a5eb628 16:38
does it make sense?
Zoffix kjk: with the eval part done here: github.com/rakudo/rakudo/blob/mast...#L333-L357
It saves "context" and then restores it or something
And some things currently don't work (like declaring custom ops and IIRC native-typed variables have some problems too) 16:39
16:39 fascinum left
Zoffix So basically, if you're playing around with the language, especially with the package stuff, you probably better off using a proper script, rather than doing it in REPL 16:39
uzl geekosaur: I'm trying to declare a class attribute (which is done with my or our) but if I do it with $! (instead of $.), I get this error: Cannot use ! twigil on 'my' variable 16:40
AlexDaniel Any OpenBSD users here? There's a claim on R#1867 that t/spec/S10-packages/precompilation.rakudo.moar is failing, which I really doubt, but would be nice to double check.
synopsebot_ R#1867 [open]: github.com/rakudo/rakudo/issues/1867 [severe][⚠ blocker ⚠] Test failures on FreeBSD
Zoffix kjk: not an expert in that area, but one thing I see you may want to improve is `!$object.defined` you likely meant `!$object.DEFINITE` there (i.e. type objects only)
geekosaur yes, that's expected. you don't want a twigil for "my", it's lexical scope not an "attribute"
uzl geekosaur: So how do I declare the class attribute? With our and as a regular variable? 16:42
kjk Zoffix: oh, ok, thanks, TIL 16:43
Zoffix uzl: that's because $! is a private attribute, but for class attributes, there's nothing to be private to, so you can only have public attributes 16:44
16:46 uzl_ joined, dha joined, uzl_ left
kjk so..., what's something that's .defined but not .DEFINITE ? or maybe the other way around 16:46
16:46 itaipu left, uzl left
Zoffix m: say [.DEFINITE, .defined] with Failure.new 16:47
camelia ( no output )
lizmat kjk: any class can create a "define" method and assign its own meaning to it
Zoffix m: say [.DEFINITE, .defined] without Failure.new
camelia [True False]
Zoffix kjk: ^
lizmat as Zoffix just pointed out: Failure.defined has special semantics
kjk oh I see, thank you 16:48
Zoffix LP6 update just came in: final ebook update shipped and "Three months is a conservative estimate for the time between I turn in the book to the day it shows up in the mail from pre-orders."
So looks like my estimate that the upcoming Star is the Star the book readers will read is correct
16:48 uzl joined 16:49 dha left
Zoffix (estimate in rakudo.party/post/A-Call-To-Action...Experience I meant) 16:50
kjk so when I declare a type with :D is it checking for .defined or .DEFINITE ? 16:51
Zoffix kjk: .DEFINITE 16:52
m: say Failure.new ~~ Mu:D
camelia True
16:52 molaf joined
kjk Zoffix: gotcha, thanks 16:53
lizmat m: sub a(Failure:D) { }; my $f = Failure.new(X::AdHoc.new); a $f; dd $f.defined 16:54
camelia Bool::False
lizmat m: sub a(Failure:D) { say "DEFINITE" }; my $f = Failure.new(X::AdHoc.new); a $f; dd $f.defined
camelia DEFINITE
Bool::False
kjk right. An instance of Failure is DEFINITE but not defined 16:56
so basically, .DEFINITE is like an is-instance check. but an instance can be defined(default) or undefined depends on how it's implemented. 16:58
Zoffix right 16:59
17:00 nebuchadnezzar joined 17:01 dha joined 17:03 sjoshi left
sarna_ is there a shortcut for `bar(foo => ($foo - 1))` if `foo` is a named argument? 17:04
`:$foo - 1` doesn't work for some reason
Zoffix sarna_: no, other than bar(:foo($foo-1))
sarna_ D: 17:05
thanks
Zoffix sarna_: 'cause that means `Pair.new('foo', $foo) - 1`
sarna_ Zoffix: I'm asking because my lines are exceeding the 72 character line and it makes me anxious
17:05 dha left
Zoffix sarna_: use multiple lines 17:07
sarna_ Zoffix: each parameter on separate line? 17:08
Zoffix sarna_: doesn't have to be *each*, just fill the line and then continue on a new line
sarna_ Zoffix: hmm, I'll try :) 17:09
Zoffix Just finished my local coding meetup. No one even heard of Perl 6 when I mentioned it. Was a nice surprise as I was kinda bracing for the "Perl is linenoise" reaction :) 17:16
kjk is there something that's true but not .defined in perl6? I guess that would be confusing 17:20
geekosaur you could make one but it seems like a bad idea
MasterDuke Zoffix: it's not a language specific meetup? 17:21
lizmat m: my $a = 1 but False; say "foo" if $a 17:22
camelia ( no output )
Zoffix MasterDuke: no, just general "coding" meetup
MasterDuke cool 17:23
kjk lizmat: right, but that's still .defined 17:24
lizmat m: my $a = Any but True; say "true" if $a; say $a.defined
camelia true
False
lizmat Perl 6 gives you enough rope to shoot yourself in the foot and drown yourself 17:25
kjk lol
geekosaur m: class Weird { method defined { False }; method Bool { True }; }; my $x = Weird.new; say $x.defined; say so $x 17:26
camelia False
True
17:30 stee joined 17:32 stee3 left 17:34 ExtraCrispy left 17:39 sarna_ left 17:43 ExtraCrispy joined
kjk Any is Mu, Any is the default base class, and also the default type of paramenters and variables. When would you use Mu instead of Any? 18:08
geekosaur when you need direct access to Junctions instead of having them autothread 18:09
lizmat If you want to have something that doesn't autothread wrt Junctions
kjk interesting 18:10
lizmat m: sub foo($a) { dd $a }; foo 1|2|3
camelia Int $a = 1
Int $a = 2
Int $a = 3
lizmat m: sub foo(Mu $a) { dd $a }; foo 1|2|3 18:11
camelia Junction $a = any(1, 2, 3)
lizmat the latter didn't auth-thread
*auto
kjk lizmat: ic, thanks for the example! 18:12
18:16 Zoffix left
ingy tinita: hi 18:19
tinita hi 18:20
ingy m: sub foo($a) { dd $a }; foo 1|2|3
camelia Int $a = 1
Int $a = 2
Int $a = 3
ingy tinita: do you see the NL unicode chars
in that output?
tinita ingy: yeah, I can see them in my IRC window in irssi, but for some reason not in a terminal without irssi 18:21
ingy huh
I might need a TESTML_NO_FANCY_UNICODE setting...
tinita actually, it's not irssi, but I have no idea 18:22
in one tmux I can see it, in the other I can't
18:22 rindolf left
ingy does perl6 use things like ␤ in error messages? (besides irc bots...) 18:22
tinita ingy: might be a urxvt thing, in xterm I see it 18:24
timotimo i think the nl symbol thing is purely from ircbot
ingy marklemonware?
18:24 Zoffix joined
tinita yeah 18:25
Zoffix The ␤ is just the bot converting "\n" to and from ␤
18:25 psychoslave_ joined
Zoffix It's not used in the compiler itself anywhere. 18:25
ingy I use ␤ in TestML for label string interpoaltion that has newlines
tinita or maybe it's my font setting 18:26
ingy "Test the {*foo} == {*bar}": *foo == *bar
18:28 |oLa| left
ingy testml-perl -e '"Test that {Got} == {Want}": "foo\nbar\n" == "foo\nbar\n"' 18:29
ok 1 - Test that foo␤bar␤ == foo␤bar␤
the friend I'm visiting had problems viewing that as well
maybe it should be opt-in 18:30
tinita yeah, that sounds like a good idea. or at least opt-out
ingy nod 18:31
18:32 rindolf joined 18:35 raschipi joined
Zoffix .seen DrForr 18:37
yoleaux I saw DrForr 13 Apr 2018 14:25Z in #perl6: <DrForr> My head isn't in that space right now otherwise I'd look for possible examples...
Zoffix .ask DrFoor a long shot, but is there a version of your ML talk with working sound by any chance? www.youtube.com/watch?v=GI9DmIbNXrM
yoleaux Zoffix: I'll pass your message to DrFoor.
geekosaur who's DrFoor? :p
Zoffix .ask DrForr a long shot, but is there a version of your ML talk with working sound by any chance? www.youtube.com/watch?v=GI9DmIbNXrM 18:38
yoleaux Zoffix: I'll pass your message to DrForr.
Zoffix Thanks :)
18:38 psychoslave_ left
DrFoor . 18:39
yoleaux 18:37Z <Zoffix> DrFoor: a long shot, but is there a version of your ML talk with working sound by any chance? www.youtube.com/watch?v=GI9DmIbNXrM
ingy They Call Me Dr Foo o/~
geekosaur Mr. Hyde?
ingy to the tune of Dr Love... 18:42
18:43 domidumont left 18:47 xtreak left 18:49 susmus joined
b2gills the camelia bot uses ␤ instead of newlines because the newline character ends an irc message 18:51
ingy b2gills: well it could use '\n' 18:52
but that would couse confusion with literal '\n'
I really like the ␤
b2gills m: # comment␤ print "not a comment\n"
18:52 uzl left
camelia not a comment 18:52
ingy oic 18:53
neat
testml -e supports multiple -e lines, and they keep indentation. also 2 or more spaces after a ; are kept (for indentation). 18:54
so: testml -e '=>' -e ' 1 == 1' same as: testml -e '=>; 1 == 1' 18:55
people naturally want to put one space after a ;
but not 2 spaces, so that can mean indentation. 18:56
19:05 zakharyas joined 19:10 zakharyas left 19:11 zakharyas joined 19:39 darutoko left 19:45 Zoffix left 19:46 sjoshi joined 19:53 benjikun2 joined 19:57 benjikun left 20:04 wamba joined 20:06 mahafyi joined 20:22 sjoshi left 20:30 jmerelo joined 20:45 imcsk8 left
jmerelo squashable6: status 20:47
squashable6 jmerelo, Next SQUASHathon in 19 days and ≈13 hours (2018-07-07 UTC-12⌁UTC+14). See github.com/rakudo/rakudo/wiki/Mont...Squash-Day
El_Che releasable6: status
releasable6 El_Che, Next release will happen when it's ready. 2 blockers. 87 out of 91 commits logged
El_Che, Details: gist.github.com/b4a452650b48be6124...8660735050
sarna woo 20:48
20:51 Kaiepi joined
Kaiepi m: my $range = [1,1,*+*...*]; for 1..10 { say $range[$_] } 20:52
camelia 1
2
3
5
8
13
21
34
55
89
Kaiepi m: my $range = [1,1,*+*...*]; for 1..1000 { say $range[$_] }
camelia 1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
6765
10946
17711
28657
46368
75025
121393
196418
317811
514229
832040
1346269
2178309
3524578
5702887
9227465
14930352
24…
Kaiepi m: my $range = [1,1,*+*...*]; for 1..10000 { say $range[$_] }
camelia 1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
6765
10946
17711
28657
46368
75025
121393
196418
317811
514229
832040
1346269
2178309
3524578
5702887
9227465
14930352
24…
Kaiepi weird i run out of memory on my system when i try that
sarna maybe it's lazy here? 20:53
Kaiepi ok it doesn't when i try that again 20:54
jmerelo Kaiepi: different amount of memory, maybe.
Kaiepi: more free memory? 20:55
20:55 jmerelo left
Kaiepi openbsd limits the amount of memory processes can use depending on how /etc/login.conf is configure 20:55
20:56 mahafyi left
Kaiepi s/configure/configured 20:56
20:56 imcsk8 joined
Kaiepi it's weird that it killed moarvm when i first tried it though 20:57
it was using 1.5GB of memory 20:58
can't reproduce 21:00
21:02 raschipi left 21:06 HaraldJoerg1 joined 21:07 HaraldJoerg left
Kaiepi unrelated but anyone have any tips on how i can improve this grammar? hastebin.com/parimarowi.tex 21:08
i don't want to have to check for every single type of negotiation
21:09 raschipi joined
Kaiepi also why does <-[ \x[80] ... \x[FF] ]> but not <[ \x[00] ... \x[7f] >? 21:11
*<[ \x[00] ... \x[7F] ]> 21:12
geekosaur suspect that first doesnt do what you intend either, unless you're forcing a single-byte encoding elsewhere 21:15
Kaiepi what do you mean? 21:17
the string i'm passing to the grammar is encoded in latin1 21:18
21:31 HaraldJoerg1 is now known as HaraldJoerg, mahafyi joined 21:35 zakharyas left 21:40 Luneburg joined 21:45 raschipi left
Luneburg I'm having some trouble with Project Euler problem 11 21:46
The code looks good, but it isn't producing the right solution
timotimo can you paste the code on some pasting website? if you use one like glot.io we can immediately run the code on-line, too 21:47
Luneburg timotimo: I used 0bin: 0bin.net/paste/5SnxRUyMXpoUaXqX#3h...-NFXPF5dXS 21:51
21:52 todd joined
timotimo did you know that split takes an array of needles to split by? :D 21:52
i think your code may accidentally wrap around the right edge 21:53
Luneburg timotimo: What do you mean?
todd Hi All, on docs.perl6.org/language/control#for, I am not find a C style loop. I am looking for something like `for i=1 to 10 by 2`
timotimo m: "hello how are,you today,thanks,i'm,fine how about,you".split([" ", ","]).perl.say
camelia ("hello", "how", "are", "you", "today", "thanks", "i'm", "fine", "how", "about", "you").Seq
timotimo todd: c-style for is called "loop" in perl6 21:54
but what you can use for your example instead is the ... operator
m: for 1, 3 ... 10 { .say } 21:55
camelia 1
3
5
7
9
timotimo todd: ^
todd No wonder I couldn't find it. Thank you!
testing 21:56
timotimo Luneburg: consider what happens when your $i is at the end of the first line, it'll just keep increasing $i to look for the next value, but in doing so it will skip out of the right edge and into the left on the next line
Luneburg timotimo: Ah, I did notice that, but I don't think that should impact the result 21:57
timotimo you could output $i and which direction it was whenever you update $greatest-sum 21:58
i think that'd let us see if that happens or not 21:59
i just executed it on my machine as well and it looks like the code is gladly accessing past the end of the array, too 22:00
that's what the "use of uninitialized value of type Any in numeric context" message means
todd what am I doing wrong? `perl6 -e 'my @x=<a b c d e f>; loop (my $=2; $<4: $I++){say "@x[$Index]";}'` 22:01
Whitespace required before < operator at -e:1 ------> p (my $=2; $<4: $I++){say "@x[$Index]";}⏏<EOL> expecting any of: term
Luneburg timotimo: Ah, okay. But would that affect the final output value? I mean, it's going to multiple (Any) by a few numbers, but the product of that should not be greater than previous multiplications, since less than four numbers are being multipled together (ignoring the any)
timotimo todd: i think you forgot to give the loop variable a proper name 22:02
right, it'd end up being 0 for those undefined values
todd: otherwise it is exactly what it says, there would have to be a whitespace before the < operator. but you don't want to use just $ there, that's not helpful 22:03
todd fix a bunch of booboo, now it works: # perl6 -e 'my @x=<a b c d e f>; loop (my $I=2; $I < 4; $I++){say "@x[$I]";}' c d 22:04
Thank you!
b2gills Kaiepi: [1,1,*+*...*] keeps all of the previous values in memory. You probably want a one-shot sequence instead.
timotimo the thing is that $blah<foo> is syntax for a key lookup in $blah, but $ by itself is also a valid name for a variable - a special kind, but still 22:05
Luneburg timotimo: Thanks for the help, I'll edit the code and see if it works.
timotimo so $< will be parsed as accessing something hash-like and when it hits the end of the file it realizes "oh you didn't actually mean for all this to be the key to look up!" and tells you that a whitespace in front of the < would probably have made things right 22:06
b2gills todd: that is better written as `for @x[2..^4] { say ~$_ ; }` 22:07
todd The part of the array to be accessed wil be calculated. 22:10
22:11 HaraldJoerg left
todd perl6 -e 'my @x=<a b c d e f>; my $i=2; my $j=4; for @x[$i..^$j]{say "$_";}' ===SORRY!=== Error while compiling -e Missing block (whitespace needed before curlies taken as a hash subscript?) at -e:1 ------> i=2; my $j=4; for @x[$i..^$j]{say "$_";}⏏<EOL> 22:12
fix it: # perl6 -e 'my @x=<a b c d e f>; my $i=2; my $j=4; for @x[$i..^$j] {say "$_";}' c d 22:13
Thank you! 22:14
b2gills Also why not use `put` so you don't have to stringify it
todd wat the put to me? 22:16
b2gills `say "$_"` === `say ~$_` === `put $_` === `$_.put` === `.put`
kjk say I have a mysub that returns a sequence of Pairs, and I want to do: for mysub() -> $x, $y { ... }. how do I actually unpack the pairs into $x and $y there? 22:17
b2gills -> Pair ( :key($x), :value($y) ) {…}
22:17 AlexDani` joined
b2gills or just `-> ( :key($x), :value($y) ) {…}` 22:18
If you don't care about it being $x and $y `-> ( :$key, :$value ) {…}`
kjk b2gills: nice! thank you 22:19
22:19 Luneburg left, AlexDaniel left 22:20 AlexDani` is now known as AlexDaniel
Kaiepi <b2gills> Kaiepi: [1,1,*+*...*] keeps all of the previous values in memory. You probably want a one-shot sequence instead. 22:22
what's a one shot sequence?
b2gills 1,1,*+*...*
Kaiepi is that different from [1,1,*+*...*]? 22:23
b2gills m: my $seq = 1,1,*+*...*; for $seq[1..1000] { say $_ }
camelia Potential difficulties:
Useless use of ... in sink context
at <tmp>:1
------> 3my $seq = 1,1,*+*...7⏏5*; for $seq[1..1000] { say $_ }
MoarVM panic: Memory allocation failed; could not allocate 24 bytes
evalable6 (signal SIGKILL) Potential difficulties:
Useless use of ... in sink context
at /tmp/43f5_sTK6E:1
------> 031,1,*+*...08⏏04*
22:24
b2gills m: my $seq = (1,1,*+*...*); for $seq[1..1000] { say $_ } 22:26
camelia 1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
6765
10946
17711
28657
46368
75025
121393
196418
317811
514229
832040
1346269
2178309
3524578
5702887
9227465
14930352
24…
b2gills It needed () to parse it the expected way. It was parsing as `(my $seq = 1),1,*+*...*;` 22:27
Is there a reason you are skipping the first value?
m: my $seq = (1,1,*+*...*); for $seq.head(1000) { say $_ }
camelia 1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
6765
10946
17711
28657
46368
75025
121393
196418
317811
514229
832040
1346269
2178309
3524578
5702887
9227465
14930352…
b2gills m: my $seq = (1,1,*+*...*); say $seq.^name 22:28
camelia Seq
b2gills m: my $range = [1,1,*+*...*]; say $range.^name
camelia Array
Kaiepi so i should be using () instead of []? 22:30
b2gills Kaiepi: basically `1,1,*+*...*` creates a sequence (which starts off being one-shot). Putting [] around it turns it into an Array, which is never one-shot. In this case something is needed to cause it to parse the way you want, and the only thing () does is change the way things are parsed. 22:31
Kaiepi ahhh
ok that makes sense
thanks
are seqs lazy? 22:32
b2gills sequences are lazy if they are expected to be lazy
timotimo 001246 todd ? perl6 -e 'my @x=<a b c d e f>; my $i=2; my $j=4; for @x[$i..^$j]{say "$_";}' 22:33
b2gills (1,1,*+*...*) is lazy. (1,1,*+*...8) is not lazy. (1,1,*+*...9) is not lazy, and never terminates
timotimo oops, sorry about that
misclicked
22:35 rindolf left, dct joined
b2gills Kaiepi: Sequences don't generate values until asked. If it looks to be an infinite sequence it will be lazy. Sequences can always be marked as lazy by calling .lazy. 22:36
m: say (1,1,*+*...8).elems; # < doesn't error out␤ say (1,1,*+*...8).lazy.elems 22:37
camelia 6
Cannot .elems a lazy list
in block <unit> at <tmp> line 2
geekosaur heh
22:45 todd left 22:50 perlpilot joined 22:59 pecastro left
Kaiepi ah 23:01
23:02 mahafyi left 23:06 pecastro joined, zachk joined, zachk left, zachk joined 23:07 dataangel joined 23:09 Zoffix joined
Zoffix m: use Test; constant @iias6 = do { %(:foo, :bar) }; is-deeply @iias6.sort, (:foo, :bar).sort, 'def, statement (value)'; 23:09
camelia ok 1 - def, statement (value)
Zoffix m: use Test; constant @iias6 = do { %(:foo, :bar) }; is-deeply @iias6.sort, (:foo, :bar).sort, 'def, statement (value)'; ok ::('@iias6')
camelia ok 1 - def, statement (value)
The iterator of this Seq is already in use/consumed by another Seq
(you might solve this by adding .cache on usages of the Seq, or
by assigning the Seq into an array)
in sub proclaim at /home/camelia/rakudo-m-in…
Zoffix What Seq?
oh gee 23:10
m: use Test; constant @iias6 = do { %(:foo, :bar) }; dd @iias6
camelia (:foo, :bar).Seq
Zoffix k
23:10 Zoffix left 23:11 Zoffix joined 23:12 dct left 23:15 Zoffix left 23:21 Zoffix joined 23:40 llfourn left 23:41 wamba left 23:44 sauvin_ joined, sauvin left
kjk p6: sub s(-->Pair) { asdf => 123 if False }; s 23:53
camelia Type check failed for return value; expected Pair but got Slip (Empty)
in sub s at <tmp> line 1
in block <unit> at <tmp> line 1
kjk is that expected? 23:54
p6: sub s(-->Pair) { asdf => 123 if False; Nil }; s 23:56
camelia WARNINGS for <tmp>:
Useless use of "asdf => 123 " in sink context (line 1)
Zoffix kjk: yeah, an `if` without an `else` returns `Empty` if the condition is false
23:56 hami joined
Zoffix m: sub (*@args) { say @args }( (42 if True), (100 if False), (<meows> with 42), (<foos> without 42)) 23:57
camelia [42 meows]
Zoffix let's you write stuff like this
And also the way to conditionally "ninja-in" named params
kjk interesting, thanks for the explanation, Zoffix. 23:58
Zoffix m: my $foo; sub (:$foo = 'teh default') { dd $foo }( :$foo ) # If you do just this, the default doesn't get applied even tho `$foo` ain't got a proper value
camelia Any $foo = Any
Zoffix m: my $foo; sub (:$foo = 'teh default') { dd $foo }( |(:$foo with $foo) ) # But this works
camelia Str $foo = "teh default"
23:58 entonian joined
Zoffix |(:) <-- looks like a ninja, hence "ninja a named arg" :) 23:59
m: my $foo = 42; sub (:$foo = 'teh default') { dd $foo }( |(:$foo with $foo) ) # But this works
camelia Int $foo = 42