»ö« 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 moritz on 22 December 2015. |
|||
00:10
wamba left
00:12
BenGoldberg joined
00:15
Cabanossi left,
nadim left
00:17
Cabanossi joined
00:39
pierre_ joined
00:53
r3m left,
r3m joined
00:57
Actualeyes left
01:00
dct left
01:03
mcmillhj joined
01:08
mcmillhj left
01:14
mcmillhj joined
01:18
mcmillhj left
01:24
k-man joined
01:29
mcmillhj joined
01:36
mcmillhj left
|
|||
Geth | ecosystem: CurtTilmes++ created pull request #336: Add DBI::Async to ecosystem |
01:37 | |
01:38
xfix left
01:40
xfix joined
01:42
labster left
01:46
ilbot3 left
01:47
mcmillhj joined
01:48
ilbot3 joined,
ChanServ sets mode: +v ilbot3
01:52
aborazmeh joined,
aborazmeh left,
aborazmeh joined
01:54
mcmillhj left
02:00
labster joined
02:01
mcmillhj joined
02:04
itaipu left
02:06
mcmillhj left
02:15
Cabanossi left
02:17
mcmillhj joined,
Cabanossi joined
|
|||
grondilu | m: class { has Num method foo { rand } }.new.foo.say | 02:22 | |
camelia | 0.157018793505413 | ||
grondilu | ^TIL new method syntax apparently | 02:23 | |
02:26
mcmillhj left
02:30
kurahaupo joined
02:35
kurahaupo left
02:36
mcmillhj joined
02:41
mcmillhj left
02:44
dj_goku left
02:53
mcmillhj joined
02:58
mcmillhj left
03:00
stmuk joined
03:01
stmuk_ left
03:02
wamba joined
03:05
dj_goku joined
03:09
stmuk_ joined
03:10
stmuk left
03:25
aborazmeh left
03:27
pierre_ left
03:28
pierre_ joined
03:29
Cabanossi left
03:32
Cabanossi joined
03:33
pierre_ left
03:45
pierre_ joined
03:53
Actualeyes joined,
kurahaupo joined
03:55
Actualeyes left
03:56
kurahaupo_ joined
03:58
pierre_ left
03:59
pierre_ joined
04:01
kurahaupo__ joined,
Cabanossi left
04:02
Cabanossi joined
04:03
pierre_ left
04:04
Resol joined,
kurahaupo left
04:05
kurahaupo joined
04:06
kurahaupo_ left
04:07
kurahaupo left,
kurahaupo__ left
04:08
kurahaupo joined,
wamba left
04:19
skids left
04:22
BenGoldberg left
04:28
tharkun left
04:35
stmuk joined
04:37
stmuk_ left
04:41
tharkun joined
04:52
curan joined
05:08
kurahaupo_ joined
|
|||
Geth | ecosystem: a88b802059 | (Curt Tilmes)++ | META.list Add DBI::Async to ecosystem See github.com/CurtTilmes/perl6-dbi-async |
05:11 | |
ecosystem: 33b8477a85 | (Juan Julián Merelo Guervós)++ (committed using GitHub Web editor) | META.list Merge pull request #336 from CurtTilmes/master Add DBI::Async to ecosystem Thanks! |
|||
05:11
kurahaupo left
05:12
pierre_ joined
05:14
xtreak joined
05:17
wamba joined
05:31
mcsnolte left,
bioexpress joined
|
|||
bioexpress | Hello, how could I remove a module from the ecosystem? | 05:32 | |
gfldex | bioexpress: you send a PR to the ecosystem with the line in question removed | ||
bioexpress | Thx! | 05:33 | |
What's a PR? | 05:34 | ||
gfldex | pullrequest | 05:35 | |
05:35
anton_p joined
|
|||
bioexpress | Thx | 05:37 | |
samcv | wow... | 05:41 | |
person on libtommath github issue says that i should fork the project and change the LICENSE file | |||
and show my lawyers my fork with me having changed the license. | 05:42 | ||
gfldex | please don't feed the troll | ||
samcv | yeah cause... that's how things work in the real world. you can just lie about softwares licenses by editing the LICENSE file | ||
they are a 'Member' :( | |||
and they think the WTFPL is better than CC0 because it uses less words | 05:43 | ||
github.com/libtom/libtommath/issue...-298826328 :\ | |||
wow i'm reading the complaints of the maker of WTFPL about CC0 and they're pretty much what the person just posted | 05:48 | ||
that how did it take them 1000 words to write that they person could use the software however they want. seems sam hocevar misses the point of licenses | 05:49 | ||
05:49
wamba left
|
|||
samcv | "Your honor, this license is really short. therefore i can't possibly be infringing on any copyright here. this one sentence obviously cannot be interpreted any other way. if the license fits into a small number of words you must acquit"" | 05:51 | |
said by nobody ever. | |||
well acutalyl probably not. but. maybe a few peolpe. but they' probably didn't win their cases | |||
can't say nobody would say that since sam hocevar obviously seems to say exactly that | |||
Geth | ecosystem: kuerbis++ created pull request #337: Update META.list |
05:52 | |
05:53
CIAvash joined
05:55
bioexpress left
05:57
xinming_ left
06:00
CIAvash left,
Cabanossi left
06:02
Cabanossi joined
06:04
ufobat joined,
xinming joined
|
|||
u-ou | what does this mean? Cannot resolve caller Numeric(Player+{Wolf}: ); none of these signatures match: | 06:05 | |
Geth | ecosystem: 9c7a681e0a | kuerbis++ (committed using GitHub Web editor) | META.list Update META.list Removed Term-Form-p6 |
||
ecosystem: d4225a208f | (Juan Julián Merelo Guervós)++ (committed using GitHub Web editor) | META.list Merge pull request #337 from kuerbis/master Update META.list Thanks for the submission. Why did you remove it? |
|||
samcv | u-ou, can paste full error? | 06:06 | |
gfldex | u-ou: it means that neither Player nor Wolf got a Numeric method to turn it into a number. You likely used an operator that requires a number. | ||
u-ou | there's only one more line: (Mu:U \v: *%_) | 06:07 | |
06:09
domidumont joined
|
|||
u-ou | that's weird. it happens when I compare an array of them's .elems with < | 06:09 | |
but that shouldn't try to turn any of them into a number | |||
06:13
xinming left
06:14
domidumont left
06:15
domidumont joined
06:17
xinming joined
06:19
xtreak left,
xtreak joined
06:20
xtreak left
06:21
xtreak joined
|
|||
samcv | so it's $wold.elems < 10 | 06:22 | |
or something like that? | |||
could always add a Numeric method \-/ shrug | |||
06:23
itaipu joined
|
|||
sammers | hi all | 06:26 | |
06:32
xtreak left
|
|||
u-ou | it happens without that line, too, so it seems to be happening in the background. I will post it on github sometime to show you if I can't work it out. | 06:32 | |
06:33
xtreak joined
|
|||
u-ou | the program is across many files | 06:33 | |
06:37
xtreak left
06:42
lowbro joined,
lowbro left,
lowbro joined
06:55
lizmat joined
06:56
wamba joined
07:00
xtreak joined
07:07
wamba left
07:10
xtreak left
07:14
xtreak joined
07:19
espadrine_ joined
07:27
espadrine_ left
07:29
nadim joined
07:30
xtreak left
07:34
pierre_ left
07:45
labster left
07:46
pierre_ joined,
xtreak joined
07:50
labster joined
07:52
robertle left
07:53
darutoko joined
07:55
parv joined
08:00
itaipu left
08:02
lizmat left
08:03
wamba joined
08:07
zakharyas joined
08:08
nadim left,
domidumont left,
nadim joined
08:09
domidumont joined
08:11
mcmillhj joined
08:15
bjz joined
08:16
Cabanossi left,
mcmillhj left
08:17
Cabanossi joined
08:20
dakkar joined
08:27
mcmillhj joined
08:31
jonas1 joined
08:32
mcmillhj left
08:46
Cabanossi left
08:47
Cabanossi joined
08:48
pierre_ left
08:56
rindolf joined
08:59
kurahaupo_ left
09:00
xtreak left
09:02
pierre_ joined
09:08
rindolf left
09:13
Ven joined,
Ven is now known as Guest98555
09:19
labster left
09:23
john51 left,
john51_ joined,
rindolf joined
09:25
kurahaupo_ joined
09:39
xtreak joined
09:45
AlexDani` joined,
Cabanossi left
09:46
Actualeyes joined
09:47
Cabanossi joined
09:48
pierre_ left
09:49
AlexDaniel left
09:52
pierre_ joined,
Guest98555 left
09:55
Ven joined
09:56
Ven is now known as Guest51495
09:57
AlexDani` left,
AlexDani` joined
10:02
kurahaupo` joined
10:05
kurahaupo_ left
10:06
kurahaupo` left
10:07
salva joined
10:08
Guest51495 left
10:09
domidumont left
10:11
Ven_ joined
10:17
bjz_ joined
10:18
anton_p left,
bjz left
10:30
AlexDani` is now known as AlexDaniel
10:31
rindolf left
10:34
ChoHag joined
|
|||
nadim | good morning, a few questions about named arguments. s(:argument) would set argument to True, how is is set to false? named arguments can be :argument(values), is it possible to write argument:value someway? | 10:37 | |
moritz | nadim: s(:!argument) sets it to False | ||
argument:value isn't supported, argument => value is | |||
10:38
pierre_ left
|
|||
nadim | moritz: thanks, I always forget about :! . Just to satisfy my curiosity, apart the fact that we had fat commas in P5, do you know if and why argument:value was a candidate? | 10:43 | |
moritz | nadim: no, my historic knowledge doesn't stretch that far back | ||
10:44
ChoHag left
|
|||
timotimo | speaking from a "right now" standpoint, argument:value doesn't work because there could be a sub named &argument:value | 10:45 | |
m: sub argument:value { say "not what you wanted" }; sub takes-named-argument(*@, :$argument) { say "$argument" }; takes-named-argument(argument:value) | |||
camelia | not what you wanted Use of uninitialized value $argument of type Any in string context. Methods .^name, .perl, .gist, or .say can be used to stringify it to something meaningful. in sub takes-named-argument at <tmp> line 1 |
||
10:52
parv left
10:56
nadim left
11:00
nadim joined
11:01
Cabanossi left
11:02
Cabanossi joined
11:11
bjz joined
11:12
bjz_ left
11:13
TEttinger left
11:21
xiaomiao left
11:23
xiaomiao joined
11:27
xinming left
11:28
xinming joined
11:45
Cabanossi left
11:47
Cabanossi joined
11:57
abraxxa joined
|
|||
AlexDaniel | freaking pulseaudio… why is everything so clicky | 11:59 | |
timotimo | it's not getting enough cpu time? | 12:00 | |
AlexDaniel | it happens whenever something changes | ||
e.g. if I change the volume, or I start something else | |||
timotimo | when i play synthesia and have qsynth on, i need to give qsynth and pulseaudio a lower nice value otherwise it'll go into crackly-staticy mode every minute or two | 12:01 | |
(synthesia on wine is a performance trainwreck) | |||
AlexDaniel | while I can ignore these occasional clicks, I can't understand why the hell would I experience this in 2017 | ||
timotimo | it's got a little animation in the mode select menu where little circles go 'round a button and it chews through cpu like nobodys business | ||
AlexDaniel | thing is, I can just uninstall pulseaudio and things will go back to normal | 12:02 | |
except that I'd have to find a different web browser | |||
fucking hell… | |||
12:04
wamba left
12:05
ChoHag joined
12:06
daxim joined,
itaipu joined
12:08
Ven_ left
12:11
Ven joined
12:12
Ven is now known as Guest31589
12:21
rindolf joined
12:23
Guest31589 left
12:24
raschipi joined
|
|||
Ulti | found a little bug in the docs.perl6.org it doesnt URL encode/decode search strings so you can get something like docs.perl6.org/routine/%% as a bad request | 12:25 | |
what repo has that stuff in? | |||
is it just perl6/doc | 12:26 | ||
AlexDaniel | Ulti: yes | ||
12:27
Ven_ joined
|
|||
Ulti | k k | 12:27 | |
will take a look | |||
12:28
Ven_ left
12:29
Ven_ joined
12:34
wamba joined
12:38
rindolf left
|
|||
Voldenet | I've got some perl5 code, what's the simplest way (modules would be nice) to make it perl6-friendly: ix.io/szS | 12:41 | |
I'm thinking of using HTTP::Server::Async | |||
timotimo | yeah, your code currently looks like a cgi script | ||
Voldenet | Yeah, it's a pretty much a trivial cgi script. | 12:42 | |
s/a pretty much/pretty much/ | |||
timotimo | painful how much boilerplate it has, but other than the boilerplate it uses no modules at all | ||
Voldenet | welp, that's cgi for you :P | ||
timotimo | still better than "use CGI" | 12:43 | |
Voldenet | Yeah, sadly | ||
Ulti | probably narrowed it down to github.com/perl6/doc/blob/eaa4d3dd...fy.p6#L765 needing to replace % with %25 not just the \ to %5c really just put in a full percent encode maybe | ||
12:43
haxmeister joined
12:45
mcmillhj joined
|
|||
Ulti | weird URI escape should be doing all this | 12:45 | |
hmmm | |||
12:45
pierre_ joined
|
|||
Ulti | aha! %2525 | 12:46 | |
heh | |||
Voldenet | Hm, I guess using perl6 with cgi is a really bad idea, because of script compilation time | ||
timotimo | yeah, there's way better ways to go about this | 12:48 | |
Voldenet | I could just use fcgi or http | ||
12:48
domidumont joined
|
|||
Voldenet | Well, http has less code smell, that's for sure | 12:48 | |
but I wonder how does HTTP::Server::Async compare to nginx | 12:49 | ||
timotimo | i usually install services behind a mod_proxy-alike | ||
Voldenet | mod_proxy http or mod_proxy fcgi? | 12:51 | |
timotimo | http | ||
we do have SCGI or something, though? | 12:52 | ||
12:55
domidumont left
|
|||
Voldenet | hm, gonna do some ab on the http to compare | 12:55 | |
12:56
ChoHag left
|
|||
Voldenet | hmm nginx: Requests per second: 38372.99 [#/sec] (mean), HTTP::Server::Async: Requests per second: 36.97 [#/sec] | 12:59 | |
tyil | thats | 13:00 | |
Voldenet | :( | ||
tyil | a slight difference | ||
13:00
Cabanossi left
|
|||
timotimo | yup | 13:00 | |
moritz | in both cases talking to a database likely exceeds the offset from the web server | 13:01 | |
Voldenet | Unless you're serving static content as well | ||
moritz | right, but you'd configure your web server to do that in any realistic production scenario | 13:02 | |
timotimo | yeah, always use a proper file server to serve static content | ||
13:02
Cabanossi joined
|
|||
timotimo | er | 13:02 | |
web server | |||
Voldenet | Well, it makes sense to proxy only dynamic api requests to the dynamic server. | ||
moritz | that's the advice even if using a rather mature app server, like p5/mojolicious/hypnotoad | ||
Voldenet | but then, nginx + cgi: Requests per second: 261.31 [#/sec] (mean) | 13:03 | |
hmmm, 40 rq/s on dedicated http server does not sound very realistic | 13:04 | ||
haxmeister | I have a question regarding this statement | 13:06 | |
By separating identifiers with double colons, the right most name is inserted into existing or automatically created packages. | |||
does that mean if I use the double colon syntax when there are no packages other than the main file.. it will create a namespace/package that matches my identifier? | 13:07 | ||
Voldenet | Okay, I've used HTTP::Server::Tiny and it does 260rq/s - it's better | 13:09 | |
haxmeister: I think it means that you don't have to create 3 folders and 3 files per folder, just 3 folders and the module when it should be | 13:11 | ||
so A::B::C::D would require only A/B/C/D.pm6 | |||
and the A A::B A::B::C would be autogenerated | |||
haxmeister | ugh.. I'm lost in that.. I need to read more, I don't seem to understand the usage and intent of addressing external files/modules this way | 13:12 | |
Ulti | haxmeister: what language have you come from? | ||
haxmeister | last language I studied was lisp | 13:13 | |
13:13
eliasr joined
|
|||
Ulti | ahh I dont even know how name spacing of things works in lisp :S | 13:13 | |
haxmeister | before that scheme, object pascal, C++ and C.. | ||
but only intermediate skill level.. I just like studying languages, with a particular affinity for perl | |||
Ulti | well C is similar since the include is just / for the same idea less the strict name spacing it also implies | 13:14 | |
Voldenet | haxmeister: it's similar to what C++ would do | ||
#include <boost/regex.hpp> -> use boost::regex | |||
haxmeister | so the colons are directory markers? | 13:15 | |
Voldenet | I'm not 100% sure, but they sure are used that way in modules | ||
haxmeister | ok that is helpful | ||
Ulti | haxmeister: doesnt have to be | ||
timotimo | if you have a meta6.info, you can have the files organized in any way you like and only the "provides" hash is used | ||
haxmeister | oh I'm not ready for that timotimo ..lol | ||
timotimo | no problem | ||
Voldenet | Basically "you can arrange that differently, but most people don't" :) | ||
haxmeister | this tut gave the example my Int $Foo::Bar::buzz = 42; | 13:16 | |
Ulti | haxmeister: you could put it all in a single file if you really wanted to since you have to fully qualify the namespace anyway even with the directory structure | ||
13:16
cdg joined
|
|||
haxmeister | in that example we are creating a variable named what in what namespace location? | 13:17 | |
13:17
Ven_ left,
yht joined,
Ven joined
|
|||
Ulti | $buzz in Foo::Bar is being set to 42 ? | 13:17 | |
isnt this literally the example from the docs on namespacing that tells you what thats doing... | 13:18 | ||
13:18
Ven is now known as Guest80741
|
|||
Ulti | haxmeister: docs.perl6.org/language/packages is this what you were reading? | 13:19 | |
haxmeister also unless you know why you are writing something like $Foo::Bar::buzz = 42 its *very* unlikely you want to be | 13:20 | ||
13:25
raschipi left
|
|||
haxmeister | I guess it confused me because the $Foo is on the left, when I thought of Bar::buzz as the package/namespace... seemed like it should be Bar::buzz::$foo | 13:35 | |
I suppose I need to think of it as "from" instead of "in".. then the phrase kinda reads right | 13:36 | ||
timotimo | you're allowed to put the $ there, too, i believe | ||
haxmeister | so Bar::buzz::$Foo would be the same as $Foo::Bar::buzz ? | 13:37 | |
timotimo | try it out | ||
(not for declaration, though) | |||
13:40
curan left
|
|||
haxmeister | Ulti: I'm perusing docs.perl6.org/language/syntax right this second.. I've written a small program to recurse through some folders for certain files in perl6 but I need to learn to use more features like understanding the colon syntaxes that are used in several constructs | 13:42 | |
13:42
anton_p joined
13:46
titsuki joined
13:47
titsuki_ left
|
|||
moritz | haxmeister: design.perl6.org/S02.html#Adverbial_Pair_forms has a summary of the diferent colonpair forms | 13:55 | |
13:56
bjz left
|
|||
haxmeister | ty moritz | 14:03 | |
trying to make some functions that have type restraints right this second | |||
my first try must show my ignorance sub SFM(Num $rpm, Num $dia ) | |||
perl6 will not upgrade an int to a num.. | 14:04 | ||
Ulti | Bar::buzz::$Foo <--- does that not resolve $Foo for the string value to resolve as the actual symbol? | ||
timotimo | yeah, you'll want "Real" instead of "Num" | 14:05 | |
that'll give you any real number | |||
if you also accept complex numbers, use "Numeric" | |||
haxmeister | so to get floating point numbers I'll use Real not Num? | ||
Voldenet | I suggest using `Rat` instead | 14:06 | |
but welp Real is a role, right? | 14:07 | ||
14:07
xtreak left
|
|||
haxmeister | lol.. that's why it's not clear to me, the documentation for types suffers the same lack of clarity | 14:07 | |
timotimo | Real is a role that is done by all real numbers. Int, Num, Rat. | ||
m: say Int ~~ Real; say Num ~~ Real; say Rat ~~ Real; say Complex ~~ Real; | |||
camelia | True True True False |
||
Voldenet | haxmeister: look at the bottom, there's a type graph docs.perl6.org/type/Numeric | 14:08 | |
haxmeister | ok | ||
moritz | Real is a good type constraint when work with real numbers :-) | ||
haxmeister | that picture is loosing this noob.. | 14:09 | |
timotimo | that shows you what is considered Rational, Real, or Numeric | 14:10 | |
Rational is just Rat and FatRat | |||
Real is anything that's Rational, Instant, Duration, Int, or Num | |||
and Numeric is anything that's Real, or Complex | |||
haxmeister | ok.. smart way to pass to literal ints 313 and 5 to a sub that only accepts a float.(which is not a type I see in perl6).. and have that upgrade happen | 14:12 | |
s/pass to/pass two | |||
timotimo | you can 313.Num | 14:13 | |
haxmeister | sub SFM(Num $rpm, Num $dia ) | 14:14 | |
SFM(318, 3); | |||
timotimo | no, SFM(318.Num, 3.Num) | ||
haxmeister | I misunderstood Num for one thing | ||
timotimo | if they are literals, just write them SFM(318e0, 3e0) | ||
haxmeister | these functions will be part of a program that prompts user input | 14:15 | |
14:16
pierre_ left
|
|||
haxmeister | so need to learn to have the SFM function type protected and user input type checked.. that's my learning goal | 14:16 | |
Voldenet | I guess 'Numeric' role would work here | ||
but you can use Numeric, Real or Rational roles depending on what you want to achieve | 14:17 | ||
haxmeister | sheesh.. I guess I need understand "role" types a little before I try to do typed math | ||
MasterDuke_ | haxmeister: coercers might also be of interest | ||
haxmeister | lol.. you guys | 14:18 | |
Voldenet | haxmeister: if you did some C++ (i see you did), then roles in this case are pretty much similar to abstract classes | ||
MasterDuke_ | m: sub a(Num() $a, Num() $b){say "$a, $b"}(1.Int, 2.Int) | ||
camelia | 1, 2 | ||
MasterDuke_ | the .Int was just to make it obvious that the Num() coercer was doing something | ||
haxmeister | yah MasterDuke_ I have no idea how to read or use a sub with all that at this point | 14:19 | |
Voldenet | huh, any docs on coercers? | 14:20 | |
MasterDuke_ | i think the only thing a little out of the ordinary there are the `Num()`. putting the parens on the end essentially calls .Num on whatever is called | ||
docs.perl6.org/syntax/Coercion%20Type has something | 14:21 | ||
Voldenet | m: sub test($x){ "Coerced $x" }; sub test-two(test() $y){ say $y; }; test-two(2); | ||
camelia | 5===SORRY!5=== Error while compiling <tmp> Invalid typename 'test' in parameter declaration. at <tmp>:1 ------> 3t($x){ "Coerced $x" }; sub test-two(test7⏏5() $y){ say $y; }; test-two(2); |
||
Voldenet | figured it's not that magical | ||
haxmeister | I get the coercion.. I don't understand properly what numbers should be typed as Num compared to Rat..etc | ||
it's a lot of number based types... | 14:22 | ||
Voldenet | haxmeister: understanding the type graph is a key... :) | ||
haxmeister: basically, Numeric is Real + Complex | |||
moritz | haxmeister: Num are floating-point numbers | ||
haxmeister: and Rat are fractions | |||
Voldenet | Real is Rational + Int + Num + Duration + Instant | ||
moritz | haxmeister: in Perl 6, if you write 2.1, that's a Rat | ||
Voldenet | and so on | ||
haxmeister | 2.1 is a fraction? | 14:24 | |
because it looks like a float to me.. :/ | |||
huf | it's 21/10, surely | 14:25 | |
haxmeister | thank you all for being patient.. I really like perl6 but it's a big package coming in | ||
moritz | haxmeister: only with scientific notation (2.1e0) is it a Num/float in Perl 6 | ||
haxmeister | ok | ||
I have to think about that for a minute | |||
timotimo | aye, perl6 is trying to prevent you from shooting yourself in the foot | ||
Voldenet | contrary to perl5 | ||
;-) | |||
timotimo | m: my $num = 0.0; while $num != 1.0 { .say; $num += 0.1 } | 14:26 | |
camelia | (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) (Any) |
||
timotimo | hah | ||
m: my $num = 0.0; while $num != 1.0 { $num.say; $num += 0.1 } | |||
camelia | 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 |
||
timotimo | m: my $num = 0.0e0; while $num != 1.0e0 { $num.say; $num += 0.1e0 } | ||
camelia | (signal XFSZ)0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4 4.1… |
||
Voldenet | m: my $num = 0.0e0; while $num 1.0e0 ~~ 1.0e0 { $num.say; $num += 0.1e0 } | 14:27 | |
camelia | 5===SORRY!5=== Error while compiling <tmp> Missing block at <tmp>:1 ------> 3my $num = 0.0e0; while $num7⏏5 1.0e0 ~~ 1.0e0 { $num.say; $num += 0.1e expecting any of: block or pointy block infix infix st… |
||
Voldenet | m: my $num = 0.0e0; while $num ~~ 1.0e0 { $num.say; $num += 0.1e0 } | 14:28 | |
camelia | ( no output ) | ||
Voldenet | m: my $num = 0.0e0; while $num !~~ 1.0e0 { $num.say; $num += 0.1e0 } | ||
timotimo | m: my $num = 0.0e0; while $num =~= 1.0e0 { $num.say; $num += 0.1e0 } | ||
camelia | (signal XFSZ)0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4 4.1… |
||
( no output ) | |||
timotimo | m: my $num = 0.0e0; while $num !=~= 1.0e0 { $num.say; $num += 0.1e0 } | ||
camelia | 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 |
||
Voldenet | whoa !=~= | ||
what a nice operator | |||
m: $*TOLERANCE = 1e-30; my $num = 0.0e0; while $num !=~= 1.0e0 { $num.say; $num += 0.1e0 } | 14:29 | ||
camelia | Cannot modify an immutable Num in block <unit> at <tmp> line 1 |
||
Voldenet | ah ;) | ||
timotimo | you want "my" there | ||
Voldenet | m: my $*TOLERANCE = 1e-30; my $num = 0.0e0; while $num !=~= 1.0e0 { $num.say; $num += 0.1e0 } | ||
So it's still possible to shoot yourself in the foot | 14:30 | ||
timotimo | of course | ||
Voldenet | Nice! | ||
haxmeister | you guys play entirely too much with that chat bot..lol | ||
camelia | (timeout)0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4 4.1 4.2… |
||
Voldenet | Well, it's nice, because you can actually read some perl6 syntax and features while reading irc | 14:31 | |
along with all those 'funky features' you wouldn't know that exist | 14:32 | ||
14:32
lowbro left
14:33
mcmillhj left
14:34
mcmillhj joined
|
|||
haxmeister | so 313.Num is the same as Num(313) ? we have Num as a method of several types including integer and string.. and we have Num a free standing function all available is that what I'm seeing? | 14:37 | |
313.Num being a method call on the Int type object.. and Num(313) being a call to a standard free standing function | 14:38 | ||
timotimo | no, not a method call on the int type object | 14:39 | |
it's a method call on an Int instance | |||
haxmeister | oh well. yah | ||
really? | |||
timotimo | 313.Num wouldn't be able to give you 313e0 if it were a call on the type instance | ||
because the type instance carries no value | |||
haxmeister | damn timotimo | 14:40 | |
is 318 and object? | |||
timotimo | of course | ||
haxmeister | and what class is that obect? | 14:41 | |
timotimo | m: say 318.WHAT.perl | ||
camelia | Int | ||
moritz | m: say 318.^name | ||
camelia | Int | ||
14:41
wamba left
|
|||
haxmeister | so 318 is an object of the class Int | 14:41 | |
timotimo | right | ||
AlexDaniel | haxmeister: not just this chat bot. We have many bots here. We play with all of them ( ͡° ͜ʖ ͡°) | 14:42 | |
haxmeister | therefore 318.Num is calling the method Num() from the Int class object yah? | ||
timotimo | yeah | ||
haxmeister | AlexDaniel: it's ok.. the playfulness makes for a happy environment | ||
so what I said before is true | |||
timotimo | nah, "on" is a wrong word there | 14:43 | |
haxmeister | lol | ||
timotimo | m: Int.Num | ||
camelia | Invocant of method 'Num' must be an object instance of type 'Int', not a type object of type 'Int'. Did you forget a '.new'? in block <unit> at <tmp> line 1 |
||
timotimo | ^- this is a method call on the Int type object | ||
haxmeister | so I've got myself confused with the notation we use a bit and what it means | 14:44 | |
timotimo | yeah, that's fine | 14:45 | |
haxmeister | I'm glad your patient | ||
timotimo | patient is easy :) | ||
well, mostly | |||
14:46
khw joined
14:47
g4 left
|
|||
haxmeister | so if I say 313 literally I am not instantiating an object of the Int class? | 14:47 | |
14:48
nadim left
|
|||
timotimo | you are, though it happens at compile time, which could make a difference to you | 14:49 | |
14:49
pat_js joined
|
|||
haxmeister | ah.. ok. that clarifies a bit | 14:49 | |
an example of explicitly instantiating an Int object with the value 313 would look how? | 14:50 | ||
AlexDaniel | m: say Int.new(‘313’) # maybe this? :| | 14:51 | |
camelia | 313 | ||
AlexDaniel | but honestly it doesn't really make sense to do something like this | ||
m: say 313 # this is just fine… | |||
camelia | 313 | ||
timotimo | m: my $try = 0; while $try != 313 { $try++ }; say $try | 14:52 | |
camelia | 313 | ||
haxmeister | no it doesn't.. but to understand how perl6 is using dot notation it helps me | ||
because 313.Num is a thing | |||
just like "somestring".say | 14:53 | ||
timotimo | right | ||
haxmeister | using object notation on a literal is a different thing for me | ||
timotimo | what is "object notation" to you? | 14:54 | |
haxmeister | so that's why I ask about whether it's an object or not.. and then further how to use normal object instantiation method for it | ||
14:54
titsuki left
|
|||
timotimo | you need to know that "method new" is nothing special, either | 14:54 | |
haxmeister | are all anonymous objects created at compile time? | 14:56 | |
moritz ponders whether his next book should be "Perl 6 Complete: Object Orientation" | |||
haxmeister: no | |||
haxmeister | moritz: that question makes sense to you? | ||
moritz | my $x = {}; # anonymous hash created at compile time | ||
erm sorry, at run time | |||
moritz confused | |||
even classes can be created at run time | |||
haxmeister | lol | 14:57 | |
so much badassery in perl6..lmao | |||
timotimo | i can't actually find the code that makes Num(123) tick | ||
14:57
azawawi joined
|
|||
moritz | m: my $class := Metamodel.ClassHOW.new_type(name => 'funny'); | 14:58 | |
camelia | No such method 'ClassHOW' for invocant of type 'Metamodel' in block <unit> at <tmp> line 1 |
||
14:58
lizmat joined
|
|||
moritz | m: my $class := Metamodel::ClassHOW.new_type(name => 'funny'); | 14:58 | |
camelia | ( no output ) | ||
haxmeister | moritz: to be honest.. I think for this language it is almost better to start a tut with the OO stuff and work down | 14:59 | |
azawawi | hi | 15:00 | |
haxmeister | since basic typing is connected to OO syntactically and actually | ||
moritz | haxmeister: sure, start simple, then get down to the nitty gritty | ||
hi azawawi | |||
jnthn | Integer literals are a little bit interesting, because - at least for those that are small enough - the compiler is happy to treat them as both an Int object or a native int. In fact, it compiles them - in the immediate - into both, and lets the surrounding context decide which is wanted. | ||
azawawi | github.com/azawawi/perl6-terminal-...-world.pl6 # Terminal::Caca method chaining. Feedback is welcomed | 15:01 | |
haxmeister | damn | ||
that's hardcore | |||
jnthn | So if you say 42.WHAT then you're absolutely talking about the Int because .WHAT is a thing that's done to objects | ||
But if writing `my int $answer = 42` then it can see there's no point generating code that takes a Int and then takes the int out from it, it can just generate code with the native 42 integer value right away. :) | 15:02 | ||
moritz | azawawi: nice | ||
jnthn | In general, though, Perl 6 lets you consider everything an object. Even if you have a native integer, and try to use it in an object-y way, it'll box it into an Int for you automatically | 15:03 | |
moritz | so currently I'm improving my manuscript ("Perl 6 Fundamentals") in response to feedback | ||
and in the back of my mind, I'm considering what to do next | |||
and one of my ideas was to explore a Perl 6 topic in more depth | |||
maybe in the form of a short book | 15:04 | ||
jnthn | Maybe some day I should write "Perl 6 from the bottom up", to steal the "Git from the bottom up" idea. :P | ||
moritz | jnthn: I'd buy that :-) | ||
and the topics I've come up so far that I could cover are: routines and signatues, OO, Regex and grammars | |||
MasterDuke_ | jnthn: i've mentioned this to timotimo as an idea, but i would love a blog post (or something more substantial) that goes into some detail about exactly what happns when you `perl6 -e 'say "hi"'` | 15:05 | |
moritz | the other I had was to ask MJD what he thinks about a Perl 6 version of HOP | ||
MasterDuke_ | i.e., what's happening in rakudo, what in nqp, what in moarvm | 15:06 | |
jnthn | MasterDuke_: omg so much :-) | ||
moritz | or a Friedl if he would like a Perl 6 edition of "Mastering Regular Expressions" | ||
El_Che | moritz: do grammars | ||
moritz | or maybe I should stop writing for a bit, and explore podcasting | ||
or... dunno | |||
just floating ideas around | |||
MasterDuke_ | jnthn: heh, you're the one who said "book" | 15:07 | |
moritz | El_Che: vote registered :-) | ||
El_Che | moritz: als a good (deep and wide) multithreading chapter would be nice | ||
also | |||
MasterDuke_ | oops, implied "book" maybe | ||
moritz | El_Che: that would be nice indeed, but I'm the wrong person to write that :-) | ||
lizmat | . | ||
yoleaux | 14:39Z <Zoffix> lizmat: should List.sink actually do things? I would've figured it'd do self.iterator.sink-all, since a List could be made from a Seq, for example. And we do sink-all in Seqs, but not lists: irclog.perlgeek.de/perl6-dev/2017-...i_14525429 | ||
14:49Z <Zoffix> lizmat: Never mind. jnthn++ answered | |||
jnthn | Well, a Perl 6 guts-y book would certainly have to go in the queue behind the first one I really want to do :-) | 15:08 | |
moritz | jnthn: tell me more about the first one :-) | ||
MasterDuke_ | ooo, an async/multi-threading one? | ||
jnthn | MasterDuke_ guessed :) | 15:09 | |
MasterDuke_ | i would buy that | ||
moritz too | 15:10 | ||
15:10
Guest80741 left
15:11
KDr2 joined,
araraloren joined
15:12
Ven joined,
Ven is now known as Guest37161
15:14
robertle joined
|
|||
haxmeister | that is very very insightful jnthn i'm glad my difficulty was understood.. with that information the syntax is far less confusing | 15:17 | |
15:19
azawawi left
|
|||
haxmeister | having perl6 allow you to use what might be a literal in the context of object notation certainly sets it above many other language.. it is a higher higher level language in that sense | 15:19 | |
[Coke] | jnthn++ # I'd buy that book | 15:20 | |
haxmeister | though that does make it difficult to look up documentation when you don't know if you should be looking for a class method of a particular objects type or a built-in function | 15:21 | |
15:22
skids joined
15:26
mr-foobar left
|
|||
haxmeister | so only the interpreter deals with actual literals.. everything is an object and all subs/functions/methods are accepting objects as their arguments | 15:26 | |
though usually they are anonymous objects | 15:27 | ||
15:29
keix joined,
KDr2 left
15:31
yht left
15:34
mr-foobar joined
15:36
Sgeo joined
15:37
Sgeo_ left
|
|||
[Coke] | docs should /wni 8 | 15:42 | |
aha, I fooled the bot. | |||
haxmeister | oh.. block syntax.. very awesome.. | 15:44 | |
could right some outrageous macros type stuff with that | |||
15:45
wamba joined,
Cabanossi left
|
|||
haxmeister | can you pass perl6 code to a function or even block for execution? | 15:46 | |
15:47
domidumont joined,
Cabanossi joined
|
|||
timotimo | functions are objects, you can pass objects as arguments | 15:47 | |
haxmeister | all arguments are objects.. but didn't think about functions being objects thank you | ||
timotimo | m: my $foo = -> $a, $b { say "$a and $b" }; sub call-it($it) { $it("one", "two") }; call-it($foo) | ||
camelia | one and two | ||
haxmeister | interesting.. perl6 can learn and modify itself then | 15:49 | |
timotimo | that's not it | ||
just passing code objects around doesn't give you self-modification yet | |||
but you can EVAL stuff and that can do what you want, probably | |||
15:50
itsame joined
|
|||
haxmeister | EVAL sounds familiar | 15:50 | |
MasterDuke_ | and you can modify the grammar at runtime | ||
haxmeister | if I can take a string that is valid perl6 code and then evaluate that string as code.. that's all it takes | ||
timotimo | MasterDuke_: i wouldn't call that runtime, though? | 15:51 | |
haxmeister | can we create data structures by evaluating strings of perl6 code that create a data structure? | 15:52 | |
timotimo | yeah, you have to go through EVAL for that | ||
because code is code | 15:53 | ||
MasterDuke_ | timotimo: you wouldn't? | ||
15:53
Guest37161 left,
ChoHag joined
|
|||
timotimo | MasterDuke_: you pull in changes to the grammar during compile time, no? | 15:53 | |
MasterDuke_ | m: sub prefix:<!>($n) { [*] 1..$n }; say !5 | 15:54 | |
camelia | 120 | ||
timotimo | at run time, you can no longer change the grammar that was used to parse the code | 15:55 | |
jnthn | That's a compile time change, not runtime. Otherwise we don't know how to parse the added operators when we encounter them in later code :) | ||
postfix:<!> is probably a better example 'cus that doesn't exist in standard Perl 6 :) | 15:56 | ||
MasterDuke_ | ah, right | ||
jnthn | m: sub postfix:<!>($n) { [*] 1..$n }; say 5! | ||
camelia | 120 | ||
jnthn | m: say 5!; sub postfix:<!>($n) { [*] 1..$n }; # also notice order matters | ||
camelia | 5===SORRY!5=== Error while compiling <tmp> Negation metaoperator not followed by valid infix at <tmp>:1 ------> 3say 5!7⏏5; sub postfix:<!>($n) { [*] 1..$n }; # a expecting any of: infix infix stopper |
||
jnthn | Can't use the operator before it's defined | ||
haxmeister | but with EVAl though.. have we completely taken the heart of lisp and put it in perl or is it more restrictive? | ||
jnthn | 'cus it's not even in the pare tables | ||
*parse | |||
MasterDuke_ | m: say !5; sub prefix:<!>($n) { [*] 1..$n }; | ||
camelia | 120 | ||
timotimo | perl6 code isn't isomorphic or what the name is | ||
MasterDuke_ | that's a little confusing | 15:57 | |
but i guess if you're creating custom operators you should know what's happing there | 15:59 | ||
haxmeister | so eval can't work on perl6 code but it can work on perl5? | ||
it just has the option "perl" | |||
MasterDuke_ | m: EVAL q|say "hi"| | 16:00 | |
camelia | hi | ||
jnthn | The Perl 6 EVAL function assumes code is Perl 6 by default | ||
I think if you're using Inline::Perl5 you can use pass :lang<perl5> as an option or something like that | 16:01 | ||
haxmeister | if I my Str $foo = "my $bar =\"hello world\"" now $bar is available to me? | ||
timotimo | no | ||
haxmeister | because I can eval $foo and have $bar available? | ||
timotimo | nope | ||
haxmeister | kk | 16:02 | |
timotimo | lexical pads are a compile-time thing and are fixed as soon as the compiler's done | ||
so you can't put in new lexical variables by calling EVAL at run time | |||
haxmeister | oh I gotcha.. there's the difference | ||
can't access them or can't create them?.. | 16:04 | ||
16:04
ChoHag left
|
|||
haxmeister | if I EVAL a string of code that includes functions and vars etc.. will it evaluate or say no | 16:04 | |
jnthn | They will be compiled as if in a nested scope | 16:05 | |
So you can put functions and vars in there and call them inside of the EVAL, they just won't be available outside | |||
haxmeister | awesome | 16:06 | |
jnthn | If you want that you can either (for one function) return it as the result of the EVAL, or make it escape in some other way (assign it to a lexical outside of the EVAL, stick it in a package, assign it to a dynamic variable...basically anything non-lexical :)) | ||
m: my &func; EVAL '&func = sub { say 42 }'; func() | |||
camelia | 42 | ||
jnthn | That works for example 'cus &func is declared outside of the EVAL | 16:07 | |
haxmeister | sheesh I need to back up.. I have fundamentals to get used to in perl6 | ||
had to go here docs.perl6.org/language/5to6-nutshell to see why the space isn't allowed between a function call and it's parenthesized arguments | 16:11 | ||
that explanation might should be on the doc page about subs/functions.. | 16:13 | ||
in addition to this page | |||
TreyHarris | Design opinions sought: for a portable interface to a system resource (in this case, a PID, process ID) better to have a portable MyApp::PID with a has-a that will dispatch to a OS-specific object the user will never see (even if they do a .WHAT), or create a factory method as the entry point so the user gets a MyApp::PID::Linux or MyApp::PID::Darwin, both is-a to an uninstantiable MyApp::PID etc. depending on | 16:14 | |
what OS they're on? (Presumably the factory in the latter case would live in MyApp::PID.) | |||
I should just clone the entire ecosystem so I can ack around for possible conventions already emerg(ed|ing) for things like this. How large is it, I assume the hundreds of megs at most? | 16:17 | ||
(Anybody already written a CPAN Mirror-style ecosystem downloader? Simple enough to iterate through perl6/ecosystem/META.list, but there might be unusual cases and why reinvent wheels?) | 16:18 | ||
16:19
garas joined
|
|||
MasterDuke_ | huggable: all modules | 16:19 | |
huggable | MasterDuke_, github.com/moritz/perl6-all-modules | ||
MasterDuke_ | TreyHarris: ^^^ | ||
TreyHarris | MasterDuke_: ty! | ||
garas | what is the perl6 equivalent of perldoc ? | 16:20 | |
TreyHarris | garas: p6doc or perl --doc depending on usage | ||
sorry, perl6 --doc | |||
16:21
Geth left
|
|||
garas | ===> Building: p6doc No such method 'abspath' for invocant of type 'IO::Path' | 16:22 | |
TreyHarris | garas: with rakudo, you'll need to run 'p6doc-index build' first | ||
16:22
rindolf joined
|
|||
garas | I think it is broken | 16:22 | |
16:22
Geth joined,
ChanServ sets mode: +v Geth
|
|||
timotimo | yeah, it's "absolute" instead of "abspath | 16:22 | |
" | |||
but isn't it supposed to just give a deprecation warning? | 16:23 | ||
16:25
mcsnolte joined
|
|||
garas | seems easy to fix | 16:25 | |
TreyHarris hemms and haws about whether to clone moritz/perl6-all-modules in ~/src/perl6/ALL-MODULES or something for lower cognitive load and better tabbability, or under ~/src/perl6-all-modules to preserve ~/src/perl6 having only the project modules inside for a 1:1 relationship to the GitHub path | 16:26 | ||
MasterDuke_ | do both, disk is cheap! | 16:28 | |
and why not ~/src/perl6/modules/all also | 16:29 | ||
timotimo | just symlink it :P | ||
one thing that annoys me to almost no end is that i tend to perf record while in my ~, but there's also a "perl6" folder where all my perl6 stuff is in | |||
and perf creates "perf.data" | 16:30 | ||
TreyHarris | hah! the size of all modules is 236 MB. I was guessing based on pure gut instinct about a quarter gig. | 16:31 | |
timotimo | that's not only the size of modules, but also their history | ||
TreyHarris | yeah, just noticed that. modules-only is 171M | ||
timotimo | and there might be a few .so files in there | ||
garas | p6doc has been fixed already on github, but zef downloaded me the broken version.. | ||
TreyHarris | timotimo: not according to find | 16:32 | |
timotimo | OK | ||
TreyHarris | garas: p6doc is distributed with rakudo, not separately, I believe? | ||
timotimo | TreyHarris: it's in rakudo star, not in rakudo itself | ||
garas | using rakudobrew | ||
16:33
itsame left
|
|||
TreyHarris | timotimo: sorry, I thinko'd | 16:33 | |
timotimo | :) | 16:34 | |
16:34
ChoHag joined,
Zoffix joined
|
|||
Zoffix | garas: how come you're using rakudobrew? | 16:35 | |
TreyHarris | Well, that's useless... not a single class in the ecosystem has "Linux" or "Darwin" in its name, believe it or not. (Actually, one has a "Darwin", but it's referring to the Australian city, not the OS.) | ||
garas | Zoffix: I have no idea.. | ||
Zoffix | garas: hah | ||
garas | I use homebrew on the mac, and got used to it | ||
Zoffix | garas: well, it's not really for end users. For example, you need to run `rakudobrew rehash` after installing binaries like `p6doc` or stuff won't work right. Try running that now and see if that fixes your issue | ||
TreyHarris | s/class/namespace/ | 16:36 | |
garas | thanks | ||
Zoffix | timotimo: nope, no deprecation for .abspath | ||
timotimo | OK. in that case i don't know why IO::Path would error out like that for a call to its .abspath | ||
Zoffix | .slurp-rest will be deprecated in 6.d... Don't remember offhand what else | ||
timotimo: oh, no, .abspath just got removed, without any deprecation. | 16:37 | ||
It wasn't part of the language, IIRC | |||
timotimo | oh! | ||
that's how you meant it | |||
Zoffix | Yeah | ||
buggable: eco doc | 16:38 | ||
buggable | Zoffix, Found 10 results: Pod::Parser, p6doc, XML::Parser::Tiny, HTML::Parser::XML, PerlStore. See modules.perl6.org/#q=doc | ||
Zoffix | buggable: eco p6doc | ||
buggable | Zoffix, p6doc 'Perl 6 documentation (tools and docs)': github.com/perl6/doc | ||
TreyHarris | Are there performance-based reasons to prefer the factory-is-a dispatch over the has-a dispatch, which would tend to reduce method dispatch by one for ever operation? Or is that optimized and/or negligible? (I can use 'handles' in some, but not all, cases, if there's an optimization for that.) | ||
Zoffix | garas: oh, I see why. We got dumb version in p6doc | 16:39 | |
TreyHarris | (that was a misplaced modifier; the fatory is-a would tend to reduce method calls by one per operation, not the has-a) | ||
Geth | doc: 0893cdcdd5 | (Zoffix Znet)++ (committed using GitHub Web editor) | META6.json User proper version So that modules update stuff when we make new versions |
||
Zoffix | garas: zef --force install p6doc; rakudobrew rehash; | ||
That should fix the issue | |||
16:40
dakkar left
|
|||
Zoffix | IMO a META version of "*" should mean "install, always" to a package manager. | 16:41 | |
m: Version.new(*) before Version.new(*) | |||
camelia | WARNINGS for <tmp>: Useless use of "before" in expression ".new(*) before Version.new(*)" in sink context (line 1) |
||
Zoffix | m: say Version.new(*) before Version.new(*) | ||
camelia | False | ||
Zoffix | hmmm | ||
Zoffix shrugs | |||
m: say Version.new(*) after Version.new('1.001001') | 16:42 | ||
camelia | False | ||
Zoffix | m: say Version.new(*) before Version.new('1.001001') | ||
camelia | True | ||
Zoffix | Good. | ||
garas: also, p6doc is a far cry from perldoc at the moment. Still needs a bunch of work. Easier to just use docs.perl6.org | 16:43 | ||
TreyHarris | I'm leaning towards a factory in MyApp::PID returning MyApp::PID::$<OSNAME>. So, last question if anyone has an opinion: should such a factory be invoked on .new since it will just locate the right subclass and re-dispatch, or is it bad hygiene for .new to return anything other than an instance of exactly the class explicitly named and not a subclass? | ||
garas | Zoffix: agreed, I also like the website, but I am curious | 16:45 | |
Zoffix | garas: did the fix work for you? | ||
garas | it installed it | ||
--force was really important | 16:46 | ||
also | |||
Zoffix | Sweet. Do you still have the .abspath problem? | ||
TreyHarris | Hmm, github.com/perl6/modules exists, hasn't been touched since 2009, and has a single module in it, Digest (using old syntax that probably won't work (right) anymore | ||
garas | no abspath problem | ||
Zoffix | Awesome. | ||
16:48
keix left
16:49
zakharyas left
|
|||
garas | It seems to work decently :) | 16:50 | |
araraloren | TreyHarris, a factory new is a good idea, I prefer that way. | 16:51 | |
Zoffix | awwaiid: my feedback on your Terminal::Caca fluent interface is it's terrible for errors. For example this chain's death on line 25 is reported to be on line 9, because that's where the statement starts: gist.github.com/zoffixznet/2e8bd72...0dd6b75192 There's no reason to write that code in Perl 6, since you can use `given $o { .method1; .method2; .method3; }` etc | 16:52 | |
TreyHarris | araraloren: I agree, but I just didn't know if it violated least surprise to call X.new() and get an instance of Y, even if Y is a X. | 16:53 | |
Zoffix | awwaiid: though, as far as chains go, I have you beat with my juicy Perl 5 test module: metacpan.org/pod/Test::Mojo::Role:...r#SYNOPSIS :) | 16:55 | |
16:56
cdg left
16:57
Zoffix left
|
|||
araraloren | Em, I have seen that way in some Perl 5 Module. In Perl 6 , new is just a construct method. | 16:59 | |
17:00
Cabanossi left
|
|||
araraloren | TreyHarris, Just write a clear document for your module. It's no problem . | 17:01 | |
TreyHarris | araraloren: well, maybe it should be a role then. | 17:02 | |
17:02
Cabanossi joined
|
|||
TreyHarris | nope, can't be a role, it has behavior ("class methods") I need to call on it even before OS-dispatch. | 17:02 | |
araraloren | Em, Night ..I gotta sleep .. | 17:03 | |
Or maybe you can make a other name for it. Such as `method from-os(..)` | 17:05 | ||
17:05
araraloren left
|
|||
TreyHarris | m: role Dock { method bark { say "quack!" } }; Dock.bark; class Dog does Dock { }; my $d = Dog.new; $d.bark | 17:08 | |
camelia | quack! quack! |
||
TreyHarris | Hmm, guess you can call methods on roles... is that accidental? | 17:09 | |
timotimo | that's what's called "punnign" | ||
"punning" | |||
it does the equivalent of class anonymous does TheRole { } and calls the method on that | |||
TreyHarris | ....right! | 17:10 | |
forgot about that. | |||
17:13
cdg joined
|
|||
TreyHarris | it's a PITA to rewrite .new in this case, because if you do it stupidly (making the role or superclass dispatch to the class's .new) you go into an infinite loop. better to name the factory something else I guess, unless this is a case for using bless, and I think it's not. | 17:17 | |
I've always like the Recognizer pattern (where a class looks at its input and returns an object of the appropriate isomorphic type to deal with the input, with the instance classes themselves being polled "can you take this input?" and letting them reply "yes", "no", or "maybe, but come back to me if nobody else says "yes"), and multis make it a lot easier to write them. but they still aren't exactly concise | 17:21 | ||
in any OO language I've encountered. | |||
timotimo | having roles participate in the build dance is difficult, aye | 17:28 | |
normally you have a submethod BUILD and/or TWEAK, but submethods, like methods, get flattened into the class body that you're applying to | |||
17:29
alimon left,
cdg left
|
|||
TreyHarris | Easier just to separate out the build function into a factory and putting any recognition logic into "class methods" (is that an official term in Perl 6, or do we say "undefined invocant methods?"), letting the ordinary BUILD & TWEAK process work as normal. This also lets you put the participating methods into a class tree if you so desire, letting slightly-different classes capitalize on one another's | 17:31 | |
implementations. | |||
timotimo | hm, i wonder if a submethod BUILD will also invalidate the default values for attributes in roles you merge into the class | 17:33 | |
m: role WithDefault { has $.foo = rand }; class WithBuild does WithDefault { submethod BUILD(:$lol) { say $lol } }; WithBuild.new(:99lol).foo.say | 17:34 | ||
camelia | 99 0.977413050909244 |
||
timotimo | cool, that works | ||
17:34
alimon joined
17:36
azawawi joined
|
|||
azawawi | hi | 17:36 | |
17:37
anop joined
|
|||
anop | what is "do for" in perl 6 | 17:37 | |
timotimo | it lets you use a for loop in an expression context | 17:38 | |
to get its value | |||
well, values | |||
anop | thanks but why we use "do " with for ? | 17:39 | |
[Coke] | anop: docs.perl6.org/syntax/do | 17:40 | |
azawawi | Zoffix: thx for your feedback to my synonym nickname :) | ||
TreyHarris | timotimo: can you think of any examples where both a TWEAK and a BUILD would be used aside from as an academic exercise? It seems to me like the rule of thumb is, "use TWEAK if you can, BUILD otherwise, and new only if you must" (which I guess kind of blows up the whole CAPS-vs-lowercase thing) | ||
anop | thnks timotimo | 17:41 | |
" (.=not for @doors[0, $_ ... 100]) for 1..100;" in this code, could you explan what is " .=not " ? | 17:44 | ||
timotimo | it's a mutating method call on $_ | 17:45 | |
(when an object before the method call is left out, but the . is there, it is a call on $_) | |||
.=not is equivalent to $_ = $_.not | 17:46 | ||
17:46
Cabanossi left
|
|||
timotimo | TreyHarris: i don't think there's a good reason to have both | 17:46 | |
anop | thnks u so much timotimo..... | ||
17:47
Cabanossi joined
17:48
cdg_ joined
17:50
araujo left
17:54
labster joined,
skids left,
raschipi joined
|
|||
garas | Do you think it would be nice if perl6 had a help() function in the REPL, calling p6doc? | 17:56 | |
17:58
anop left
|
|||
raschipi | garas: Better done with two terminals or terminal tabs. | 18:01 | |
alphah | m: my $u = $*USER; say $u.perl; say $u[0] | ||
camelia | IntStr.new(1012, "camelia") camelia |
||
alphah | m: my $u = $*USER; say $u.perl; say $u[1] | 18:02 | |
camelia | IntStr.new(1012, "camelia") Index out of range. Is: 1, should be in 0..0 in block <unit> at <tmp> line 1 Actually thrown at: in block <unit> at <tmp> line 1 |
||
alphah | How to get the id number, not the user id? | ||
MasterDuke_ | m: my $u = $*USER; say $u.perl; say +$u | 18:03 | |
camelia | IntStr.new(1012, "camelia") 1012 |
||
alphah | aaah | ||
Thanks | |||
MasterDuke_ | m: my $u = $*USER; say $u.perl; say ~$u | ||
camelia | IntStr.new(1012, "camelia") camelia |
||
raschipi | m: my $u = $*USER; say $u ~~ 1012; | 18:07 | |
camelia | True | ||
raschipi | m: my $u = $*USER; say $u ~~ 'camelia'; | ||
camelia | True | ||
18:11
setty1 joined
18:15
Cabanossi left
18:17
Cabanossi joined,
azawawi left
18:18
itaylor57 joined
18:20
Ven joined
|
|||
raschipi | m: my $u = $*USER; say $u + 2; | 18:20 | |
camelia | 1014 | ||
18:20
Ven is now known as Guest48770
|
|||
MasterDuke_ | docs.perl6.org/language/glossary#Allomorph | 18:20 | |
18:22
garas left
|
|||
alphah | m: say $*USER.Str; say $*USER.Num; | 18:28 | |
camelia | camelia 1012 |
||
raschipi | I'm aware. | ||
m: sub f(Numeric $x){say $x}; my $y=<2>; f($y) | 18:30 | ||
camelia | 2 | ||
raschipi | m: my $y=<2>; $y.WHAT | ||
camelia | ( no output ) | ||
raschipi | m: my $y=<2>; say $y.WHAT | ||
camelia | (IntStr) | ||
raschipi | m: sub f(Numeric $x){say $x.WHAT}; my $y=<2>; f($y) | 18:31 | |
camelia | (IntStr) | ||
raschipi | m: sub f(Int() $x){say $x.WHAT}; my $y=<2>; f($y) | ||
camelia | (IntStr) | ||
18:31
cdg_ left
|
|||
raschipi | m: sub f(Int $x){say $x.WHAT}; my $y=<2>; f($y) | 18:31 | |
camelia | (IntStr) | ||
raschipi | m: say IntStr ~~ Int; | 18:32 | |
camelia | True | ||
raschipi | m: sub f(Any $x where 2){say $x.WHAT}; my $y=<2>; f($y) | 18:35 | |
camelia | (IntStr) | ||
raschipi | m: sub f($x){say $x.WHAT}; my $y=<+2>; f($y) | 18:36 | |
camelia | (IntStr) | ||
raschipi | m: sub f($x){say $x.WHAT}; my $y=<2+0>; f($y) | 18:37 | |
camelia | (Str) | ||
raschipi | The note in the glossary is confusing. | ||
18:40
Zoffix joined
|
|||
Zoffix | raschipi: which part? | 18:40 | |
The "Note:…" | |||
? | |||
raschipi | Yes. | ||
Zoffix | How can it be better? | 18:41 | |
Basically angle brackets are dual-purpose: a list of stuff or a way to make Rat and Complex literals | |||
And which you get depends on whether there's stuff other than the number in the brackets | 18:42 | ||
raschipi | It should say it doesn't work for Ints. | ||
Zoffix | Why Ints specifically? | ||
raschipi | m: say <+2>.WHAT | ||
camelia | (IntStr) | ||
raschipi | m: say <2+0>.WHAT | ||
camelia | (Str) | ||
AlexDaniel | oh please not <> again… | ||
Zoffix | <> is awesome. You're just not ready to receive all it's got to offer :P | 18:43 | |
raschipi | I like it, very handy (especially for testing). My problem is with the note. | ||
AlexDaniel | for me it would've been better if there was a distinct syntax for every single thing you can get out of it | 18:44 | |
moritz | m: say <2+3i>.^name | ||
camelia | Complex | ||
AlexDaniel | like I don't know, i<> or ~<> or whatever | ||
18:46
Cabanossi left
|
|||
Geth | doc: cc1b62a0ce | (Zoffix Znet)++ (committed using GitHub Web editor) | doc/Language/glossary.pod6 Clarify allomorph vs literal numeric note |
18:47 | |
Zoffix | raschipi: ^ what about now? | ||
18:47
Cabanossi joined
|
|||
Zoffix | .oO( that entry is way to big for a Glossary entry ) |
18:48 | |
raschipi | Now I understand how it works. | ||
Zoffix | Sweet. | 18:49 | |
18:49
Zoffix left
18:51
jonas1 left,
eliasr left
18:55
jonas1 joined
18:58
labster left
19:04
darutoko left
19:08
domidumont left
19:19
TEttinger joined
19:21
jonas1 left
19:32
r3m left,
espadrine_ joined
19:33
r3m joined
19:41
itaipu left
19:44
itaipu joined
19:45
Cabanossi left
19:47
Cabanossi joined
19:50
dct joined
19:55
itaipu left
19:56
labster joined
19:59
cdg joined
20:01
skids joined
20:05
raschipi left
|
|||
Geth | ecosystem: 941b77ba6a | (David Warring)++ | META.list rename repos |
20:22 | |
20:24
azawawi joined
|
|||
TreyHarris | I'm confused by this behavior I've made into a short test case. I'm following the documentation example so closely here that I'm sure I'm just making a typo or something, but I retyped this example from scratch and still getting the same thing: gist.github.com/treyharris/f26bb1a...cfd970b14b | 20:24 | |
azawawi | github.com/azawawi/perl6-terminal-...n-sink.pl6 # Perl 6 random lines, boxes, circles, ellipses and triangles (also fill-) primitives :) | 20:26 | |
timotimo | TreyHarris: that example is wrong | 20:27 | |
you're giving the proxy a method and it's trying to access $!x, but it'l installed on the proxy object | |||
but Proxy doesn't have a $!x | |||
TreyHarris | timotimo: oh? I'll fix the example if you tell me what's wrong with it | ||
timotimo | please try "sub" instead of "method" in there | ||
TreyHarris | ok | ||
moritz | but if you use sub, you need a placeholder argument for the proxy | 20:28 | |
timotimo | ah, yes | ||
20:28
ggoebel left
|
|||
timotimo | first positional parameter | 20:28 | |
moritz | so FETCH => sub ($) { $!x * 2 } | ||
20:28
Perl6Noob joined
|
|||
timotimo | yup, and add a $ for the STORE sub, too | 20:28 | |
in front | |||
moritz | STORE => sub ($, $new) { $!x = $new / 2 } | ||
timotimo | that makes things work properly | 20:29 | |
moritz | also, the tests assume that if you assign 3, you get a 6 out | ||
but you're assinging 3/2 to $!x, and then fetch 3/2 * 2, so 3 | |||
ugexe | META version of "*" cant mean install always to a package manager without also adding logic to ignore dependencies and a bunch of other things. Instead, a META version of * is treated just like how rakudo treats it: as version 0 | 20:30 | |
moritz | erm wait, you're storing 3*2, and then retrieving 3*2/2 | ||
TreyHarris | huh? the tests pass now and I just changed "method (" to "sub ($," | ||
Perl6Noob | ugexe, why ignore dependency? | 20:31 | |
Trey | |||
moritz | TreyHarris: oh, because you assign to x, not to double-x | ||
TreyHarris: never mind my ramblings | |||
ugexe | because dependencies can overlap versions | ||
Perl6Noob | TreyHarrys, because sub closes over $!x, while when it was a method it was trying to get it from elsewhere | 20:32 | |
ugexe | now you have to introduce special logic for when versions overlap and you only want one or the other and not both | ||
TreyHarris | moritz: oh, yes, I wanted to simplify down to bare bones so I used a name for the proxy that wasn't overloaded at all | ||
ugexe | there are tons of details like this | ||
declaring version * in META6.json should just be barred | |||
TreyHarris | Perl6Noob: excuse me? ignore what dependency? | ||
Perl6Noob | ugexe, ok | ||
TreyHarris, nah, that was to ugexe | 20:33 | ||
20:33
dct left
|
|||
TreyHarris | In the docs there are examples of proxy with "STORE => method" and "FETCH => method" where it's a code snippet, not a runnable example... when (if/ever) is "method" appropriate/ | 20:35 | |
? | |||
There are no examples with FETCH/STORE => sub, so I feel like I should change one of them to that at least so they won't spend 2 hours like I just did trying all sorts of things but never thinking to make that particular change | 20:36 | ||
Perl6Noob | TreyHarris, when it's self-contained or closes over just normal variables. It really just saves you from adding an invocant to parameters list. And it failing the way it does when you closed over $!x may be a bug... Like if you do it in regexes you get a proper error about it | ||
20:36
rindolf left
|
|||
Perl6Noob | IMO a block is the best thing to use there | 20:38 | |
least typing | |||
TreyHarris | Okay, but in what context would you close it over normal variables when creating an "is rw" accessor method? That's what led me to the example in the first place, docs saying to use a Proxy to achieve complex read/write accessor behavior | 20:39 | |
Perl6Noob: could you illustrate? I'm not sure what you mean. oh, you mean just "STORE => { $!x * 2 }" and "FETCH => { $!x = $^x / 2 }"? | 20:40 | ||
timotimo | i don't think that is enough, because of what it'll be called as | ||
TreyHarris | the second one wouldn't get $^x as the invocant? | 20:41 | |
timotimo | oh | ||
sorry, that's correct | |||
but the STORE one should get two arguments | |||
20:41
ggoebel joined
|
|||
TreyHarris | it does, I just tested it as above, except I flipped STORE and FETCH, sorry, thinko | 20:43 | |
20:43
Perl6Noob left
|
|||
TreyHarris | So how do you make a placeholder that matches the second positional and throws away the first? | 20:43 | |
oh, he's gone | |||
.seen Perl6Noob | 20:46 | ||
yoleaux | I saw Perl6Noob 20:38Z in #perl6: <Perl6Noob> least typing | ||
TreyHarris | duh, I meant before that. :-) | 20:48 | |
20:49
Perl6Noob joined
|
|||
TreyHarris | Perl6Noob: I'm just wondering if you were alluding to some other "shorter way" using blocks, like perhaps avoiding the Proxy constructor completely? | 20:50 | |
Because "STORE => { $!x = $^x / 2 }" doesn't work because you need two positionals and that only takes one. (a placeholder-less block will take any arguments and discard them, so FETCH is okay) | 20:51 | ||
Perl6Noob | TreyHarris: just blocks. For second one, I'd use -> $, $v { $!x = ½*$v }, but you can also write as { $!x = ½*@_[1] } | ||
Geth | perl6.org: b3660e91d0 | (Steve Mynott)++ | source/downloads/index.html Mention current Strawberry Perl dep for MSI |
20:52 | |
Perl6Noob | TreyHarris: also, you can shorten bare blocks and write them as :STORE{ $!x = ½*$^x } | ||
m: say '_' before 'a' | |||
camelia | True | ||
Perl6Noob | m: say { $^_; say ½×$^x }(42, 10) | 20:53 | |
camelia | 5===SORRY!5=== Error while compiling <tmp> Redeclaration of symbol '$^_' as a placeholder parameter at <tmp>:1 ------> 3say { $^_7⏏5; say ½×$^x }(42, 10) |
||
Perl6Noob | Oh right. | ||
Oh huh | |||
m: say { $^z; dd $_; say ½×$^x }(42, 10) | |||
camelia | Any $_ = Any 21 True |
||
Perl6Noob | oh ok | ||
TreyHarris | Perl6Noob: how with :STORE? :FETCH{ ... } works, because, again, you don't need the argument | ||
Perl6Noob | m: say { $^a; say ½×$^x }(42, 10) | ||
camelia | 5 True |
||
Perl6Noob | If you really wanted to do stuff | ||
TreyHarris: oh sorry, I meant with :FETCH{} | |||
TreyHarris | I think it looks odd to use two different syntaxes there. | 20:54 | |
Perl6Noob | :FETCH(* × 2) | 20:56 | |
Never mind :) | |||
TreyHarris | m: say { $^z; dd $_; say ×$^x}(42) | 20:58 | |
camelia | 5===SORRY!5=== Error while compiling <tmp> Preceding context expects a term, but found infix × instead at <tmp>:1 ------> 3say { $^z; dd $_; say ×7⏏5$^x}(42) |
||
Perl6Noob | TreyHarris: method double-x { Proxy.new: :FETCH{$!x × 2} :STORE(-> $, $y { $!x = ½×$y }) } | 20:59 | |
That's the shortest I can think of | |||
TreyHarris | I'm not quite sure what was supposed to happen no matter how many args it got | ||
Perl6Noob | TreyHarris: I think your system is missing fonts or something? There supposed to be a ½ before multiplication | 21:00 | |
as in: | |||
u: ½ | |||
unicodable6 | Perl6Noob, U+00BD VULGAR FRACTION ONE HALF [No] (½) | ||
Perl6Noob | And that code wouldn't compile even if you added it, 'cause the sig is for two args, but you gave only one | ||
TreyHarris | wait, how does "$!x = ×$y" work? What does unary × do? | ||
Oh, I see | 21:01 | ||
Perl6Noob | Hah | ||
TreyHarris | Yes, I can't read that one half | ||
Perl6Noob | m: say { ½×$^x}(42) | ||
camelia | 21 | ||
TreyHarris | I see "...ONE HALF [No] ()" | ||
Perl6Noob | Look! Unary × divides by 2! | ||
m: say { ¼×$^x}(42) | |||
camelia | 10.5 | ||
Perl6Noob | And now it divides by 4. It's time-sensitive operator :P | 21:02 | |
21:02
setty1 left
|
|||
TreyHarris | m: say ×6 | 21:02 | |
camelia | 5===SORRY!5=== Error while compiling <tmp> Preceding context expects a term, but found infix × instead at <tmp>:1 ------> 3say ×7⏏056 |
||
Perl6Noob | hah | ||
TreyHarris | m: say(×6) | ||
camelia | 5===SORRY!5=== Error while compiling <tmp> Preceding context expects a term, but found infix × instead at <tmp>:1 ------> 3say(×7⏏056) |
||
TreyHarris | m: my $x = ×6; $x.say | ||
camelia | 5===SORRY!5=== Error while compiling <tmp> Preceding context expects a term, but found infix × instead at <tmp>:1 ------> 3my $x = ×7⏏056; $x.say |
||
TreyHarris | hmm | ||
Perl6Noob | m: sub infix:<> { $^a + $^b }; say 22 | 21:03 | |
camelia | 4 | ||
Perl6Noob | ehehe | ||
21:03
bjz joined
|
|||
Perl6Noob | TreyHarris: There's no prefix ×. This is how it's all supposed to look like: i.imgur.com/fqmr3VT.png | 21:04 | |
TreyHarris | Sorry, I was looking at how cross-product works on scalars because I couldn't remember the differences between scalar cross-product and multiplication, and so I missed your joke | ||
Perl6Noob | scalar cross-product is for vectors and stuff. | 21:06 | |
I even invented a shorter trick to calculate it than what they teach at school. | |||
True Story! | |||
21:06
Perl6Noob left
|
|||
TreyHarris | I know, but I thought maybe somehow promoted to a vector and then de-promoted back to a scalar, somehow you were getting a one-half operation | 21:06 | |
21:07
itsame joined,
itsame left
21:08
itsame joined
|
|||
TreyHarris | m: (1 + q++).say | 21:09 | |
camelia | 1 | ||
TreyHarris | m: my \q = 0; (1 + q++).say | ||
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 is … |
||
TreyHarris | Crazy stuff like that :-P | ||
21:09
labster left
|
|||
timotimo | yeah, \q doesn't have a container to it | 21:10 | |
you can add one, though | 21:12 | ||
21:12
mcmillhj left
|
|||
timotimo | m: my \q := my $ = 0; (1 + q++).say | 21:12 | |
camelia | 1 | ||
TreyHarris | you should probably get at least a warning if you attempt to declare a siggilless variable with the same name as a quoting construct | ||
timotimo | oh, now i get why you brought this up | 21:13 | |
TreyHarris | m: q++ === "" | 21:15 | |
camelia | WARNINGS for <tmp>: Useless use of "===" in expression "q++ === \"\"" in sink context (line 1) |
||
TreyHarris | m: say so q++ === "" | ||
camelia | True | ||
timotimo | that's a hilarious way to trip up people | ||
21:16
Cabanossi left
|
|||
TreyHarris | "q++" to get the empty string is a stable of obfuscated Perl entrants. :-) | 21:16 | |
timotimo | q++, qq++, Q++, either of those | ||
21:17
Cabanossi joined
21:18
perlpilot joined
|
|||
TreyHarris | m: my @f = qw;;; @f.say | 21:18 | |
camelia | [] | ||
21:19
labster joined
|
|||
timotimo | m: say s+++ | 21:19 | |
camelia | 5===SORRY!5=== Error while compiling <tmp> Null regex not allowed at <tmp>:1 ------> 3say s+7⏏5++ |
||
timotimo | m: say s+a++ | ||
camelia | Use of uninitialized value of type Any 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 Nil |
||
timotimo | m: s+a++ | 21:20 | |
camelia | Use of uninitialized value of type Any 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 | bleh %) | ||
m: $_ ="waaaaaat"; s+a++; .say | |||
camelia | waaaaat | ||
timotimo | m: $_ ="at"; s+a++; .say | ||
camelia | t | ||
timotimo | m: $_ ="wat"; s+a++; .say | ||
camelia | wt | ||
TreyHarris | ach, you beat me | ||
timotimo | that's wat i meant | ||
azawawi | timotimo: github.com/azawawi/perl6-terminal-...n-sink.pl6 # .polyline primitive :) | 21:25 | |
TreyHarris | now, I just need to remember WHY I wanted a read-write attribute method in the first place 3 hours ago ;-) | ||
I learned lots of random tidbits along the way, though. Like, putting .resume in a CATCH when clause that can match both resumable and unresumable exceptions can make your program go into an infinite recursion.... | 21:29 | ||
21:38
mcmillhj joined
21:44
mcmillhj left,
mcmillhj joined
21:46
Cabanossi left
21:47
Cabanossi joined
21:49
ChoHag left,
mcmillhj left
21:54
anton_p left
21:56
azawawi left
21:59
itsame left
22:00
mcmillhj joined
22:05
mcmillhj left
|
|||
ugexe | it'll stop eventually... :) | 22:06 | |
22:10
Sound joined,
Sound left,
Sound joined
22:15
wamba left
22:16
mcmillhj joined
22:23
aindilis` joined
22:24
kyclark joined,
Praise- joined,
Praise- left,
Praise- joined,
smash left
22:25
Mithaldu left,
mcmillhj left,
sergot_ joined,
El_Che_ joined
22:26
integral joined,
integral left,
integral joined,
petercom1and joined,
rblackwe_ joined,
haxmeist1r joined,
tinita_ joined,
sivoais_ joined
22:27
Mithaldu joined
22:28
ggoebel_ joined,
ufobat left,
petercommand left,
ggoebel left,
aindilis left,
Praise left,
haxmeister left
22:29
Sound left,
Praise- is now known as Praise
22:30
smash joined
22:36
mcmillhj joined
22:42
mcmillhj left
22:43
tinita_ is now known as tinita
|
|||
kyclark | I would love to understand Perl 6 Grammars better, so I’ve started off with a simple one to parse commented lines (starting with “#”) from not: lpaste.net/355166 | 22:47 | |
It does not work, so I would love some help fixing this. | 22:48 | ||
22:55
cdg left
22:56
mcmillhj joined
|
|||
raiph | kyclark: looking now. have you used Grammar::Tracer? | 22:57 | |
gfldex | kyclark: your comments can only have one '#' without anything following it | 22:58 | |
kyclark | Ah, I remember someone pointing me to this before. How do I look at the docs for this? I don’t see it on modules.perl6.org | ||
skids | kyclark: your comment rule doesn't eat anything but the # | ||
gfldex | `zef install Grammar::Debugger` | 22:59 | |
github.com/jnthn/grammar-debugger | |||
23:00
mcmillhj left
|
|||
raiph | kyclark: in a P6 regex matches any character, including a newline | 23:01 | |
er, . in a P6 regex | |||
so <data> gobbles the rest of the file in one go, and (by default) tokens don't backtrack | 23:02 | ||
skids | kyclark: also, your TOP rule asks for at least one "line" (with no newlines needed) then followed by any number of newlines | ||
raiph | so the final \n+ fails | ||
kyclark | I was grasping at straws over how to write TOP. I found the brackets “[]” somewhere that made me think “many of these” but then there’s also “<line>+” which I think also means “one or more <line>s" | 23:03 | |
What do the “[]” mean? | 23:04 | ||
raiph | kyclark: it just brackets some atoms together | ||
without capturing (storing what matched) | |||
so you could, for example, write [ foo \n ]+ to match one or more lines (consisting of just foo and a newline) | 23:05 | ||
if you wrote ( foo \n )+ you'd do the same matching but you'd also store the result | 23:06 | ||
m: / < foo \n > / # presumably a compile error? | 23:08 | ||
camelia | ( no output ) | ||
raiph | m: say / < foo \n > / for "\n", 'foo', 42 ; # ah? | 23:10 | |
camelia | / < foo \n > / / < foo \n > / / < foo \n > / |
||
raiph | m: say m/ < foo \n > / for "\n", 'foo', 42 ; # ah? | ||
camelia | Nil 「foo」 Nil |
||
raiph | m: say m/ < foo \n > / for '\n', 'foo', 42 ; # ah? | ||
camelia | 「\n」 「foo」 Nil |
||
23:12
mcmillhj joined
23:14
espadrine_ left
23:17
mcmillhj left
|
|||
kyclark | Are there any docs on grammars I should read? | 23:22 | |
23:22
bjz left
|
|||
kyclark | E.g., I think I have a grammar that’s working, but how do I get the parsed data out? | 23:22 | |
raiph | m: grammar g { token TOP { [ '#'? \N+ \n ]+ } }; say g.parse: "foo\n#bar\n" | 23:24 | |
camelia | 「foo #bar 」 |
||
raiph | m: grammar g { token TOP { [ [ <comment> | \N+ ] \n ]+ }; token comment { '#' \N+ } }; say g.parse: "foo\n#bar\n" | ||
camelia | 「foo #bar 」 comment => 「#bar」 |
||
raiph | m: grammar g { token TOP { [ [ <comment> | \N+ ] \n ]+ }; token comment { '#' \N+ } }; say (g.parse: "foo\n#bar\n")<comment> | ||
camelia | [「#bar」] | ||
23:25
Actualeyes left
|
|||
kyclark | What does “^^” mean in a token? | 23:25 | |
raiph | m: grammar g { token TOP { [ [ <comment> | \N+ ] \n ]+ }; token comment { '#' \N+ } }; say (g.parse: "foo\n#bar\nbaz\n#quux\n")<comment> | ||
camelia | [「#bar」 「#quux」] | ||
raiph | m: grammar g { token TOP { [ [ <comment> | \N+ ] \n ]+ }; token comment { '#' \N+ } }; say (g.parse: "foo\n#bar\nbaz\n#quux\n")<comment>[1] | ||
camelia | 「#quux」 | ||
raiph | kyclark: start of a line; ^ means start of a string (which may contain multiple lines) | 23:26 | |
23:28
mcmillhj joined
|
|||
raiph | kyclark: docs.perl6.org/language/regexes#^^...nd_of_Line | 23:28 | |
timotimo | it'd be kinda cool if we could put the url of a gist or other kind of paste and follow it up with some extra code | 23:30 | |
23:32
mcmillhj left
|
|||
kyclark | It’s works if I say “token TOP { [ [ <comment> | <data> ] \n ]+ }” | 23:33 | |
But not if I say “token TOP { [ <line> \n ]+ }" | |||
Where “token line { <comment> | <data> }" | |||
lpaste.net/355166 | 23:34 | ||
23:35
mcmillhj joined
|
|||
kyclark | It fails to match “line” after it’s done parsing all the data, so it ends with a FAIL. | 23:38 | |
raiph | i'm getting failure in *both* cases | 23:40 | |
i think... | |||
23:40
mcmillhj left
|
|||
raiph | yeah | 23:41 | |
23:41
BenGoldberg joined
23:42
Guest48770 left
|
|||
raiph | token TOP { [ <line> \n ]+ } will fail because the last (empty) line won't match | 23:43 | |
token TOP { [ [ <comment> | <data> ] \n ]+ } fails for same reason | |||
both the comment and the data tokens require at least one character | 23:44 | ||
(btw, the comment perhaps ought to be '#' \N* rather than '#' \N+) | 23:45 | ||
timotimo | you should check out the % operator, which you can put after a quantifier and it'll mean "and in between the things that are quantified, match this" | ||
and %% is "optionally, match the in-between thing at the end once" | |||
raiph | timotimo: do you mention that because of the very specific scenario of lines of two types (comments and not-comments)? | 23:46 | |
timotimo | well, lines that end in \n, except at the end of the file where it may not have a \n in between | ||
raiph | ah | 23:47 | |
kyclark | This works: lpaste.net/355166 | ||
Dang, I have to go home now. Maybe I can call again sometime soon? | 23:48 | ||
raiph | m: grammar g { token TOP { [ <comment> | <data> ]+ %% \n+ } } | ||
camelia | ( no output ) | ||
raiph | kyclark: hope you do | ||
23:49
kyclark left
|
|||
raiph | m: grammar g { token TOP { [ [ '#' \N* ] | .+ ]+ %% \n+ } }; say g.parse: "a\n#b" | 23:50 | |
camelia | 「a #b」 |
||
raiph | m: grammar g { token TOP { [ [ '#' \N* ] | \N+ ] \n ]+ } }; say g.parse: "a\n#b" | 23:51 | |
camelia | 5===SORRY!5=== Error while compiling <tmp> Malformed regex at <tmp>:1 ------> 3 { token TOP { [ [ '#' \N* ] | \N+ ] \n 7⏏5]+ } }; say g.parse: "a\n#b" |
||
raiph | m: grammar g { token TOP { [ [ '#' \N* | \N+ ] \n? ]+ } }; say g.parse: "a\n#b" | 23:52 | |
camelia | 「a #b」 |
||
raiph | m: grammar g { token TOP { [ [ '#' \N* ] | \N+ ]+ %% \n? } }; say g.parse: "a\n#b" | 23:53 | |
camelia | 「a #b」 |
||
23:56
kurahaupo joined
|