| [Coke] | welcome aboard | 00:00 | |
|
00:53
arkiuat left
00:58
deoac joined
01:09
arkiuat joined
|
|||
| korvo | Solved it! Humming-Bird::Core::listen() requires a :no-block argument in order to actually `start` concurrently. | 01:13 | |
| disbot7 | <aruniecrisps> @librasteve sure I can do that, what exactly are you looking for? | 02:28 | |
| <aruniecrisps> Or can it just be any snippet? | 02:30 | ||
|
02:36
kylese left
02:37
kylese joined
02:49
deoac left
|
|||
| disbot7 | <jubilatious1_98524> @aruniecrisps have you tried NFKD decomposition? docs.raku.org/routine/NFKD | 03:04 | |
|
03:07
deoac joined
03:15
kylese left,
kylese joined
03:28
itaipu left
03:44
itaipu joined
04:11
Aedil joined
04:13
cm left
04:15
deoac left
04:20
lichtkind_ joined
04:21
cm joined
04:23
lichtkind left
04:38
itaipu left
|
|||
| Voldenet | jubilatious1_98524: it's not a contradiction – to group things you need a container for the grouping (a scope) and another value that escapes that scope is the only one preserved | 05:16 | |
| disbot7 | <jubilatious1_98524> @Voldenet so what's the 'escape key'? | 05:17 | |
| Voldenet | 'escape key' hm? | 05:18 | |
| what do you mean | |||
| m: my $result = do { my $a = 1; my $b = 2; $a + $b }; say $result # this is the pattern - $result gets assigned, but $a and $b are not preserved | 05:19 | ||
| camelia | 3 | ||
| Voldenet | it can get a lot more complicated with FINALIZER module for instance | 05:20 | |
| disbot7 | <jubilatious1_98524> Have you posted this do { ... } idiom previously? I might have missed it. | 05:21 | |
| Voldenet | yes a while earlier, but without 'do' | ||
| disbot7 | <jubilatious1_98524> It doesn't seem exactly like the Rust code you posted, which talked about immutability of variables manipulated in that blog code-example. | 05:23 | |
| Voldenet | in C# there's `using(var x = new SomeIDisposableImpl()) { … }` for tracking IDisposable values | ||
| it's a bit similar to using do-block | |||
| where you can `my $item = do { using FINALIZER; my $x = FoosRepository.new(:conn(await $connections.connect()); $x.items.fetch(:id(42)); }; ` | 05:25 | ||
| disbot7 | <jubilatious1_98524> In my Raku one-liners, I use BEGIN blocks all the time: unix.stackexchange.com/search?q=us...7738+BEGIN | ||
| Voldenet | obviously rust is a different kind of language, but you can make things immutable by turning it into List on the end | 05:26 | |
| for example | |||
| disbot7 | <jubilatious1_98524> Here are some (other) examples with state variables: unix.stackexchange.com/search?q=us...7738+state | ||
| <jubilatious1_98524> So I thought a hypothetical {STATE .... } keyword would replicate what you wanted to bring over from Rust. | 05:28 | ||
| Voldenet | I agree that BEGIN blocks are very useful, I still do time things with `now - BEGIN now` :> | ||
| though I guess do-block is just something that's totally unnecessary | |||
| it hardly does anything | |||
| so using it in this context is just not very obvious | 05:29 | ||
| disbot7 | <jubilatious1_98524> (Never heard of FINALIZER before...). | ||
| Voldenet | very cool module, it's something that should be in stdlib, basically it implements the IDisposable (C#) AutoCloseable (java) or Drop (rust) patterns | 05:31 | |
| so instead of directly using DBIish, you'd use method attaching .dispose to current scope | 05:33 | ||
| disbot7 | <jubilatious1_98524> do blocks make for loops imperative, I'll use it instead of (complicated)map calls: unix.stackexchange.com/a/734258/227738 | 05:37 | |
| Voldenet | I use for loops if I plan for them to have side effects | 05:38 | |
| .map is for things without side effects | 05:39 | ||
|
05:39
[Coke] left
|
|||
| disbot7 | <jubilatious1_98524> As long as you assign outside the do for loop, there doesn't seem to be any difference from map. | 05:41 | |
|
05:42
[Coke] joined
|
|||
| Voldenet | m: say do for ^10 { $_ * 10 } # this feels a bit weird to write compared to `(^10).map({ $_ * 10 })` | 05:42 | |
| camelia | (0 10 20 30 40 50 60 70 80 90) | ||
| Voldenet | of course, in the end they're both equivalent in what they do, so it's only a matter of preference | 05:45 | |
| disbot7 | <jubilatious1_98524> m: my @a = 0..9; @a = do for @a { <a b c d e f g h i j>[ $_ ] }; .say for @a.pairs; | 05:48 | |
| <jubilatious1_98524> raku -e 'my @a = 0..9; @a = do for @a { <a b c d e f g h i j>[ $_ ] }; .say for @a.pairs;' 0 => a 1 => b 2 => c 3 => d 4 => e 5 => f 6 => g 7 => h 8 => i 9 => j | |||
|
05:48
arkiuat left
|
|||
| SmokeMachine | For making stuff immutable, one could also use something like this: raku.land/zef:FCO/ValueClass | 05:48 | |
| Or maybe something like these: raku.land/zef:FCO/Functional::LinkedList raku.land/zef:FCO/Functional::Queue or raku.land/zef:FCO/Functional::Stack | 05:50 | ||
| Voldenet | (it's not the same as in rust - in rust mutability will stop some optimizations and immutability could make them possible) | 05:51 | |
| rust is just very different | |||
| SmokeMachine | Sorry, I’m not comparing with rust… (I don’t know rust) | 05:52 | |
| Voldenet | I mean, language knows the concept of mutability | ||
| in raku, language will asume that ValueClass is mutable | 05:53 | ||
| the only thing preventing mutation is Proxy STORE dying | 05:54 | ||
|
06:18
arkiuat joined
06:23
arkiuat left
|
|||
| Voldenet | the above example doesn't need for btw | 06:27 | |
| m: my @a = 0..9; @a = do for @a { <a b c d e f g h i j>[ $_ ] }; .say for @a.pairs; # this | |||
| camelia | 0 => a 1 => b 2 => c 3 => d 4 => e 5 => f 6 => g 7 => h 8 => i 9 => j |
||
| Voldenet | m: my @a = <a b c d e f g h i j>[0..9]; .say for @a.pairs; | 06:28 | |
| camelia | 0 => a 1 => b 2 => c 3 => d 4 => e 5 => f 6 => g 7 => h 8 => i 9 => j |
||
| korvo | LangJam GameJam is done. I made a little S-expression language declaring an idle game and a friend wrote a little scenario. I'll have a blog post ready in a day or two. | ||
| Voldenet | m: my $a = 0; my $b = 1; say do for ^10 { my $n = $b + $a; $b = $a; $a = $n; $n } # this is something that totally wouldn't work with .map | 06:29 | |
| camelia | (1 1 2 3 5 8 13 21 34 55) | ||
|
06:52
arkiuat joined
06:57
arkiuat left
07:26
arkiuat joined
07:31
arkiuat left
|
|||
| disbot7 | <jubilatious1_98524> m: my $a = 0; my $b = 1; for ^10 { my $n = $b + $a; $b = $a; $a = $n; print "$n " }; put(); | 07:44 | |
| <jubilatious1_98524> raku -e 'my $a = 0; my $b = 1; for ^10 { my $n = $b + $a; $b = $a; $a = $n; print "$n " }; put(); ' 1 1 2 3 5 8 13 21 34 55 | 07:45 | ||
| <jubilatious1_98524> @Voldenet did you not just show that the code worked without map? | 07:46 | ||
|
08:00
arkiuat joined
08:05
arkiuat left
08:18
Aedil left
08:28
arkiuat joined
08:33
arkiuat left
08:41
Sgeo left
|
|||
| Voldenet | yes, maybe I mistyped, but from my understanding it might not work with map | 08:54 | |
| m: my $a = 0; my $b = 1; my $x = (^10).map({ my $n = $b + $a; $b = $a; $a = $n; $n }); say $x, $x | |||
| camelia | (1 1 2 3 5 8 13 21 34 55)(1 1 2 3 5 8 13 21 34 55) | ||
| Voldenet | Yes, it happens to work as expected, maybe it's even documented | ||