»ö« 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.
tobs m: sub prefix:<±> (Numeric $x) { $x|-$x }; say so 1/0 ~~ ±Inf; say so -1/0 ~~ ±Inf 00:00
camelia True
True
Elronnd I'm using this perl6intro.com/#_assignment_vs_binding and in the part about binding it says my $a; my $b; $b := $a. When I type that into the repl, it gives me an error message of "Cannot use bind operator with this left-hand side" 00:04
tobs Elronnd: try to write it all in one line 00:05
(I don't know why but then it doesn't throw over here)
benjikun m: my $a; my $b; $a := $b;
camelia ( no output )
timotimo yes, the REPL is often a bit wacky 00:06
Elronnd ok 00:07
benjikun Yeah, works fine if you type it out in a program in any way
Elronnd awww 00:09
it would be *really* nice if I could do $x := $y; $y = x + 1 and then evaluating $y leads to stack overflow 00:10
timotimo what you want is a symbolic math package
buggable: eco symbolic
buggable timotimo, Math::Symbolic 'Symbolic math for Perl 6': modules.perl6.org/dist/Math::Symbol...ub:raydiak
timotimo i believe this hasn't been updated in a while
benjikun I don't think he does
Elronnd can I have multidirectional bindings like $x := $y; $y := $z and then if I modify one both of the others are also modified? 00:13
timotimo binding means two variables now serve the same underlying object
so when you bind $x := $y and $y := $z, you'll have $x point at what $y used to have, but $y will now share only with $z 00:14
if you want all three to share the same thing, you need $x := $y; $z := $y
Elronnd ahh ok
benjikun m: my ($x, $y, $z); $y := $x; $z := $y; $x = 5; say $x, $y, $z; 00:16
camelia 555
AlexDani` . 00:25
Elronnd why is return type of a function with an arrow specified within the parens? why sub bla(x --> T), not sub bla(x) --> T? 00:42
AlexDaniel m: sub foo() returns Int { 42 }; say foo 00:43
camelia 42
Elronnd yeah but why with the arrow notation must it be within the parens?
AlexDaniel Elronnd: I guess a short answer is that it's part of the signature
m: sub foo(Str $x --> Int) {}; say &foo.signature 00:47
camelia (Str $x --> Int)
Elronnd junctions are neat
also the answer to the people who said if (x == 5 || 6 || 7) in another language (and thus potentially dangerous :P) 00:48
Zoffix m: sub prefix:<±> (Numeric $x) { $x|-$x }; say so 0/0 ~~ ±Inf; 00:49
camelia False
Zoffix m: sub prefix:<±> (Numeric $x) { $x|-$x }; say so $_ ≠ $_ with 0/0; 00:50
camelia True
Zoffix :)
timotimo Elronnd: you can have return type annotations in pointy block's signatures, too 00:51
timotimo m: my &bloop = -> $a, $b --> Int:D { $a + $b }; bloop(1, 2) 00:51
camelia ( no output )
timotimo m: my &bloop = -> $a, $b --> Int:D { $a + $b }; say bloop(1, 2)
camelia 3
Elronnd what's the difference between for bla -> \i and for bla -> $i? 01:25
timotimo $i will hold the value in "item context", and \i allows you to keep something in any context that it happens to already be in
Elronnd huh? 01:27
so \i will overwrite an existing $i if it exists, but $i will create a new $i just for this scope?
benjikun m: my $i = 1; -> \t { t++; }($i); say $i; 01:29
camelia 2
benjikun m: my $i = 1; -> $t { t++; }($i); say $i;
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared routine:
t used at line 1
benjikun m: my $i = 1; -> $t { $t++; }($i); say $i; 01:29
camelia Cannot resolve caller postfix:<++>(Int); the following candidates
match the type but require mutable arguments:
(Mu:D $a is rw)
(Int:D $a is rw)

The following do not match for other reasons:
(Bool:D $a is rw)
(Bool:U $a …
benjikun w/e I think you get the point
Elronnd yeah 01:30
tobs m: -> $s { say [+] $s }(1...10) ; -> \s { say [+] \s }(1...10) 01:44
camelia 55
10
tobs Elronnd: think that's the aspect timotimo talked about
can you figure it out? :) 01:45
Elronnd hmmm 01:46
m: -> \s { say \s}(1...10)
camelia \((1, 2, 3, 4, 5, 6, 7, 8, 9, 10).Seq)
Elronnd what is the ␤? 01:49
benjikun Newline
Elronnd m: say [+] \((1, 2, 3, 4, 5, 6, 7, 8, 9, 10).Seq)
camelia 10
benjikun `say` leaves a \n or newline on the end
Elronnd m: say [+] \((1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
camelia 10
Elronnd I do not understand 01:50
tobs btw, in addition to what you're reading, I recommend this advent calendar door perl6advent.wordpress.com/2017/12/...ntainers/. I for one read it three times since last Christmas
benjikun m: my $number = 0; sub foo(\n) { n += 5; }; foo($number); say $number; 01:52
tobs Elronnd: the 1...10 is a Seq. If you stuff it into a scalar container using the "-> $s" signature, it will be "itemized" and the [+] hyperop treats it as one single thing. Since + is a numeric operator, it will coerce the entire Seq into a number, in that case 10, the number of its elements.
camelia 5
tobs But if the argument is sigil-less, "-> \s", it won't be itemized and [+] treats it as the Seq it is and iterates over it, taking the sum 01:53
benjikun m: say [+] \(1, 2, 3); 01:54
camelia 6
benjikun m: say [+] \((1, 2, 3));
camelia 3
benjikun m: \((1, 2, 3)).elems 01:55
camelia ( no output )
benjikun m: say \((1, 2, 3)).elems
camelia 1
benjikun See why it did that now, Elronnd? 01:55
`\((1, 2, 3))` treats (1, 2, 3) as one item in the list 01:56
benjikun m: say \((1, 2, 3))[0]; 01:56
camelia (1 2 3)
benjikun I think that's what you were asking :P 01:58
Elronnd ohh ok I see now
m: say +\(1, 2, 3)
camelia 3
tobs hrm, I might have said something wrong? (not uncommon at 4am.) Seems it's not only the sigil-lessness in the signature but the \ when it's used. 02:00
tobs queues the fourth reading of the advent calendar 02:01
benjikun It's a capture thing 02:02
tobs I see! 02:03
benjikun m: my $a = \(1, 2, 3); say $a.WHAT;
camelia (Capture)
tobs so, what I said was complete bogus and even the wrong way around :-/ 02:06
benjikun :P 02:08
tobs m: -> $s { say "-$_-" for $s }(1...10) 02:12
camelia -1 2 3 4 5 6 7 8 9 10-
tobs m: -> \s { say "-$_-" for s }(1...10) 02:13
camelia -1-
-2-
-3-
-4-
-5-
-6-
-7-
-8-
-9-
-10-
tobs now I think what I said earlier applies to this example and before I'm proven wrong, I'll hit the hay o/ 02:14
benjikun night
Geth doc: 2dbf66ef11 | (Zoffix Znet)++ (committed using GitHub Web editor) | doc/Language/modules.pod6
Reword module installation info

To address concerns on github.com/perl6/doc/pull/2253
04:06
synopsebot Link: doc.perl6.org/language/modules
geekosaur contemplates a certain infamous StackOverflow in response to recent list mail 04:07
Zoffix hopes the snarky replies are not something P6 community will be known for :)
FWIW: my stock photos plan expires tomorrow. I still have 11 pics to download that must be downloaded tomorrow. If anyone thinks we need some stock for something, find it on depositphotos.com/ and gimme the URL to it (to the actual pic, not just search results). 04:08
I already got all I could think of and those 11 will likely go into generic stock that'll likely never get used anywhere. 04:09
(gonna be downloading stuff in ~16hr)
Elronnd geekosaur: which StackOverflow? 04:17
geekosaur stackoverflow.com/questions/1732348/ 04:19
Elronnd hah 04:20
I've always liked that one
Elronnd what does 'use v6' do? I've seen it on some online things 04:20
geekosaur mostly it catches you if you accidentally run it with perl 5, which will throw an error about an unsupported perl version 04:22
Kaypie how can i throw a custom exception when a nativecall sub returns an error, but can return two different kinds of errors? 04:27
Juerd Kaypie: You could write a wrapper function 04:52
TodAndMargo What is this error? 04:53
$ReturnStr = qqx ( curl $TimeOutStr -L $Url -o $FileName; echo \$\? );
Malformed UTF-8
How do I tell it I do not care what the character are going into $ReturnStr? 04:54
The file does download perfectly. The error occurs after the download 04:55
AlexDaniel TodAndMargo: are you sure that it is on that line? 04:58
TodAndMargo Malformed UTF-8 in sub CurlDownloadFile at /home/linuxutil/CurlUtils.pm6 line 52 04:59
52: $ReturnStr = qqx ( curl $TimeOutStr -L $Url -o $FileName; echo \$\? ); # Note qqx need a space before the (
AlexDaniel the reason I ask is because it seems like your stdout is just a number
and qqx shouldn't really catch stderr 05:00
so what is malformed there I'm not sure
anyway
TodAndMargo I want it NOT to catch the STDERR. Curl sends its progrss bar to StdErr.
AlexDaniel what about 05:01
TodAndMargo I just saw this: `/bin/sh: -o: command not found`
hmmmmmm
AlexDaniel $ReturnStr = run('curl', $TimeOutStr, '-L', $Url, '-o', $FileName).exitcode;
not only you don't have to echo anything to get exit code, but it's also bug free because there's no possibility for shell injection through $TimeOutStr, $Url and $FileName 05:02
TodAndMargo All I want is the exit code anyway. Thank you! 05:04
wait, what if I want both SteOut and the error code? 05:06
AlexDaniel my $proc = run(:out, 'curl', $TimeOutStr, '-L', $Url, '-o', $FileName); say $proc.exitcode; say $proc.out.slurp; 05:07
TodAndMargo: oh yea, I think I understand now. Your $TimeOutStr was interpreted by shell
so `/bin/sh: -o: command not found` totally makes sense 05:08
in general, it's easier to avoid `shell` and `qqx`
TodAndMargo my $TimeOutStr = " "; if $TimeOut { $TimeOutStr = "--connect-timeout $TimeOut"; }
TodAndMargo I want to see curl's progress bar 05:08
AlexDaniel ok it was $Url then and not $TimeOutStr :) 05:10
AlexDaniel maybe ‘&’ character or something like that 05:10
TodAndMargo Fixed it. It was the url.
$ReturnStr = qqx ( curl $TimeOutStr -L \'$Url\' --output \'$FileName\'; echo \$\? );
I had to single quote the url
AlexDaniel I… wouldn't call that a fix…
TodAndMargo curl really, really wants their url's in single quotes 05:11
AlexDaniel that has nothing to do with curl
it is about how shell is interpreting your single string that you gave it
TodAndMargo here is an example from firefox of downloading that same file: 05:12
curl --header 'Host: cdn09.foxitsoftware.com' --user-agent 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:58.0) Gecko/20100101 Firefox/58.0' --header 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' --header 'Accept-Language: en-US,en;q=0.5' --cookie 'FoxitWebsiteRef=25bcpOMBoY0h%2BI5u6Lqx48D6bh0Ek%2B9IVb4a94Dxl8yumDnG%2FCmGTXIXLQQGOHEvVk3OdA' --header 'Upgrade-Insecure-Requests: 1' 'cdn09.foxitsoftware.com
AlexDaniel if your $Url variable had a ' in it, it'd break immediately
that has nothing to do with curl, it's how shell works
TodAndMargo No single quotes in the url. No worries there
AlexDaniel also should have no single quotes in $FileName 05:13
I mean, you can avoid all that trouble by just using `run`
as simple as that
TodAndMargo a single quote in the file name wold drive me bananas! Since I am the one generating the $FileName, no worries there either 05:14
AlexDaniel my $proc = run(:out, 'curl', ($TimeOut ?? "--connect-timeout $TimeOut" !! Empty), '-L', $Url, '-o', $FileName); say $proc.exitcode; say $proc.out.slurp; 05:16
there
works perfectly, no need to backslash a bunch of stuff
no need to double check that your stuff doesn't have “disallowed symbols” 05:17
doesn't pass anything through shell so just a tiny bit more efficient too
moritz "--connect-timeout $TimeOut" will pass a single arg, needs «...» instead 05:18
TodAndMargo run kills my progress meter from curl 05:19
AlexDaniel moritz: ah, yeah. I was also thinking maybe --connect-timeout=5 but curl doesn't support that?
TodAndMargo This is my debug before calling qxx 05:20
TimeOutStr = <--connect-timeout 6600> Url = <www.foxitsoftware.com/downloads/la...nglish> FileName = </home/CDs/WindowsInternet/PDF/FoxitReader-9.2.0.9297_Setup_Prom_IS.exe>
AlexDaniel TodAndMargo: I just tried it and I can see stderr without any issues 05:21
TodAndMargo Did you see it count across the screen? 05:22
AlexDaniel TodAndMargo: for a different URL, yes 05:23
TodAndMargo How do I talk to you guys on HexChat? I could not find where to put the address in.
TodAndMargo Huh. Mine is totally blank is I use run 05:23
AlexDaniel my $TimeOut = 6600; my $Url = ‘www.foxitsoftware.com/downloads/la...=English’; my $FileName=‘foo’; my $proc = run(:out, ‘curl’, ($TimeOut ?? (‘--connect-timeout’, $TimeOut) !! Empty), ‘-L’, $Url, ‘-o’, $FileName); say $proc.exitcode; say $proc.out.slurp 05:26
evalable6 % Total % Received % Xferd Average Speed Time Time Time Current
AlexDaniel, Full output: gist.github.com/6c8a5468fc4f38448f...27bc690d75
AlexDaniel heh, poor evalable6 :D
AlexDaniel ↑ although here you don't need stdout I think 05:27
TodAndMargo Huh? Thank you! 05:28
TodAndMargo Oh I get it. I wrote my own call to "run" where I run it together without the segments. I always return all three, which is why I am not seeing it. 05:29
xinming_ Hi, I''m a bit curious, why will the - be better to use as a delimiter? I'm feeling strange, before in perl5, I always use _ as the delimiter for subs, But after I switched to perl6, it supports - and I can get used to it really fast, and then, I feel - is a better delimiter. 05:32
What is the reason behind all this?
curious the reason behind why - is better for human to accept 05:33
:-)
TodAndMargo I'm confused 05:35
AlexDaniel xinming_: because it is a we-use-it-all-the-time-in-English delimiter? :) 05:36
xinming_: and you_never see_text_like_this 05:37
benjikun I don't think that's proper use of `-` if you want to use it by the english-way-of-using-it 05:38
:P
`_` substitutes a space in my mind 05:39
tbh either one works fine, just separates words
xinming_ benjikun: I know they both worked fine. But as a Chinese, before, I always use _ for word delimiter. 05:40
benjikun I use _ when I'm doing lower-level languages 05:41
xinming_ so, to me, _ and - are almost the same. I learnt lisp, But never programming much in it, it uses - as delimiter, I don't feel the difference. After came to perl6, I can choose both _ and -, And after using -, I feel that I don't like the _ anymore.
benjikun and likeThis for higher level ones
fooBar 05:42
xinming_ so, it makes wonder, what caused me that - is better.
I don't like the likeThis as function name. to me, It's worse than like_this. :-)
benjikun :P
I've gotten used to either way 05:43
maybe you like `-` more because it's more vertically symmetrical
xinming_ maybe
AlexDaniel benjikun: why not? Who defines what I can and cannot use as a compound adjective? Are you going to call the compound adjective police? :) 05:44
but yeah maybe you're right :P
TodAndMargo What am I doing wrong here. I kow that the caret before the \d is the issue, but why? 06:05
p6 'my $x="8627-2.2.19882.exe"; if $x ~~ m/ ^\d "-" (.*?) .exe / {say "Found"};'
Never mind. I forgot the + ^\d+ 06:06
Any idea why this is failing: 06:21
ShortEntry =<4626-2.2.19882.exe> BaseTag =<\d+> Extension = <.exe>
PrintGreenErr( "ShortEntry =<$ShortEntry> BaseTag =<$BaseTag> Extension = <$Extension>\n" ); if $ShortEntry ~~ m/ ^$BaseTag "-" (.*?) $Extension / {
This works: PrintGreenErr( "ShortEntry =<$ShortEntry> BaseTag =<$BaseTag> Extension = <$Extension>\n" ); if $ShortEntry ~~ m/ ^$BaseTag "-" (.*?) $Extension / {
ops: $ p6 'my $x="8627-2.2.19882.exe"; if $x ~~ m/ ^\d+ "-" (.*?) ".exe" / {say "Found"};' Found 06:22
Elronnd I have a function sub print-and-copy(Str $s) {, and the compiler is choking up on the '$s' with "Variable '$s' is not declared" 06:27
wtf??
m: sub print-and-copy(Str $s) { say $s; }
camelia ( no output )
araraloren_ TodAndMargo ShortEntry =<4626-2.2.19882.exe> , This is the code ? 06:28
Elronnd wait, hmm, no
sorry, I fucked up, figured it out 06:29
TodAndMargo `4626-2.2.19882.exe` is the string being tested.
araraloren_ m: my $BaseTag = "\d+"; my $Extension = ".exe"; say "8627-2.2.19882.exe" ~~ m/ ^$BaseTag "-" (.*?) $Extension /; 06:31
camelia 5===SORRY!5=== Error while compiling <tmp>
Unrecognized backslash sequence: '\d'
at <tmp>:1
------> 3my $BaseTag = "\7⏏5d+"; my $Extension = ".exe"; say "8627-2
expecting any of:
double quotes
term
araraloren_ you mean this ?
araraloren_ m: my $BaseTag = '\d+'; my $Extension = ".exe"; say "8627-2.2.19882.exe" ~~ m/ ^$(BaseTag) "-" (.*?) $Extension /; 06:33
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared name:
BaseTag used at line 1
araraloren_ m: my $BaseTag = '\d+'; my $Extension = ".exe"; say "8627-2.2.19882.exe" ~~ m/ ^$($BaseTag) "-" (.*?) $Extension /;
camelia False
araraloren_ m: my $BaseTag = '\d+'; my $Extension = ".exe"; say "8627-2.2.19882.exe" ~~ m/ ^$BaseTag "-" (.*?) $Extension /;
camelia False
araraloren_ m: my $BaseTag = '\d+'; my $Extension = ".exe"; say "8627-2.2.19882.exe" ~~ m/ ^<$BaseTag> "-" (.*?) $Extension /; 06:34
camelia 「8627-2.2.19882.exe」
0 => 「2.2.19882」
TodAndMargo It does not bomb out. It just says false 06:35
araraloren_ Do you mean using $BaseTag as a pattern, not a literal ?
I am not very understand what you want to do 06:36
you should take a look at docs.perl6.org/language/regexes#Re...erpolation
TodAndMargo the <> seemed to fix it. I am looping through a list of entires in a directory and pushing onto a stack the ones that pass the testa 06:38
araraloren_ yeah, if you want using the string as regex pattern, you should using <> 06:39
TodAndMargo Thank you! 06:40
araraloren_ but notice the document said, it causes implicit EVAL
Elronnd I don't mean to presume, and it's ok if not, but would anyone mind looking over this small script that I made and noting if I'm doing something unidiomatic? github.com/Elronnd/Uploader/blob/m.../upload.p6 07:03
nasm silly noob question, does `Str $arg -> Str` define a parameter of type `Str -> Str` named `$arg` or name a type where the parameter has the name `$arg`? 07:12
araraloren_ nasm I don't think so 07:16
there is not XX -> XX in Perl 6 , I think
nasm oh. there's no type constructor for functions? 07:17
moritz what's a type constructor?
moritz is a typo constructor
nasm I'm borrowing terms from other languages, sorry. It's kind of like a type, except parameterized. Like `'a list` (ML) or `List<a>` (C++/Java) 07:18
list or List is the type constructor
Elronnd how is that different from a normal constructor? 07:19
nasm constructor as in data constructor or the magical almost-method that builds objects? 07:20
Elronnd the difference being?
benjikun nasm: Is this what you're talking about? wiki.haskell.org/Constructor#Type_constructor 07:21
nasm yes. I was just kinda surprised at the syntax `Str $msg --> Str` for declaring a parameter that happens to be a function instead of having a more complex type appearing to the left and was trying to figure out what was going on. 07:23
nevermind, I misinterpreted the syntax completely. sorry. 07:24
benjikun `--> Str` means the function returns a Str
TodAndMargo is there a way to write `if a || b` and not evaluate b if a passes? 07:29
benjikun Does it TodAndMargo? 07:30
m: sub a { return True }; sub b { say "CALLED B" }; if a() || b() { say "." } 07:31
camelia .
TodAndMargo not sure what you said. 07:32
araraloren_ Elronnd It's pretty good, but I recomend you using MAIN to write the script
benjikun not sure what you mean
araraloren_ m: if 1 || do {"called".say;} { say "True"; } 07:33
camelia True
Elronnd TodAndMargo: the answer is yes, and that's to write `if a || b` 07:34
araraloren_: ok, thanks
araraloren_ TodAndMargo so what do you mean ?
TodAndMargo I have a test. If the first part passes, I do not want it to evaluate the second part as it will throw an error. It will only not throw an error if the first part fails 07:38
Elronnd yes, you can just use || because it already does that
TodAndMargo Unrecognized regex metacharacter - (must be quoted to match literally) at /home/linuxutil/EVAL_4:1 ------> anon regex { CimTrak⏏-Enterprise-Server} 07:39
Elronnd (this is a common practice in c to prevent null dereferences -- if (x && x->arr && x->arr[0] == bla))
araraloren_ Elronnd in Perl 6 we have .? for that 07:47
Elronnd that is simultaneously really nice and infuriating 07:49
because it's ?. in kotlin
benjikun lol
Elronnd now, I've never done any serious programming in kotlin, but I went through the official tutorial and that's the part I remember
TodAndMargo I had to install some escapes to fix the issue `( my $EscBaseTag = $BaseTag ) ~~ s:global/ "-" /\\-/;` 07:55
Geth doc: 8e211b7f4e | (JJ Merelo)++ | doc/Language/faq.pod6
Reflow

