01:18
frost joined
03:13
discord-raku-bot left,
discord-raku-bot joined
|
|||
stevied | can someone explain why I'm getting an error with this: | 06:26 | |
``` | |||
for $config.IO.slurp.lines <-> $l { | |||
$l .= trim; | |||
``` | |||
error is: `Parameter '$l' expects a writable container (variable) as an argument, | 06:27 | ||
but got '# karabiner config file' (Str) as a value without a container.` | |||
why doesn't $l have a container? | |||
can I give it one? | |||
lakmatiol | I assume `my $l` would work | 06:38 | |
07:07
MasterDuke left
08:39
MasterDuke joined
|
|||
MasterDuke | doing `$l is rw` works | 08:40 | |
you need both `<->` and `is rw` | 08:42 | ||
gfldex | `-> $l is copy` makes more sense | 08:44 | |
MasterDuke | yep, probably so | 08:45 | |
09:05
dakkar joined
|
|||
lizmat | .lines doesn't produce containers | 09:08 | |
Nemokosch | which pretty much makes sense, lines of a file are constant values | 09:23 | |
12:20
frost73 joined
12:23
frost left
12:24
frost73 is now known as frost
12:46
frost left
|
|||
shift-eleven | is there any sort of overhead to the `is-prime` method for `Int` | 13:17 | |
dakkar | "over" with respect to what? I mean, it has to determine if the number is prime, and that's going to be slow for large numbersā¦ | 13:18 | |
MasterDuke | there is a different code path for numbers less than 2**31 - 1 that doesn't use the big integer library | 13:19 | |
shift-eleven | runtime overhead is what I meant | 13:21 | |
MasterDuke | not entirely sure what you mean, but i don't think so. it pretty much just directly callsĀ the moarvm implementation (that's where it splits in deciding to call into the big integer library or not) | 13:25 | |
shift-eleven | gotcha | 13:26 | |
stevied | thanks MasterDuke, that worked. Also an interesting answer here: stackoverflow.com/questions/706923...5#70694125 | 14:27 | |
oh, that's lizmat | 14:28 | ||
Nemokosch | š | 14:52 | |
stevied | anyone got any tips on how to speed up syntax highlighting using neovim? | 16:33 | |
thowe | speaking of, the neovim raku syntax plugin link on the Raku web site needs to be updated. | 16:39 | |
destroycomputers | stevied, try to set regex engine to 1 (set re=1), that helped quite a bit when I used neovim with raku | 16:45 | |
stevied | this looks cool: developpaper.com/real-time-syntax-...er-in-vim/ | 16:52 | |
no idea how to set it up, though | |||
17:08
[Coke] left
17:14
[Coke] joined
17:40
dakkar left
|
|||
gfldex .oO( .lines is so lazy, it doesn't even produce containers ) | 18:41 | ||
stevied | ok, been working on this for a couple hours. can't figure out what the problem is | 21:02 | |
I have this in a file in lib/Karabiner/Template.rakumod: | 21:03 | ||
``` | |||
unit class Template; | |||
has Str $.key; | |||
``` | |||
and I have this in lib/Karabiner/Templates/DoubleTab.rakumod: | 21:04 | ||
``` | |||
use Karabiner::Template; | |||
unit class DoubleTap is Template; | |||
has Str $!app1; | |||
method print() { | |||
say $!app1; | |||
say $!key; | |||
} | |||
``` | |||
I'm getting error in second file: `lib/Karabiner/Templates/DoubleTap.rakumod|11 error| Attribute $!key not declared in class DoubleTap` | |||
21:05
qorg11 left
21:06
qorg11 joined
|
|||
[Coke] | Yes, it's not declared | 21:07 | |
did you mean $.key ? | |||
even the parent doesn't have a $!key. | |||
but even if it did, you can't poke at the guts of the parent. | 21:08 | ||
MasterDuke | the parent does. but classes are very private in raku and yeah, i think the child needs to use the accessor | ||
[Coke] | so you'd still have to use $.key | ||
the parent does not have a $!key | |||
it has a $.key | |||
(not declared anyway) | |||
MasterDuke | that's sugar though to create an accessor for $!key | 21:09 | |
m: class A { has $.key = "hi"; method foo() { say $!key } }; A.new.foo | |||
camelia | hi | ||
[Coke] | (sugar) fair | 21:10 | |
stevied | yeah, $.key fixed it | 21:13 | |
this is confusing | |||
[Coke] | You can't refer to another classes attributes directly, even if you're their kid. | 21:14 | |
stevied | so I can't have $!key in parent and allow child to use it? | 21:15 | |
[Coke] | Correct. | ||
but you can use the accessors that you get with 'has $.key' | 21:16 | ||
This allows the parent to maintain consistency | |||
stevied | ok, thanks | ||
one other question: can objects be set up to accept positional parameters instead of named? | 21:17 | ||
[Coke] | ISTR there was an ovid presentation that covered this that might be worth finding (looking) | ||
MasterDuke | you'll need to create your own .new for that | 21:18 | |
stevied | is that the same as the BUILD method? | 21:19 | |
MasterDuke | m: class A { has $.key = "hi"; multi method new($key) { self.bless(:$key) }; method foo() { say $!key } }; A.new("bye").fooĀ Ā Ā Ā Ā Ā Ā Ā # something like this perhaps | 21:21 | |
camelia | bye | ||
stevied | I can't seem to have $.key in parent and set $!key in submethod BUILD() | 21:29 | |
this is what I've been struggling with | |||
MasterDuke | do you really need BUILD over TWEAK? | 21:30 | |
stevied | I got this: | 21:31 | |
``` | |||
has $.app1; | |||
has $.key; | |||
submethod BUILD($app, $key) { | |||
$!app1 = $app; | |||
$!key = $key; | |||
} | |||
``` | |||
trying to use positional arguments | |||
never heard of TWEAK. will it make my head explode? | |||
MasterDuke | you generally should try to use TWEAK before BUILD. it was added after the initial release of rakudo, so a lot of the docs don't mention it as much, but it's supposed to make the simpler kinds of things you used to have to use BUILD for easier to do | 21:32 | |
stevied | ok, thanks. I see it now in the docs. I'll play around with it | 21:33 | |
i gotta say, OO Moose in Perl was a lot easier than this | 21:34 | ||
MasterDuke | you can't do what i did in my example above? | 21:35 | |
stevied | oh, missed that | 21:36 | |
ok, that worked | 21:41 | ||
oh wow, now I can do positional constructors | 21:45 | ||
nice | |||
Sub | Hello friends. I'm trying to extract certain strings from a file and I'm not sure if grammars are the right fit for me. Would someone be able to point me in the right direction? Even just a term to search for in the documentation should help, I think. Here's my code. | 22:25 | |
``` | |||
use v6; | |||
grammar G { | |||
token TOP { | |||
^ | |||
.*? | |||
<expression>+ | |||
.*? | |||
$ | |||
} | |||
token expression { | |||
\{ \! (\w+) \} | |||
} | |||
Hello friends. I'm trying to extract certain strings from a file and I'm not sure if grammars are the right fit for me. Would someone be able to point me in the right direction? Even just a term to search for in the documentation should help, I think. Here's my code. | 22:27 | ||
I'm getting that I can perform captures with regex, but I'm wondering if I need to break the file into smaller chunks and try to make matches line by line, or something. It seems like maybe I need to use an action method to further operate on what I extract with the grammar, but I'm not too sure. | |||
``` | |||
use v6; | |||
grammar G { | |||
22:27
discord-raku-bot left
22:28
discord-raku-bot joined
|
|||
gfldex | m:``` | 22:56 | |
use v6.*; | |||
sub is-pentagon($c is raw) { (1+sqrt(1+24*$c))%%6 } | |||
sub P($n is raw) { $n*(3*$n-1) div 2 } | |||
my \integers = Channel.new; | |||
22:56
discord-raku-bot left,
discord-raku-bot joined
|
|||
With that I got it down to 1.671976079s and it even terminates! | 22:56 | ||
This is basically hypering by hand. :) | 22:58 | ||
[Coke] | if you're not specifying a language variant, you can skip the 'use' there. | 23:02 | |
Nice work. | |||
gfldex | wow. This is super sensitive to the batch size. With 40 Ints per batch I'm at 1.22098525s. | 23:04 | |
Note quite. `use v6.e` does include _PREVIEW. | 23:05 | ||
`v6.*` even | |||
[Coke] | Isn't that the same as no use v6 at all? | 23:06 | |
gfldex | Also, Channel doesn't throttle. So it may produce way more batches than are needed. | ||
With `$*KERNEL.cpu-cores - 1` it gets a wee bit faster. So the Channel is throttled ... accidentally. | 23:08 | ||
I believe we default to the latest stable. | 23:09 | ||
m: say $*RAKU; | 23:10 | ||
We do. |