🦋 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. |
|||
codesections | m: dd $*RAKU.compiler | 00:01 | |
camelia | Compiler rakudo = Compiler.new(id => "B0D6A0338B85BFBFE1C14B4AEDA60C0788BB2C25", release => "", codename => "", name => "rakudo", auth => "The Perl Foundation", version => v2020.07.66.g.2.db.92.e.04.f, signature => Blob, desc => Str) | ||
00:24
mowcat left
00:51
Altai-man joined
00:53
sena_kun left
01:03
_jrjsmrtn joined
01:05
__jrjsmrtn__ left
01:10
gugod left
01:13
gugod joined
01:17
gugod left,
gugod joined,
gugod left,
gugod joined
01:18
gugod left,
gugod joined
01:27
kotrcka joined
01:56
cpan-raku left
01:59
cpan-raku joined,
cpan-raku left,
cpan-raku joined
02:02
Noisytoot left
02:19
ilogger2 joined
02:20
go|dfish joined
02:35
fooist joined
02:38
Cabanossi joined
|
|||
fooist | Does anyone here know what the status/provenance is of the p6dists.json.gz file in CPAN (under /authors)? Sorry | 02:40 | |
Total raku #n00b | 02:41 | ||
Mostly wondering if it’s officially supported | 02:42 | ||
03:51
hungrydonkey joined
04:00
rockxloose joined
04:54
sena_kun joined
05:05
finanalyst joined
|
|||
moritz | fooist: iirc it's the file that package managers use to get a list of p6/raku distributions on CPAN | 05:08 | |
05:22
stoned75 joined,
epony joined
05:37
bocaneri joined
07:07
sjm_uk joined
07:10
sarna joined
07:12
hungrydonkey left
|
|||
sarna | o/ | 07:13 | |
Geth | ecosystem: 318bb77d0d | (Daniel Lathrop)++ (committed using GitHub Web editor) | META.list remove duplicate from META.list |
07:15 | |
ecosystem: 14877cef2d | (Juan Julián Merelo Guervós)++ (committed using GitHub Web editor) | META.list Merge pull request #526 from fooist/patch-1 remove duplicate from META.list |
|||
07:15
hungrydonkey joined
07:18
oddp joined
07:20
JJMerelo joined
|
|||
sarna | m: say join("hello ", "world"); say ("hello ", "world").join; # is there a viable use case for `sub join` when `*@list` has < 2 things in it? | 07:22 | |
camelia | world hello world |
||
JJMerelo | what's happened to "hello"? | 07:29 | |
tellable6 | 2020-08-16T21:06:49Z #raku <lizmat> JJMerelo github.com/Raku/advent/blob/master.../rfc200.md | ||
2020-08-17T22:52:12Z #raku <tbrowder> jjmerelo: how often are public-facing doc pages regenerated? do i need to trash my browser cache to see an update? | |||
JJMerelo | .tell tbrowder they are updated... from time to time. I'll do it today. | ||
tellable6 | JJMerelo, I'll pass your message to tbrowder | ||
sarna | JJMerelo: sub's signature is `sub join($separator, *@list)`, it thinks "hello " is the separator, and "world" is the list :( | 07:33 | |
it's very confusing when you first encounter it | |||
JJMerelo | Ah, right, of course... | ||
sarna | it could check the length of the list, but idk about performance loss/use cases I missed | 07:35 | |
07:44
stoned75 left
07:45
dakkar joined
07:48
xinming joined
07:54
stoned75 joined
|
|||
Geth | advent: 51018fd824 | (JJ Merelo)++ | 20th/articles/rfc265.md Minor modifications |
08:04 | |
08:11
hungrydonkey left
|
|||
Geth | ecosystem: 9f1c7aa568 | (JJ Merelo)++ | 2 files Rearranges test file So that it builds before testing for the existence of files. Closes #527 It also updates to use the latest version of the Docker container, which includes make and gcc |
08:32 | |
08:47
[Sno] joined
08:51
Altai-man joined
08:54
sena_kun left
09:02
rindolf joined
09:05
JJMerelo left
|
|||
tbrowder | .tell jjmerelo thnx, amigo | 09:56 | |
tellable6 | tbrowder, I'll pass your message to JJMerelo | ||
tbrowder | gracias | 09:57 | |
tellable6 | 2020-08-19T07:29:38Z #raku <JJMerelo> tbrowder they are updated... from time to time. I'll do it today. | ||
10:04
hungrydonkey joined
|
|||
sarna | is there really no way of preventing Nil propagation in method chains? I'd prefer it to fail fast :( | 10:13 | |
10:19
sjm_uk left
|
|||
sarna | can I maybe specify that I want to take `self:D`? not sure how to do that.. | 10:20 | |
oh no, that wouldn't work, since every method called on Nil returns Nil >.> | 10:21 | ||
10:25
[Sno] left
10:29
JJMerelo joined,
yangzq50 joined
|
|||
codesections | sarna: hmmm, you seem to be right, that doesn't work; I'm a bit surprised | 10:29 | |
m: class A { method n { Nil }; method non-nil(A:D $:) { 42}}; say A.new.n.non-nil | |||
camelia | Nil | ||
sarna | codesections: I've found this - stackoverflow.com/questions/601552...2#60155442 | ||
I don't find the reasoning (not having to insert null checks between chains) that convincing | 10:30 | ||
m: class A { method n { Nil }; method non-nil(A:D $:) { 42}}; my $foo = A.new.n; say $foo.non-nil | |||
camelia | No such method 'non-nil' for invocant of type 'Any' in block <unit> at <tmp> line 1 |
||
sarna | this dies (as it should), but you have to break up your method chains like this, every time.. | 10:31 | |
codesections | And that makes sense, given how assigning Nil works | 10:33 | |
sarna | yeah, but I'd say the default behavior is LTA - nothing less fun than hunting for a bug that propagated from something deep down the call stack | 10:34 | |
Nil carries absolutely no information | 10:35 | ||
codesections | m: class A { method n { Nil }; method non-nil(A:D $:) { 42}}; say (my $ = A.new.n).non-nil | ||
camelia | No such method 'non-nil' for invocant of type 'Any' in block <unit> at <tmp> line 1 |
||
codesections | that's pretty ugly, though | ||
sarna | it is, and the ugliness is O(n) where n is the number of methods in a chain | 10:37 | |
codesections | Yep! | 10:38 | |
Though, I think it'd work without the `my` which helps (very slightly) | |||
sarna | maybe raku has something like dart's cascade notation? that would help - stackoverflow.com/questions/494477...ot-in-dart | 10:40 | |
I may be onto something | 10:42 | ||
m: class A { method n { Nil }; method non-nil(A:D $:) { 42}}; $ = A.new.n; $ .= non-nil; .say | |||
camelia | No such method 'non-nil' for invocant of type 'Any' in block <unit> at <tmp> line 1 |
||
sarna | just replace all dots with `$ .=` et voila | 10:43 | |
codesections | Is that really less ugly than | 10:44 | |
m: class A { method n { Nil }; method non-nil(A:D $:) { 42}}; say ($ =A.new.n).non-nil | |||
camelia | No such method 'non-nil' for invocant of type 'Any' in block <unit> at <tmp> line 1 |
||
sarna | semicolons instead of parens? :D | 10:45 | |
mine would read better when splitted across multiple lines | 10:46 | ||
10:47
yangzq50 left
|
|||
codesections | oooh, I think I have something: | 10:47 | |
m: sub postfix:<‽>($a) { $ = $a}; class A { method n { Nil }; method non-nil(A:D $:) { 42}}; say A.new.n‽.non-nil | |||
camelia | No such method 'non-nil' for invocant of type 'Any' in block <unit> at <tmp> line 1 |
||
sarna | codesections: what's that? | 10:49 | |
oh darn it's your own operator | 10:50 | ||
I searched for it in the docs :DDD | |||
codesections | :D | ||
sarna | I love this | ||
also I hate this | |||
codesections | Agreed | 10:51 | |
sarna | noo you can't do ‽<newline>. :((( | 10:53 | |
all the methods have to be on one line | |||
10:54
[Sno] joined
|
|||
codesections | Hmmm, I've run into that problem with &.subroutine method calls too | 10:56 | |
tobs | it's probably better to extinguish that behavior at the source if you dislike it and don't want to change your entire code to a new method call operator: | 11:01 | |
m: Nil.^find_method("FALLBACK").wrap: -> $, $ { fail 'method call on Nil' }; class A { method n { Nil }; method non-nil (A:D $:) { 42 } }; say A.new.n.non-nil | 11:02 | ||
camelia | method call on Nil in block <unit> at <tmp> line 1 |
||
sarna | monkey patching Nil because I don't like a design decision? is that legal? | ||
tobs | by keeping the return value of that wrap call you can make the change lexical by unwrapping at scope exit | 11:03 | |
actually, I am not sure how stable wrapping core class's methods is | |||
sarna | that still seems heavy-handed, and confusing to whoever will come and look at my code | 11:04 | |
codesections | tobs: I like that approach. It strikes me that forgetting to unwrap that at the end of a scope could break … lots of things, though | ||
11:08
aluaces joined,
aluaces is now known as alberto
|
|||
codesections | sarna: I'm not getting an error when breaking the method chain across multiple lines with the new operator | 11:09 | |
11:09
alberto is now known as Guest47135
|
|||
sarna | codesections: where do you break it? I tried `foo?!<newline>.bar` and I kept getting "bogus operator" | 11:09 | |
tbrowder | hi, anyone use raku on win 10 as primary os? | 11:11 | |
11:12
xinming left
|
|||
tbrowder | if so, what is preferred raku installation method and editor? thnx | 11:12 | |
11:13
xinming joined
|
|||
tbrowder | win is not my cup of tea, but trying to wean grandson off python and such | 11:14 | |
as is taught in govt schools | 11:15 | ||
kawaii | Is there some way to switch the state of a Bool between True/False without doing some janky if statement saying `if $blah = True { $blah = False }`? :) | 11:22 | |
11:22
aborazmeh joined,
aborazmeh left,
aborazmeh joined
|
|||
Altai-man | kawaii, $blah = !$blah2? | 11:22 | |
kawaii | (implying I don't know the state of the Bool, I just want to switch it regardless) | ||
Altai-man | $blah = !$blah? | ||
kawaii | ah :D | ||
wait really | 11:23 | ||
this is a thing | |||
codesections | sarna: here's the code that was working for me with newlines gist.github.com/codesections/445e2...aac75d5462 | ||
kawaii | Altai-man++ | ||
11:23
xinming left
11:24
xinming joined
11:25
hungrydonkey left
|
|||
codesections | kawaii: and you don't really need the final `?`, though it might make the expression clearer, at least to some readers | 11:26 | |
kawaii | codesections: trust me, no one is capable of reading anything I write :) | ||
codesections | :D | 11:27 | |
sarna | codesections: repl.it/repls/OnerlookedAngryClimate#main.raku take a look here, without line 8 it works fine | 11:28 | |
codesections | hmm, odd. I *bet* that's something to do with the precedence/associativity of the operator, but I'm not sure. docs.raku.org/language/functions#Precedence | 11:31 | |
SmokeMachine | is there a way of getting the block that called the current block? | 11:35 | |
11:38
JJMerelo left
|
|||
codesections | SmokeMachine: I assume CALLER doesn't do what you want, because you want the actual _block_ and not a way to look up symbols in that block? | 11:42 | |
SmokeMachine | codesections: it would be... but it doesn't seem to work inside a Proxy's fetch block... :( | 11:46 | |
11:48
hungryd22 joined
|
|||
SmokeMachine | I was trying to do something like this to make rerun every block where the variable was used when it changes it value: | 11:50 | |
m: my %blocks is SetHash; my $a := Proxy.new: FETCH => sub fetch(|) { say CALLER; %blocks{CALLER} = True; 42 }, STORE => -> $, | { .() for %blocks.keys }; sub bla { say $a }; bla; $a = 13 | |||
camelia | (CALLER) Cannot invoke this object (REPR: Uninstantiable; CALLER) in block at <tmp> line 1 in block <unit> at <tmp> line 1 (CALLER) (CALLER) (CALLER) (CALLER) (CALLER) (CALLER) 42 |
||
11:54
hungryd22 left,
hungrydonkey joined
|
|||
Geth | doc/default-0: 421864a707 | (Stoned Elipot)++ | doc/Type/Baggy.pod6 Current and explicit Baggy.default signature |
12:01 | |
doc: stoned++ created pull request #3565: Current and explicit Baggy.default signature |
|||
12:12
aborazmeh left
|
|||
kawaii | Is there a clean way of removing a value from an @array if what we try to `push` already exists? | 12:25 | |
andinus | why push if it already exists? | 12:27 | |
moritz | you mean, moving an element to the end? | ||
12:27
lichtkind joined
|
|||
kawaii | andinus: because the $end-user doesn't know if it exists or not :) but you're saying I should check first before pushing in my code? | 12:28 | |
12:28
Maylay joined
|
|||
kawaii | I was just wondering if there was some built-in logic | 12:28 | |
moritz | kawaii: does the order of elements matter? | ||
kawaii | nope | ||
moritz | then maybe a Set is the better data structure | 12:29 | |
because there adding an element that's already in there is a no-op | |||
kawaii | I was thinking Hash | ||
moritz | and checking if an element is in a set is fast, compared to an array | 12:30 | |
kawaii: a Set is basically Hash without values | |||
do you need to store values? | |||
kawaii | I don't, so you're probably right about using a Set | ||
moritz | I use hashes a lot in p5, but python has taught me to take sets seriously :D | 12:31 | |
lizmat | and then the SetHash variety, if you want a mutable one | ||
12:32
finanalyst left
|
|||
moritz | lizmat++ good point, forgot that sets are immutable by default | 12:32 | |
kawaii | ah, yes I need to add and remove from it regularly :) | ||
moritz: `my SetHash[Str] $monitored-channels;`, so once I've defined it, how would I `push` a value here? :) | 12:35 | ||
It's basically storing just a few hundred strings | |||
(but by default will be empty) | 12:36 | ||
moritz | my SetHash[Str] $monitored-channels .= new(); $monitored-channels<stuff> = True; | ||
docs.raku.org/type/SetHash | |||
kawaii | www.irccloud.com/pastebin/C0xdswFQ/ | 12:39 | |
12:39
stoned75 left
|
|||
kawaii | moritz: hey this is really cool :D | 12:39 | |
thanks! | |||
moritz | my pleasure | 12:40 | |
12:52
sena_kun joined
12:53
skids joined,
Altai-man left
|
|||
lizmat | kawaiiL it you're using a SetHash, you can also use the .set and .unset methods | 13:03 | |
m: my %sh is SetHash; %sh.set(1,2,3,4); dd %sh; %sh.unset(2,3); dd %sh | 13:04 | ||
camelia | Too many positionals passed; expected 2 arguments but got 5 in block <unit> at <tmp> line 1 |
||
lizmat | hmmm | ||
kawaii | lizmat: `$monitored-channels{$message.channel-id} = !$monitored-channels{$message.channel-id};` I'm doing it like this to flip between adding and removing based on the user running a command :) | ||
13:04
stoned75 joined
|
|||
lizmat | m: my %sh is SetHash; %sh.set((1,2,3,4)); dd %sh; %sh.unset((2,3)); dd %sh | 13:04 | |
camelia | SetHash.new(4,3,1,2) SetHash.new(4,1) |
||
lizmat | hmmm... I guess that a. needs documentation, and b. another slurpy candidate | ||
codesections | I have documenting that (and BagHash.add) on my to-do list | 13:05 | |
lizmat | codesections: could you create an issue for the above problem> | 13:06 | |
tobs | m: my $b = True; $b .= not; say $b # kawaii: another way to toggle a boolean without mentioning it twice | 13:07 | |
lizmat | ? | ||
camelia | False | ||
codesections | lizmat: will do! | ||
lizmat | codesections++ | ||
kawaii | tobs: there are too many ways of doing these things, raku has spoiled me :) | 13:08 | |
codesections | tobs: the only inconsistency there is that $b != $b _looks_ like it should do the same thing, but that means something else entirely :) | 13:09 | |
13:12
aborazmeh joined,
aborazmeh left,
aborazmeh joined
|
|||
tobs | yeah, I guess Raku made a concession to the widespread use of != there. | 13:12 | |
13:13
gnufr33dom joined
|
|||
codesections | agreed. In retrospect (and with the knowledge of how many people will know at least a little JS, with its broken comparitors), I kind of wish we'd gone with `!==` | 13:14 | |
lizmat | codesections: but you can | 13:15 | |
m: say 42 !=== 666 | |||
camelia | True | ||
lizmat | m: say 42 !== 666 | ||
camelia | True | ||
lizmat | prefix ! is a meta op in that context | 13:16 | |
so if you want your code to be more readable in that respect, you can | |||
codesections | Ok, fair point. But I meant that we could have not had `!=` be a comparison operator, which would have freed it up to be the negation operator with assignment | 13:17 | |
to keep the parallelism with .= and other assignment meta ops | |||
jdv79 | =! isn't good enough for you;) | 13:19 | |
codesections | jdv79: ha, I didn't know you could put the whitespace like that! | 13:21 | |
lizmat | m: sub infix:<!=>(\a,\b) { a = !b }; my $a != True; say $a | 13:26 | |
camelia | False | ||
codesections | :D | 13:27 | |
tobs | for the original task we'd want this to be "prefix mutating unary metaop"-lookalike though | 13:30 | |
m: sub prefix:<!=>($a is rw) { $a .= not }; my $b = True; say $b; say !=$b; say $b | |||
camelia | True False False |
||
13:35
lucasb joined
|
|||
AlexDaniel | lizmat: != and ≠are roughly the same in performance, !== is much slower | 13:40 | |
pretty much any uncommon syntax is several times slower | 13:41 | ||
rir | How to "redirect" $*ERR to $some-Str for a bit? | 13:42 | |
lizmat | AlexDaniel: nothing a "constant &infix:<!==> = &infix:<!=>" wouldn't fix | 13:44 | |
13:45
oddp left
|
|||
codesections | AlexDaniel: only "roughly the same"? I thought they _were_ the same operation | 13:45 | |
m: say &infix<!=> === &infix<≠> | |||
camelia | 5===SORRY!5=== Error while compiling <tmp> Undeclared routine: infix used at line 1. Did you mean 'index', 'indir'? |
||
codesections | m: say &infix:<!=> === &infix:<≠> | 13:46 | |
camelia | True | ||
rir | ^ s/for a bit/for more than one bit/ Ha! | ||
lizmat | codesections: they are the same | ||
AlexDaniel | lizmat: that's probably true | ||
lizmat: IIRC ≠required a bit of wiggling to make sure it works right and is fast at the same time, I guess indeed the same can be applied to other ops | 13:47 | ||
lizmat | m: dd &infix:<≠>.name # they're aliased | 13:48 | |
camelia | "infix:<!=>" | ||
lizmat | so there is *no* runtime overhead | 13:49 | |
m: my $a = 42; for ^1000000 { my $b := $a != 666 }; say now - INIT now | |||
camelia | 0.02375516 | ||
lizmat | m: constant &infix:<!==> = &infix:<!=>; my $a = 42; for ^1000000 { my $b := $a !== 666 }; say now - INIT now | 13:50 | |
camelia | 0.0409685 | ||
lizmat | m: constant &infix:<!==> = &infix:<!=>; my $a = 42; for ^1000000 { my $b := $a !== 666 }; say now - INIT now | ||
camelia | 0.0269728 | ||
lizmat | m: my $a = 42; for ^1000000 { my $b := $a != 666 }; say now - INIT now | ||
camelia | 0.024267 | ||
lizmat | m: my $a = 42; for ^1000000 { my $b := $a != 666 }; say now - INIT now | ||
camelia | 0.0246294 | ||
lizmat | m: constant &infix:<!==> = &infix:<!=>; my $a = 42; for ^1000000 { my $b := $a !== 666 }; say now - INIT now | ||
camelia | 0.04128212 | ||
AlexDaniel | not enough iterations and possibly too much stuff optimized away | ||
lizmat | yeah, but anyway, in the same ballpark | ||
codesections | Is `note $msg; exit 1` (or other non-zero number) the preferred way to exit a CLI app when printing an error msg to the end user? I thought `die $msg` would be better, but it adds `===SORRY!===`, which the end user doesn't really need to see... | 13:56 | |
lizmat | codesections: that's how I would do it if it was a compile time error and I would want to get rid of the SORRY | ||
codesections | lizmat++ | 13:57 | |
(someday, I need to understand Raku's notion of "compile time" better. The error I encountered was based on calling EVALFILE on a file that the user passes in with a CLI flag... and yet that's a compile-time error? I guess because EVALFILE is "compiling" the file before/as it runs it? | 13:59 | ||
) | |||
lizmat | yup | 14:00 | |
moritz | yes, compile and run time can be nested in each other | ||
EVAL/EVALFILE nests a compile time inside run time | |||
lizmat | one of the cases of tormenting the implementor :-) | 14:01 | |
moritz | and BEGIN (and other constructs) nest in a run time during compile time | ||
tobs | rir: I think you would need to wrap a Str inside an IO::Handle like interface and `temp` assign that to $*ERR. There is a module for that: github.com/hoelzro/p6-io-string | 14:02 | |
14:02
aborazmeh left
|
|||
codesections | wow. That's all crazy powerful. But also makes some things a bit harder to reason about. I'm used to thinking of "it's done at compile time" as "it's free at runtime". But I guess that isn't always true with Raku | 14:02 | |
(Which might matter as we start doing more compile-time programming with RakuAST) | |||
rir | codesections: Tanstafl. tobs: Thanks. | 14:04 | |
codesections | rir: fair | ||
Geth | doc/baggy-bool-eg: 2ce6a8f169 | (Stoned Elipot)++ | doc/Type/Baggy.pod6 Fix example output |
14:09 | |
doc: stoned++ created pull request #3566: Fix example output |
14:10 | ||
14:10
sarna left
14:15
aborazmeh joined,
aborazmeh left,
aborazmeh joined
14:16
rockxloose left
14:17
mtj_ left,
MilkmanDan joined
14:18
wamba joined
14:19
aborazmeh left
|
|||
Geth | doc: 2ce6a8f169 | (Stoned Elipot)++ | doc/Type/Baggy.pod6 Fix example output |
14:21 | |
doc: 44df452c0b | (Will Coleda)++ (committed using GitHub Web editor) | doc/Type/Baggy.pod6 Merge pull request #3566 from Raku/baggy-bool-eg Fix example output |
|||
linkable6 | Link: docs.raku.org/type/Baggy | ||
14:44
guifa joined
|
|||
guifa | Um, wow. I figured this refactor would be a little bit faster but I wasn’t expeting it to be THAT much faster | 14:45 | |
tellable6 | 2020-08-18T21:26:41Z #raku <rir> guifa`: Thanks, I'll look at Comma. I've been mired in 'too much to learn' and forgot all about it. | ||
guifa | bit.ly/31bSRni | ||
14:46
wamba left
|
|||
guifa | Basically a three order of magnitude speed up. That should let loading of CLDR data be MUCH faster hopefully | 14:46 | |
15:00
gnufr33dom left
|
|||
xinming | m: my $x = "t"; class T { method t { "T v".say } }; (T."$x").raku.say; | 15:09 | |
camelia | 5===SORRY!5=== Error while compiling <tmp> Quoted method name requires parenthesized arguments. If you meant to concatenate two strings, use '~'. at <tmp>:1 ------> 3ss T { method t { "T v".say } }; (T."$x"7⏏5).raku.say; |
||
xinming | I know that T."$x"() works fine. Is it possible that in the future, raku can return the code for T."$x" kind of syntax? | 15:10 | |
guifa | I’ve always wondered about that requirement myself | 15:12 | |
moritz | what do you mean by "return the code for"? | 15:14 | |
return the method instead of calling it? | 15:15 | ||
codesections | and, relatedly, why does `T."$x"()` work, but T::("$x") does not? | ||
moritz | T.^lookup($x) | ||
codesections | moritz: I think xinming just meant "restore the functionality to be able to do" | ||
moritz | because methods live in a classes (or roles) method table, not in a scope | ||
and T::($x) is a lookup in a scope | 15:16 | ||
codesections: if you want the method object, and not call it, use T.^lookup($x) | |||
or T.^find_method($x); the two differ a bit when it comes to role and auto punning -- cannot remember which one is better for your use case right now | 15:17 | ||
codesections | yeah, I get all that :). I've been diving pretty deep into these introspection methods | ||
I'm saying that there's some special casing to get T."$x"() to work | |||
guifa | moritz: what’s the logic in requiring () though for calling? Obviously, normally you just need to do foo.call-method, and not foo.call-method(). It’s seemed odd to me to require the parentheses for the quoted method, though I’m sure there’s a reason | 15:18 | |
codesections | it has to resolve "$x" into `t`, and then lookup `t` in the T method table | ||
and it seems like the same special casing could just as easily apply to T::("$x"), and increase consistency by doing so | 15:19 | ||
moritz | guifa: that has to do with producing better error messages for accidentally using . as the concat operator (a common p5ism) | ||
guifa | perlisms strike again lol | ||
xinming | moritz: yes, I do mean return the method object with the specified name. | ||
hmm, Ignore me, I just realized, that calling method doesn't require the (). | 15:20 | ||
so, require $obj."$method-name"() is fine. ;-) | 15:21 | ||
guifa | The recent question on SO about adding a sub infix:«>>» keeps reminding me how catering to users from other languages can sometimes prevent fluent Raku users from doing certain things :-) | ||
moritz | on the one hand, I hate that so many p5isms shape current-day raku. OTOH I still use Perl 5 quite a lot, and those error messages often saved my butt | ||
guifa . o O ( although why anyone would really WANT to have a >> infix given how it already pulls at least double duty elsewhere… ) | |||
Geth | doc: 5ff724940a | stoned++ (committed using GitHub Web editor) | doc/Type/Baggy.pod6 Current and explicit Baggy.default signature (#3565) |
15:25 | |
linkable6 | Link: docs.raku.org/type/Baggy | ||
guifa | Also, random thought: andthen has basically a perfect precedence level | ||
linkable6 | DOC#3565 [closed]: github.com/Raku/doc/pull/3565 Current and explicit Baggy.default signature | ||
guifa | looser than commas so I can still use a colon method call, but tighter than postfix if | 15:26 | |
m: say “a”, “b” andthen say “c” if True | 15:27 | ||
camelia | ab c |
||
guifa | m: say “a”, “b” andthen say “c” if False | 15:28 | |
camelia | ( no output ) | ||
15:44
MilkmanDan left
15:51
MilkmanDan joined,
melezhik joined
16:01
mtj_ joined
16:20
dogbert11 joined
16:33
dakkar left
16:44
gabiruh joined
16:51
Altai-man joined
16:53
sena_kun left
|
|||
codesections | I mentioned this the other day, but I *really* like that this form works: | 17:07 | |
m: say 1 ==> {$_ + 1}() | 17:08 | ||
camelia | 1 | ||
codesections | m: say: 1 ==> {$_ + 1}() | ||
camelia | ( no output ) | ||
codesections | m: ( 1 ==> {$_ + 1}() ).say | 17:09 | |
camelia | 2 | ||
Geth | doc/list-eg-output: 7a0b5821fe | (Stoned Elipot)++ | doc/Type/List.pod6 Uniformize examples' output And while here, if we would like an example to produce an output, we might as well call `say` :) |
17:10 | |
doc: stoned++ created pull request #3568: Uniformize examples' output |
|||
codesections | (grr, getting the output to print correctly there made the syntax less pretty and undermined the point I was making. Oh well) | ||
17:19
Kaiepi joined
|
|||
xinming | m: class B { has $.a is rw; }; class T is B { method t () { $.B::a = 5 }; }; my $o = T.new; $o.t.say; | 17:21 | |
camelia | No such method 'B::a' for invocant of type 'T' in method t at <tmp> line 1 in block <unit> at <tmp> line 1 |
||
xinming | m: class B { has $.a is rw; }; class T is B { method t () { self.B::a = 5 }; }; my $o = T.new; $o.t.say; | ||
camelia | 5 | ||
xinming | In this case, Should $.B::a work as expected? | ||
hmm, ignore me, I think I realized, that $.meth is to mean $(self.meth) literally | 17:22 | ||
rypervenche | m: 1 ==> {say $_ + 1}(); | 17:37 | |
camelia | 2 | ||
rypervenche | codesections: Better? Or not what you wanted? | ||
codesections | Meh, close enough :) That's technically printing out the sum of $_ + 1 and then returning True from the block, and I was printing out the return value of the block. But I didn't really care about printing – I just like that we can pass args in from the left when it's clearer to do so! | 17:38 | |
17:40
sftp joined
|
|||
codesections | wait... it just occurred to me that we can also do 1.&{$_ + 1} | 17:41 | |
rypervenche | You win. | 17:44 | |
17:46
stoned75 left
|
|||
CIAvash | codesections: you can do `==> say()` too | 17:48 | |
17:58
Guest47135 is now known as aluaces
18:23
finanalyst joined,
bocaneri left
18:27
rindolf left
|
|||
brass | Hey, is there a way to limit floats to 2 decimal places when printing? | 18:28 | |
Or I guess it's a Num, not a float | 18:29 | ||
codesections | m: say '%.2f'.sprintf(20.sqrt) | 18:30 | |
camelia | 4.47 | ||
codesections | brass ^^^ | ||
docs are here: docs.raku.org/language/independent...ne_sprintf | 18:31 | ||
tobs | or 20.sqrt.fmt('%.2f') | ||
brass | Oh awesome, thank you | ||
codesections | tobs: oh, I didn't know about that one. Any idea why we have two such similar subs? Just for TIMTOWTDI? | 18:32 | |
tobs | pretty sure that fmt uses sprintf internally, but one is a method on (format) Strs, the other on Cool | 18:33 | |
codesections | makes sense | 18:34 | |
tobs | depends on what is the subject and what the object of that statement in your head, so yes TIMTOWTDI | ||
18:35
rindolf joined
18:42
xelxebar joined
18:49
cpan-raku joined,
cpan-raku left,
cpan-raku joined
18:53
wamba joined
18:55
melezhik left
19:05
guifa` joined
19:13
wamba left
|
|||
[Coke] | m: dd FatRat.^methods[*-1] | 19:35 | |
camelia | Submethod+{is-hidden-from-backtrace} BUILDALL = Submethod+{is-hidden-from-backtrace}.new | ||
kawaii | Is it allowed to wrap `when` in `if` within switches like this? www.irccloud.com/pastebin/jbKPVgPn/ | 19:37 | |
SmokeMachine | is there a way of changing the default class for @, % and $ on a specific class or on a class created by a specific metaclass? | 19:43 | |
I mean on attributes | 19:44 | ||
19:44
melezhik joined
|
|||
guifa` | kawaii: it appears to work okay | 19:46 | |
kawaii | guifa`: thanks for testing, not on my raku box :) | 19:47 | |
guifa` | kawaii If you've gome complex logic though, you can always use given $blah, $something | 19:48 | |
and then | |||
when 1, .not {Â }; when 2, .not {Â }, when 3, * {Â } | 19:49 | ||
19:57
melezhik left
|
|||
brass | Is it intentional that when I run something like &print.^methods I get completely borked output? | 20:03 | |
I get a ton of lines mixed in with the methods that just say "implementation detail and has no serviceable parts inside" and it makes the output unreadable | 20:04 | ||
Like this imgur.com/WaI2SZO | 20:07 | ||
Like I can use something like `&print.^methods.grep(!*.gist.contains(" "))' but that seems unnecessary | 20:11 | ||
lizmat | brass: what are you trying to achieve? | 20:12 | |
[Coke] | when you dump them methods, you're getting a gist of the methods, not the method names. | ||
brass | I just like checking out the methods on random things out of curiosity | ||
Ah ok I see | |||
[Coke] | m: &print.^methods>>.name | 20:13 | |
camelia | ( no output ) | ||
tadzik | m: say &print.^methods».name | ||
camelia | (<anon> <anon> <anon> gist multi <anon> leave <anon> <anon> <anon> <anon> <anon> <anon> soft <anon> <anon> package <anon> wrap unwrap <anon> <anon> <anon> onlystar raku cando <anon> <anon> <anon> <anon> candidates BUILDALL POSITIONS phasers returns WH… | ||
[Coke] | m: dd &print.^methods>>.name | ||
camelia | ("<anon>", "leave", "<anon>", "<anon>", "<anon>", "<anon>", "<anon>", "raku", "<anon>", "<anon>", "soft", "<anon>", "cando", "<anon>", "package", "gist", "<anon>", "onlystar", "<anon>", "<anon>", "multi", "<anon>", "<anon>", "<anon>", "<anon>", "wrap"… | ||
tadzik | ha :) | ||
[Coke] | so that's a little better. | ||
[Coke] shakes his old-man fist in the air. | |||
<-- too slow | |||
brass | Haha | 20:14 | |
tadzik has the ping advantage | |||
brass | What are the anonymous methods use for? | ||
[Coke] is also theoretically supposed to be paying attention to this presentation | |||
m: dd &print.^methods[0] | |||
camelia | ForeignCode <anon> = The 'ForeignCode' class is a Rakudo-specific implementation detail and has no serviceable parts inside |
||
[Coke] | m: dd &print.^methods[2] | 20:15 | |
camelia | ForeignCode <anon> = The 'ForeignCode' class is a Rakudo-specific implementation detail and has no serviceable parts inside |
||
[Coke] | m: dd &print.^methods[3] | ||
camelia | Method gist = proto method gist (Mu: |) {*} | ||
[Coke] | m: dd &print.^methods[2].Signature | ||
camelia | No such method 'Signature' for invocant of type 'ForeignCode'. Did you mean 'signature'? in block <unit> at <tmp> line 1 |
||
[Coke] | m: dd &print.^methods[2].signature | ||
camelia | :(|) | ||
tadzik | what a weird smiley face | ||
[Coke] | so you can poke around at the individual methods a bit if you want. | 20:16 | |
tadzik++ | |||
20:20
MasterDuke joined
20:33
Kaiepi left
|
|||
SmokeMachine | how can I do something like this (but that works) | 20:36 | |
m: class P is Proxy { has $!value; method new { ::?CLASS.bless: FETCH => -> | { $!value }, STORE => -> $value { $!value = $value } } }; my $p := P.new | |||
camelia | Cannot invoke this object (REPR: Null; VMNull) in method new at <tmp> line 1 in block <unit> at <tmp> line 1 |
||
lizmat | SmokeMachine: fwiw, I haven't been able to subclass Proxy :-( | 20:39 | |
20:40
stoned75 joined
|
|||
SmokeMachine | lizmat: :( | 20:40 | |
I think that's not the first time I do that question... | |||
lizmat | perhaps this is of use: gist.github.com/lizmat/4bb3e1d997f...85815a431d | 20:42 | |
stoned75 | hi it seems the independent routine join's first parameter has a default value, how can I trigger its usage ? | 20:43 | |
cf. github.com/rakudo/rakudo/blob/mast....pm6#L2146 | |||
lizmat | interesting: I don't think you can, and it's there for documentation / introspection only | 20:44 | |
gist.github.com/lizmat/4bb3e1d997f...85815a431d # for SmokeMachine | 20:45 | ||
stoned75 | that's what I thought but I don't get how it is useful | ||
lizmat | it could be considered dead code | 20:46 | |
stoned75 | ok :) | ||
raku-bridge | <primetoxinz> Hello, I'm working a module that is doing some native calls and I have a Pointer[int32] that I'm trying to get the int value out of. my $p = Pointer[int32].new(); # Native call that assigns the value say $p.deref; This causes a segfault. What am I missing? If I say $p I can see the value is visible NativeCall::Types::Pointer[int32]<0x2> | 20:51 | |
20:51
thundergnat joined
20:52
sena_kun joined
|
|||
Geth | ¦ doc: taboege assigned to codesections Issue Document the .add/.remove BagHash methods and the .set/.unset SetHash methods github.com/Raku/doc/issues/3569 | 20:53 | |
lizmat | m: say join' | ||
camelia | 5===SORRY!5=== Error while compiling <tmp> Two terms in a row at <tmp>:1 ------> 3say join7⏏5' expecting any of: infix infix stopper postfix statement end statement modifier … |
||
lizmat | m: say join | 20:54 | |
camelia | |||
20:54
Altai-man left
|
|||
lizmat | stoned75: the reason $sep = '' is in there | 20:54 | |
without it, the above would throw an error | |||
stoned75 | so a straigth join a is fancy way to get an empty string ? :) | 20:56 | |
lizmat | yeah, looks like :-) | ||
raku-bridge | <primetoxinz> Oh I think I realized part my the problem. I wasn't aware native CPointers don't allocate memory. how would I do that for an Pointer[int32]? | 20:57 | |
SmokeMachine | lizmat: but I still need to pass FETCH and STORE, right? :( | 20:58 | |
thundergnat | This fills me with nearly equal parts pleasure and horror: gist.github.com/thundergnat/76b406...a99b80715a | ||
I'm debating whether that is worth packaging up and releasing as a module. | 20:59 |