00:28
Oshawott joined
00:31
arch left
02:00
Kaiepi left
02:23
frost joined
03:27
Guest35_ left
08:05
jaguart joined
08:33
Kaiepi joined
08:38
jaguart left
10:20
kueppo joined
|
|||
kueppo | Morning, I've a problem with the '^' twigil, idk how the order btw these positional parameters works and how to name them | 10:24 | |
Like this example from the rakudoc | |||
my @powers-of-three = 1,3,9…100; | |||
say reduce { $^b - $^a }, 0, |@powers-of-three; | |||
after reading through it I still don't understand | 10:25 | ||
thanks in advance | 10:26 | ||
lizmat | m: say (* / *)(4,2) # kueppo: do you understand that? | 10:29 | |
camelia | 2 | ||
lizmat | m: say (* / *)(6,2) # perhaps better | 10:30 | |
camelia | 3 | ||
lizmat | m: say (-> $a, $b { $a / $b })(6,2) | ||
camelia | 3 | ||
lizmat | m: say ({ $^a / $^b })(6,2) | ||
camelia | 3 | ||
lizmat | m: say ({ $^b / $^a })(6,2) | 10:31 | |
camelia | 0.333333 | ||
10:31
kueppo left
10:43
razetime joined
|
|||
Nemokosch | Are the variable names magic names, then? | 10:52 | |
lizmat | nope | 10:59 | |
m: say (-> $foo, $bar{ $foo / $bar })(6,2) | 11:00 | ||
camelia | ===SORRY!=== Shape declaration is not yet implemented; please use whitespace if you meant something else at <tmp>:1 ------> say (-> $foo, $bar⏏{ $foo / $bar })(6,2) Variable '$bar' is not declared. Perhaps you forgot a 'sub' if… |
||
lizmat | m: say (-> $foo, $bar { $foo / $bar })(6,2) | ||
camelia | 3 | ||
lizmat | m: say ({ $^bar / $^foo })(6,2) | ||
camelia | 3 | ||
lizmat | because "bar" is alphabetically before "foo" | 11:01 | |
m: say ({ $^foo / $^bar })(6,2) | |||
camelia | 0.333333 | ||
lizmat | m: say (-> $bar, $foo { $foo / $bar })(6,2) | ||
camelia | 0.333333 | ||
Nemokosch | This is a point block though | 11:16 | |
lizmat | point blocks are just syntactic sugar to create a block | 11:18 | |
they're all Callables | |||
it's just that WhateverCodes such as |* + 3" are a bit simpler blocks, because they can never have phasers | 11:19 | ||
* + 3 | |||
:-) | |||
there is internally no difference between the Callable part of a sub / method / pointy block / block of an if / elsif / for / loop etc. | 11:20 | ||
it's just that subs have a name, and that blocks can have phasers | 11:21 | ||
Nemokosch | That's besides the point (pun not intended) | 12:01 | |
lizmat | ok, then what is the point ? | 12:02 | |
Nemokosch | How does the compiler know which value is $^a and which is $^b | ||
lizmat | variables of the form $^foo *generate* the signature of the block in which they occur | 12:03 | |
m: -> $foo { $^bar } | |||
camelia | ===SORRY!=== Error while compiling <tmp> Placeholder variable '$^bar' cannot override existing signature at <tmp>:1 ------> <BOL>⏏-> $foo { $^bar } |
||
lizmat | m: dd ({ $^bar }).signature | ||
camelia | :($bar) | ||
lizmat | m: dd ({ $^foo + $^bar }).signature | 12:04 | |
camelia | :($bar, $foo) | ||
lizmat | the compiler alphabetically sorts the names to create the signature | ||
Nemokosch | > alphabetically sorts the names | 12:16 | |
👏 | |||
13:14
razetime left
13:45
Guest35 joined
14:05
kueppo joined
16:14
kueppo left
17:30
kueppo joined
|
|||
kueppo | trying to learn this ':' twigil | 17:32 | |
{ $:add; $add.say } :add<3> | |||
for the above snippet, raku say "You can't adverb { $:add; $add.say }" | |||
but this works and I would like to know why | |||
{ $:add; $add.say }() :add<3> | |||
and also the meaning of the error message | 17:33 | ||
Nemokosch | are you sure you meant $:add and not :$add? | 17:41 | |
oh no, actually $: exists, didn't know it | 17:43 | ||
my best guess would be that it's a parsing problem | |||
try :3add instead of :add<3> | 17:44 | ||
kueppo | I meant to use add => 3 | ||
I was trying to declare $:variable | 17:45 | ||
I'm passing a named parameter to the block but it doesn't work without this '()' and as you said it might be a parsing problem :] | 17:47 | ||
Nemokosch | :3add actually means add => 3 | 17:48 | |
kueppo | ah okay :] | 17:49 | |
Nemokosch | this is a shorthand when the value is a number | 17:58 | |
probably inspired by units of measure or something | |||
kueppo | very cool | 18:00 | |
Nemokosch | it would still be good to know why the supposedly equivalent forms don't seem to work | 18:02 | |
kueppo | would also like to know why there's no comma after (4, 5) is to a norm for named parameters? | 18:10 | |
say { $:add ?? $^a + $^b !! $^a - $^b }( 4, 5 ) :!add | |||
*is it a norm .... | |||
infact, I mean why is :!add even outside (4, 5)? it's also a parameter | 18:13 | ||
Nemokosch | asking the right questions, my man, I have no clue | 18:15 | |
this isn't the first structure I've heard of that takes parameters outside of the parens | |||
the feed operator also has this habit | 18:16 | ||
kueppo | feed operator? some of these names are confusing, what is it if I may ask? | 18:23 | |
18:23
frost left
|
|||
kueppo | okay found it | 18:24 | |
Morfent | `CALL-ME` has adverbs | 18:27 | |
like `:k` in `@xs[*]:k` | |||
m:``` | 18:29 | ||
say (1,2,3)[*, :k] # should be equally valid | |||
``` | |||
welp | |||
Nemokosch | why "method Int"? | 18:31 | |
Morfent | it's being interpreted as a positional position instead of a named argument | ||
m:``` | |||
say (1,2,3)[|\(*, :k)] # OK | |||
``` | |||
m:``` | 18:33 | ||
say (1,2,3)[*]:k # Maybe not | |||
``` | |||
18:35
kueppo left
|
|||
anyway, point i'm trying to make is `CALL-ME` and the various kinds of operators all support this syntax | 18:37 | ||
anyway, point i'm trying to make is `CALL-ME` and the various kinds of operators all support the adverb syntax | |||
though they're not strictly identical | 18:39 | ||
Nemokosch | This is sort of crazy territory | 19:15 | |
{ $:add; $add.say }() :3add | 19:16 | ||
is this "adverb syntax" or not? | |||
Ardal | Hello!! Does zef have a command to automate scaffolding modules as described here (docs.raku.org/language/modules#Pre...he_module) ? | ||
In other words, does zef have anything like `npm init` / `cargo new` | |||
? | |||
Hello!! Does zef have a command to automate scaffolding modules as described here (docs.raku.org/language/modules#Pre...he_module) ? | |||
In other words, does zef have anything like `npm init` / `cargo new`? | |||
lizmat | no, but App::Mi6 does | 19:20 | |
which is what I use :-) | |||
Morfent | that's `CALL-ME`, so yes | 19:25 | |
Nemokosch | hmmm | 19:26 | |
how does this relate to the fact that the same thing didn't work with :add{3} ? | 19:27 | ||
Morfent | this? `{ $:add; $add.say } :add<3>` | 19:29 | |
`:add{3}` would pass a block returning `3` | 19:31 | ||
Nemokosch | yuck | 19:33 | |
okay... so it seems like both `{ $:add; $add.say }(:add<3>)` and `{ $:add; $add.say }() :add<3>` work | 19:35 | ||
but it won't work without the parens | 19:37 |