🦋 Welcome to Raku! raku.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: colabti.org/irclogger/irclogger_log/raku
Set by ChanServ on 14 October 2019.
Geth advent: 47c574da12 | (Vadim Belman)++ | 20th/articles/rfc265.md
Add RFC 265
02:56
vrurg .seen jmerelo 02:57
tellable6 vrurg, I saw jmerelo 2020-08-16T17:00:18Z in #raku: <JJMerelo> lizmat I think I'm going to disable that. It never works...
Geth ecosystem/master: 4 commits pushed by (Jack Kuan)++, (Juan Julián Merelo Guervós)++ 07:13
andrzejku Hello 07:38
SmokeMachine m: say "a b c\td e f\ng h i".words 08:11
camelia (a b c d e f g h i)
SmokeMachine is there a way of finding the attributes a method uses on its body? 09:00
or only with RakuAST? 09:01
andrzejku do you think if Perl7 come it will eliminate Raku? 09:24
tadzik nah 09:27
not enough cool stuff in it :P
moritz perl7 still needs to solve all the problems that perl 5 has 09:36
[ptc] agrees with tadzik 09:37
moritz too easy to mix binary data and text; no good concurrency story; no function signatures; weak built-in OO etc. 09:38
[Coke] is there a way in comma to check for a newer version? 12:44
Altai-man [Coke], you mean plugin or standalone? 12:46
[Coke] the "complete" edition
"comma CP" 12:47
Altai-man Well, there is complete edition as a plugin for other jetbrains IDE and as an standalone IDE.
[Coke] standalone
Altai-man But anyway, for the plugin I don't think there are ropes at all for it, and standalone Comma warns you there is a new version, or at least it should, yes. 12:48
[Coke] ah, check is always on? ok.
[Coke] wonders if it is worth fighting to see if cro works on mac yet. :| 12:48
Altai-man Yeah.
pmurias andrzejku: Perl doing great would be awesome for Raku 12:49
Altai-man Well, no idea about cro. :S
pmurias andrzejku: it's not very likely that it's possible to incrementally evolve Perl (the language) into something as cool as Raku 12:51
moritz and the real question is, IMHO: since Perl 7 wants to be backwards incompatible with Perl 5, will there be a fork, and Perl 5 continued to be maintained? 12:52
moritz if so: I'd like to suggest that Perl 7 gets a new name, ideally not starting with "Perl" :-) 12:52
been there, done that
pmurias moritz: talked with mst (on #perl) and he was hoping the backward incompatibility will be stopped 12:53
pmurias anyway aren't major versions supposed to be a bit incompatible nowadays? 12:54
moritz yes, and everybody struggles with that
[Coke] I am definitely interested to see how the p5 community deals with these questions 20 years after the last time we tried this. 12:55
moritz there were reports in October of 2018 that 62% of websites on the Internet were still using PHP5, even though it was scheduled to EOL at end of 2018 12:56
[Coke] I suspect they have an idea of certain things to avoid. 12:56
moritz hard to find more up-to-date numbers, but it seems that php5 -> php7 wasn't such a huge success in terms of adoption
python2 -> python3 ... do I need to say more?
codesections I really like Rust's "edition" approach (which actually shares a fair bit with how we use `use` with our letter versions)
pmurias moritz: aren't a lot of website unmaintained tho? 12:57
codesections namely, that Rust keeps binary compatibility but can have backwards-incompatable syntax changes 12:58
moritz pmurias: that's part of the problem
[Coke] read an article about the 5/7 switch where the author was concerned that if there wasn't a 'use v7' required, there would be problems with users trying to run 7 code in a 5 and getting unexpected results, which certainly sounded familiar. 12:59
codesections (which doesn't let you change *everything* but lets you change a lot. It's basically what we'd have had if the plans to have a p5 mode had panned out)
codesections coke: Yeah, I kind of think Racket had the right idea, by requiring all programs to start with `#lang Racket`. They can *always* change that 13:00
s/coke/[Coke]/
[Coke] I'm only [Coke] because someone took coke - no worries. :) 13:01
moritz codesections: LOLCODE does even better, all programs start with "HAI 1.2" or so and such declare their version number
language version number, even
codesections moritz: Somehow, I feel like we'd have better luck with the pitch "we should all learn from Racket" than with "we should all learn from LOLCODE" :D 13:02
moritz en.wikipedia.org/wiki/LOLCODE#Example_2 these examples always make me chuckle, and remind me of pmichaud++'s awesome talk where he gave rakudo (then perl6 on parrot) a LOLCODE backend :D 13:03
codesections For some reason, it reminds me of emojicode (which, now that I think about it, would be pretty trivial to implement in Raku) www.emojicode.org/ 13:04
[Coke] the lolcode looks really familiar and I wonder if I have commits in that repo 13:06
codesections moritz: I'm legitimately jealous of the error handling in the Example 2 you linked. Handling errors like that (instead of with exceptions) is probably the biggest thing I miss when writing Raku 13:08
moritz time for LOLRAKU! :D 13:10
moritz is a bit jealous of python's "with" contextualizer 13:11
tadzik I wouldn't be surprised if Damian has already implemented it as a vim plugin or something :P
codesections LOLRAKU - slogan: «-o LOLs» 13:12
pmurias tadzik: how are think with Warsaw.pm?
moritz likes it
tadzik pmurias: ded
not just because of the pandemic either
codesections tadzik: I don't understand how he can spend all day writing Raku and still find the inner willpower to drop back to Vimscript. Now *there's* a tough language to love! 13:13
pmurias the pandemic doesn't seem to be going anywhere soon :(
pmurias would attend a meeting but doesn't do anything Perl/Raku related anymore 13:16
tadzik I don't do much either. I think most Warsaw.pm member's don't 13:18
jdv79 NY.pm has fizzled as well 13:19
i think the last time we had regular meetings might have been 3 or 4 years ago 13:20
pmurias tadzik: this likely doesn't help the groups existence :( 13:23
tadzik pmurias: indeed:(
[Coke] Albany.pm is long gone. :| 13:24
codesections Have any of y'all gone to that SF online meetup? 13:28
moritz has been to some Germany.pm meetings 13:29
sarna hey, I want all the arguments to MAIN to be required - is there an easy way for that? 14:13
apart from a chain of `unless $foo.defined`
codesections ! 14:15
jdv79 how does one exclaim nothing...
codesections m: sub f(:$named!) { say $named }; f
camelia Required named parameter 'named' not passed
in sub f at <tmp> line 1
in block <unit> at <tmp> line 1
codesections sarna ^^^ 14:16
jdv79 sarna: look at signatures and stuff in the docs?
sarna codesections: thanks!
jdv79: I searched for "required", nothing came up :(
jdv79 hmm, i guess it doesn't surface well - docs.raku.org/type/Signature#Optio..._arguments 14:18
sarna should've searched for "mandatory" :v 14:20
codesections :) 14:22
codesections This confuses me: 15:19
m: { POST { when ?True { False }}; 'foo'}
camelia WARNINGS for <tmp>:
Useless use of constant string "foo" in sink context (line 1)
codesections m: say { POST { when ?True { False }}; 'foo'}
camelia -> ;; $_? is raw = OUTER::<$_> { #`(Block|62789032) ... }
codesections grr
m: say { POST { when ?True { False }}; 'foo'}()
camelia foo
codesections Why doesn't ^^^^ error? The POST condition is violated. Does `when` just not work with POST? Removing the (always true) `when` gets the error I wanted 15:20
m: say { POST { False }; 'foo'}() 15:21
camelia Postcondition '{ False }' failed
in block at <tmp> line 1
in block <unit> at <tmp> line 1
tobs m: say do { POST { say "«$_»" }; 'foo' } 15:56
camelia «foo»
foo
terminatorul Hello
tobs m: say do { POST { when "foo" { say "yay" } default { say "nay" } }; 'foo' } 15:57
camelia 5===SORRY!5=== Error while compiling <tmp>
Strange text after block (missing semicolon or comma?)
at <tmp>:1
------> 3say do { POST { when "foo" { say "yay" }7⏏5 default { say "nay" } }; 'foo' }
tobs m: say do { POST { when "foo" { say "yay" }; default { say "nay" } }; 'foo' }
camelia yay
foo
tobs it seems that when works as intended
codesections tobs: I think I actually figured that issue out, sort of: the `when` blocks in POST work as I expected, but only if you add an extra `{}` 15:58
tobs I'd say your use of `when $bool-literal` doesn't do what you think
codesections No, that's not it. Look:
m: say do { POST { when "foo" { say "yay"; False }; default { say "nay" } }; 'foo' } 15:59
camelia yay
foo
codesections See, even though «yay» prints, the POST condition doesn't fail 16:00
m: say do { POST {{ when "foo" { say "yay"; False }; default { say "nay" } }}; 'foo' }
camelia yay
Postcondition '{{ when "foo" { say "yay"; False }; default { say "nay" } }}' failed
in block at <tmp> line 1
in block <unit> at <tmp> line 1
codesections But, with the extra block inside the POST, it works 16:01
Which I *think* is a bug (POST not treating itself as a block for when purposes). Do you agree?
tobs grmbl, it's certainly not nice. Normally a when block returns its last expression but something else (yes, probably POST) fails to pass that on. 16:04
I say as a complete layman
terminatorul Is there a way for me to `use SQL-Linux` on Linux, and `use SQL-Windows` on Windows (and `SQL-Mac` on Mac), in the same file ? And end up using the same symbols, but from the right module ? 16:08
tobs codesections: do you know `rakudo --target=ast`? If you want to get exposed to some internals and have some time to decipher the output, you could take a look at that. 16:09
terminatorul: the runtime version of `use` is called `require`. Determine the module name at runtime and then require the correct one. See docs.raku.org/language/modules#require 16:12
tobs except I don't know how to do the importing of symbols that use does, after require 16:16
vrurg terminatorul: there is a module on modules.raku.org. Named 'if' or something like this. 16:25
Yep, it's 'if': github.com/FROGGS/p6-if 16:26
tobs: The right implementation of system dependency should use a proxy-module. In this case one doesn't need to import symbols, it'd be ok to re-export them from, say, sub EXPORT. 16:27
Just don't forget to return a Map instance from EXPORT, not a Hash. 16:28
melezhik .tell dwarring: I've added "patch" for LibXSLT - github.com/melezhik/RakuDist/commi...b8c95cb192 , now it successfully tests on RakuDist - rakudist.raku.org/sparky/report/debian/655 16:48
tellable6 melezhik, I'll pass your message to dwarring
melezhik I am not sure if dwarring: is in raku/irc, but just noticed that someone tried to test LibXSLT on RkDist, so I assume it could be him :-))) 16:49
terminatorul Thank you guys ! Can I find more about the proxy-module use ? 17:16
vrurg terminatorul: proxy module is my term for a module which acts as a proxy for other modules. I.e. in your case it'd be SQL which would then load SQL::Linux or SQL::Windows and re-export their symbols. 17:31
terminatorul Is there no way to have the specific module resolved at compile time please ? 17:32
vrurg greppable6: sub EXPORT
greppable6 vrurg, 94 lines, 72 modules: gist.github.com/bec056f337ac012c65...d096f88036
vrurg terminatorul: see link to 'if' module above. 17:33
SmokeMachine m: role R[::T] is T {}; R[Int] # should this work? 17:37
camelia 5===SORRY!5=== Error while compiling <tmp>
T does not support inheritance, so R cannot inherit from it
at <tmp>:1
Geth ecosystem: fooist++ created pull request #526:
remove duplicate from META.list
18:12
codesections m: constant $a = constant $b = 42; say $a; say $b; 18:34
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable '$b' is not declared
at <tmp>:1
------> 3tant $a = constant $b = 42; say $a; say 7⏏5$b;
codesections apparently chained assignment doesn't work with constants ^^^^ :( 18:35
(Not a big deal, but a slight inconsistency/paper cut)
guifa` codesections: did my answer on SO make sense? 19:29
codesections guifa`: I _think_ so (and I just marked it as accepted) 19:31
I'd like to come back to it when I understand the internals a bit more/we have RakuAST
you said: «If your conditions are complex things like .is-prime and * %% 2, or even non-deterministic (smartmatching against a mutable object), it will either be difficult or impossible to know for sure.» 19:32
I don't _think_ that's right – or, at least, it seems like almost anything is Any
so the compiler could give up and make you handle all of Any
(in practice, that would mean requiring a `default {...}` case 19:33
)
guifa` What I mean is if the comparison value is subject to change 19:37
perhaps
when Foo.status { ... }
I can't imagine why you would do it in that way, but if you do, the .status will vary
And might be different each time the given block is run 19:38
codesections but the point of checking for exhaustive matching is that you've handled all possible values allowed by the return type constraint on Foo.status
(which, if not specified would be Any) 19:39
guifa` Unless it returns a Mu ;-)
codesections well, fine :) but a `default` case would still handle that – it would just force you to have one, with the compiler there to remind you 19:40
(and, when you *have* constrained the return type of Foo.status, exhaustive pattern matching could be much more useful 19:41
guifa` I'd just use a default { die "WTF code needs fix kthxbye" } and save myself the trouble personally ;-)
guifa` actually uses that in one of his parses lol
codesections Like, maybe Foo.status returns a subset of Int that corrisponds to HTTP status codes that your code handles 19:42
codesections If you add a new code to the subset, you have to remember to add it to the given/when construct 19:42
guifa` You could probably create a special when clause, and feed it some type of information about what to expect 19:43
codesections and, if you forget and the status code is rare, you can end up with "WTF code needs fix kthxbye" errors in production :)
Yeah, that's kind of what I was thinking re: RakuAST. Or maybe it'd be a special type of `given` block? 19:44
guifa` err yeah, I meant givne block
so maybe
given-all $value, $range-description { … }
codesections Hmm, I still think it'd be possible to do without the $range-description 19:45
and just have it be based on $value.WHAT 19:46
guifa` You'd want the range to describe needing all positive ints, all reals, etc. Subsets aren't very introspectable 19:48
codesections «Subsets aren't very introspectable» is that a forever thing, or a NYI thing? 19:49
guifa` Subset constraints can include code of arbitrary complexity so... inasmuch as code can be introspected :-) 19:52
consider subset Positive of Int where * > 0 19:53
There's (a) currently no way (that I know) to grab the constraint (beyond being an Int), but (b) if you could, it's a WhateverCode, so you'd need to pull that through, piece together how it works and… complicated lol 19:55
codesections Perhaps I am under-thinking this (or ignoring huge performance issues), but why couldn't you just store the constraint as a string? 19:57
guifa` I mean you could
But what if the constraint is
where { $^i > 0 && $^i mod 8 < 4 && ($^i ** 3 - 1).is-prime } 19:58
codesections :m subset Ugly where { $^i > 0 && $^i mod 8 < 4 && ($^i ** 3 - 1).is-prime }; my Ugly $a = -1 20:00
m: subset Ugly where { $^i > 0 && $^i mod 8 < 4 && ($^i ** 3 - 1).is-prime }; my Ugly $a = -1
camelia Type check failed in assignment to $a; expected Ugly but got Int (-1)
in block <unit> at <tmp> line 1
codesections I'd rather that message be «Type check failed in assignment to $a; expected an Ugly where { $^i > 0 && $^i mod 8 < 4 && ($^i ** 3 - 1).is-prime } but got an Int (-1) 20:01
»
guifa` Now *that* is one thing that where the error is LTA 20:01
codesections The current one, or the one I suggested :D 20:02
guifa` The current error message
codesections Yeah, that's all I meant by storing it as a string – which I know is just a minimum level of introspectability, but at least is something 20:03
rir Anything recommendedfor raku tidying, raku coverage, or counting lines of raku? 20:47
codesections I recall that there's a convention for declaring a multi with Bool flag that changes its behavior, but I can't find a concise way to declare it
something where the callsite usage is, e.g., `greet('tom') # OUTPUT «Hi, Tom»` and `greet('tom', :loud) # OUTPUT: «HI TOM!»` 20:49
MasterDuke rir: there's the MVM_COVERAGE_LOG=foo.log env variable to get a coverage report. there's modules.raku.org/dist/Perl6::Tidy:cpan:JGOFF for tidying, but i've never used it
codesections But the only way that's occurring to me to declare that is with a signature like `multi greet($name, Bool :$loud where .so) {...}`, which seems far more verbose than what I recall seeing. What's the cleaner way to do it? 20:50
rir: I'm not familiar with anything, though I've also been currious 20:51
rir MasterDuke: Thanks, MVM_COVERAGE_LOG sounds promising. I got no joy from Perl6::Tidy. Or Perl6::Parser which seems, by docs, a precursor to a tidier. 20:55
codesections ^
MasterDuke rir: iirc, you want to do something like foo.%d.log so multiple processes don't stomp all over each other. maybe it's %p? and Perl6::(Tidy|Parser) have suffered from the loss of drforr, but hopefully somebody can step up and adopt them 20:57
tobs codesections: maybe you saw `multi sub greet($name, :$loud!) { … }` but this candidate triggers when a loud named argument is mentioned, even if you pass `named => False`. The where clause using *.so is the only option I know at least. 21:02
*`loud => False`
codesections rir: re: counting lines of Raku – the two lines-of-code counters I tend to use (tokei and loccount) both count Raku lines of code but – frustratingly - neither detect Raku properly based on file extension. It'd be an easy PR for either project, though 21:04
tobs: Thanks, I bet that was what I saw 21:05
guifa` You could probably avoid the Bool bit by just doing :$loud! where True
tobs I suppose a `subset Adverb of Bool where *.so; sub greet ($name, Adverb :$loud) { … }` could make it less noisy 21:06
guifa` tobs++
Re coverage: Comma has some coverage support for tests I believe, but I haven't used it yet
codesections guifa`: and it couldn't be `where True` because smartmatching
guifa` I forgot about Boolean smartmatching being a bit unintuitive 21:07
tobs and if the subset is called Adverb it should be :$loudly, of course :)
codesections yeah, but at least the errors are clear
tobs++
rir codesections: Thanks. I will check those out. 2 out of 3--line counter and coverage logger. Great! 21:10
codesections tobs: guifa: Oooh, I know, I'll just add `Bool % where *.values.so` as a constraint to the proto signature, and then be able to use :$loud! or similar in the multis 21:12
(that'll break if I add other named parameters, but that's fine) 21:13
rir guifa`: Thanks, I'll look at Comma. I've been mired in 'too much to learn' and forgot all about it. 21:26
tellable6 rir, I'll pass your message to guifa`
codesections m: role A[::T] {has T $.a; method a(-->T) {$!a}}; A[Int].new(a => 1).a 22:42
camelia Type check failed for return value; expected T but got Int (1)
in method a at <tmp> line 1
in block <unit> at <tmp> line 1
codesections Why does ^^^ die?
codesections It looks like it's declaring the attribute $a to be of type T, and then asking for it back and guarenteeing that it's still of type T. But it's not a T anymore, somehow? 22:43
I think it's being wrapped in a Scalar, but I'm not sure why/how – and, oddly, adding `<>` to the method doesn't seem to help 22:44
This adds to my confusion here: 22:47
m: role A[::T] {has T $.a; method a() {dd $!a.VAR.WHAT; $!a}}; dd A[Int].new(a => 1).a.VAR.WHAT
camelia Scalar
Int
codesections It looks like $!a is a Scalar right _before_ it's returned, a Scalar _when_ it's returned (which is what caused the error before), but an Int as soon as it has been returned. 22:48
Is there some sort of auto-scalarization/de-scalarization going on here that I don't know about?
codesections Oh, wait, I just read camelia's error message and now I understand (in partial defense, I get a different msg in my local REPL). 22:56
codesections It's just that the T := Int binding doesn't last long enough for the return value check. I get it. 22:56
[Coke] m: role A[::T] {has T $.a; method a(-->T) {$!a}}; A[Rat].new(a => 1).a 23:27
camelia Type check failed in assignment to $!a; expected Rat but got Int (1)
in block <unit> at <tmp> line 1
codesections m: role A[::T] {has T $.a; method a(-->T) {$!a}}; A[Rat].new(a => 1/1).a 23:56
camelia Type check failed for return value; expected T but got Rat (1.0)
in method a at <tmp> line 1
in block <unit> at <tmp> line 1
codesections (related: Why do I get the much less helpful error msg «Died with X::TypeCheck::Return» when I run that code locally? Odd) 23:57