This also closes #2245 after successful upgrade. Should be working pretty soon.
08:10
synopsebot Link: doc.perl6.org/language/faq
Geth doc: d43e7a7ef3 | (JJ Merelo)++ | doc/Type/Int.pod6
Improves and adds examples, refs #2256
08:46
synopsebot Link: doc.perl6.org/type/Int
doc: 479add6b96 | (JJ Merelo)++ | 2 files
Adds polymod for Real, closes #2256
araraloren_ Hi, How I quit from a supply block ? 11:32
like I can `done` in that 11:33
timotimo `quit` should quit, otherwise throw an exception i guess? 11:45
jnthn araraloren_: Just throw an exception 12:11
Any unhandled exception in a Supply block will be a quit
*supply
araraloren_ yeah, I see 12:12
and I have a trouble right now
evalable6: gist.githubusercontent.com/araralo...-supply.p6
evalable6 araraloren_, Successfully fetched the code from the provided URL
(signal SIGHUP) called
«timed out after 10 seconds»
araraloren_ with the first tap, the code hang on
Is something I am missing ? jnthn 12:13
It'll be fine if I add a done nameargument to the tap
sorry quit 12:14
evalable6: gist.githubusercontent.com/araralo...-supply.p6
evalable6 araraloren_, Successfully fetched the code from the provided URL
(exit code 1) 04===SORRY!04=== Error while compiling /tmp/zwWas44dzI
Undeclared routine:
ex used at line 19
araraloren_ evalable6: gist.githubusercontent.com/araralo...-supply.p6 12:15
evalable6 araraloren_, Successfully fetched the code from the provided URL
(exit code 1) called
An operation first awaited:
in block <unit> at /tmp/aC1EyvPbn_ line…
araraloren_, Full output: gist.github.com/173c5372eb6876cf82...e399db0cce
jnthn araraloren_: Not sure what's happening there, maybe worth filing a Rakudo issue about. But I'd probably write it like this: gist.github.com/jnthn/d91b387c56d6...3a23ddca21 12:26
Which works
araraloren_ jnthn cool 12:27
I will setup a issue about that
Geth marketing: fb6358672b | (Zoffix Znet)++ | 11 files
Add new stock
14:21
Geth doc: cd5e7a1876 | Coke++ | doc/Type/Any.pod6
remove dupe word
16:08
synopsebot Link: doc.perl6.org/type/Any
xinming For a non-required named params, Is it possible to set the default value for it? 17:07
timotimo of course 17:08
m: sub no-need-for-names(:$name = "Unnamed") { say "the name is $name" }; no-need-for-names(name => "timo"); no-need-for-names() 17:09
camelia the name is timo
the name is Unnamed
xinming Got it, thanks
Xliff Is there a better way to set proper usage than the following: sub MAIN(Int $num where 1..3) { 18:50
} --> Usage:
examples/pack_example.pl6 <num>
It works, but the usage message could be better defined. 18:51
Ulti Xliff you can do #`() comments on the parameters iirc 18:55
Ulti also sub USAGE lets you edit the string thats produced 18:55
Ulti also #|(comment) for the actual MAIN if its a multi means you get docs for each command use 18:56
timotimo m: subset OneToThree of Int where 1..3; sub MAIN(OneToThree $value) { } 19:09
camelia Usage:
<tmp> <value>
timotimo hm, i thought it'd put the type name there
Xliff Util: Thanks! I will have to remember that. Is there a writeup on how that should work? 19:18
Somewhere in the docs?
m: subset OneToThree of Int where 1..3; sub MAIN(OneToThree $value #`(1..3) ) { }
camelia Usage:
<tmp> <value>
Xliff Ulti ^^
AlexDaniel .tell Skarsnik rt.perl.org/Public/Bug/Display.htm...xn-1573999 19:28
yoleaux AlexDaniel: I'll pass your message to Skarsnik.
Ulti Xliff: yeah if you search for USAGE I think you get to the right bit of the docs 19:39
xinming What module is recommend to get http data? LWP::Simple? 20:04
timotimo i think HTTP::UserAgent, or if you need some advanced stuff maybe Cro::HTTP has what you need 20:05
if you want something simple, go with WWW
xinming Thanks 20:06
Xliff You will find that as your project grows, you will need more of the features in Cro::HTTP than from any other module. 20:21
So if you are doing more than get requests, take the time to deal with the learning curve. It's not that hard.
xinming ^^ 20:22
xinming Xliff: Thanks, Will try all of them. :-) 20:30
pochi what's the correct way to implement stingification of objects? 20:32
MasterDuke pochi: give them a .Str method 20:43
pochi MasterDuke: doesn't seem to work 20:48
MasterDuke m: class Foo { method Str() { "I am a Foo" }; }; my $a = Foo.new; say "I am a human, but |$a|" 20:58
camelia I am a human, but |I am a Foo|
pochi hm, I did it a bit different
m: class Foo { method Str() { "I am a Foo" }; }; my $a = Foo.new; say $a; 20:59
camelia Foo.new
MasterDuke m: class Foo { method Str() { "I am a Foo" }; }; my $a = Foo.new; say ~$a 21:00
camelia I am a Foo
geekosaur pochi, "say" uses .gist 21:00
pochi but it had to do something to come up with "Foo.new" too?
geekosaur so define method gist if you want to override that 21:01
pochi there are two methods to stringify?
geekosaur one is actual stringification, the other is "produce something compact for human consumption"
pochi isn't that the same thing?
geekosaur no? 21:02
pochi put some characters on screen representing this object please
geekosaur stringify is the whole thing. if youre wokring with an HTML document, there;s a difference between rendering it and giving you the HTML as text
pochi yeah, but in this context both are text, no?
geekosaur .Str should produce the whoole thing in some form useful for other functions, .gist should produce a summary ("the gist of it") for people
pochi but I want stringification to be the same, no matter if you quote it or dont 21:04
MasterDuke m: class Foo { method Str() { "I am a Foo for a computer" }; method gist() { "I am a Foo for a human" }; }; my $a = Foo.new; say $a; say ~$a
camelia I am a Foo for a human
I am a Foo for a computer
MasterDuke m: class Foo { method Str() { "I am a Foo for a computer" }; method gist() { self.Str }; }; my $a = Foo.new; say $a 21:05
camelia I am a Foo for a computer
MasterDuke m: class Foo { method Str() { "I am a Foo for a computer" }; method gist() { self.Str }; }; my $a = Foo.new; say ~$a
camelia I am a Foo for a computer
pochi thanks. that should be the default in my opinion 21:06
geekosaur yes, just like everyone knows encodings don;t exist, all text is magically in their locale 21:10
MasterDuke e: my @a = ^1_000; say @a; say ~@a
evalable6 [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 …
MasterDuke, Full output: gist.github.com/26730a6909821d5ada...8b326d0eb0
geekosaur "it's a difference I don;t happen to care about right now, its a difference nobody ever should care about" 21:11
MasterDuke pochi: ^^^ stuff like that is why there's both
geekosaur right up until you do need it and wonder why things don't work
pochi I would expect the same result for say @a and say ~@a 21:13
MasterDuke but what's the point of printing out its contents (in the context where you assume a human is looking at them) when it's that big? 21:15
geekosaur sigh
geekosaur has three channels all showinbg different forms of people unable to think past their own navels. lovely 21:16
MasterDuke e: my @a = ^1_000; put @a
evalable6 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 3…
MasterDuke, Full output: gist.github.com/4e5289a091ad9d495f...c0d3ef99e2
pochi MasterDuke: that's not the point I was arguing though
MasterDuke pochi: put uses .Str
pochi what? 21:17
I thought there only were two, say and print ...
pochi so put @a and put ~@a outputs the same thing then 21:19
which makes sense
geekosaur to you, now
but then you've been studiously ignoring any possibility that your right now might not be right for all cases
pochi as does print @a and print ~@a it seems
so only say @a and say ~@a differs 21:20
MasterDuke docs.perl6.org/type/Mu#method_print and the next two entries (put and say) explain the differences
pochi ah, so it says not to use "say" 21:21
MasterDuke say does some other niceties, like sort hashes 21:24
lizmat waves from Glasgow 23:00
benjikun waves from North Carolina lol 23:04
lizmat \o/ 23:14