This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html Set by lizmat on 8 June 2022. |
|||
stevied | ok, had to do IO::Spec::Unix.splitpath for some reason | 00:15 | |
SmokeMachine | %h{ ||@k } wasn’t implemented yet, right? | 00:18 | |
guifa | SmokeMachine oh right! I forgot all about that! | 00:21 | |
SmokeMachine | m: my %h; %h{“a”; “b”; “c”} = 1; dd %h; my @k = <x y z>; %h{ ||@k } = 2; dd %h | ||
camelia | Hash %h = {:a(${:b(${:c(1)})})} Hash %h = {:a(${:b(${:c(1)})}), :x(2), :y(Any), :z(Any)} |
||
guifa will go to the corner and put on his dounce cap | |||
SmokeMachine | Yes, not implemented yet… :( | ||
It seems I was wrong! | 00:45 | ||
m: use v6.e.PREVIEW; my %h; %h{“a”; “b”; “c”} = 1; dd %h; my @k = <x y z>; %h{ ||@k } = 2; dd %h | |||
camelia | Hash %h = {:a(${:b(${:c(1)})})} Hash %h = {:a(${:b(${:c(1)})}), :x(${:y(${:z(2)})})} |
||
SmokeMachine | \o/ | ||
guifa: 👆 | 00:46 | ||
01:50
frost joined
02:27
frost left
02:30
frost joined
08:14
dakkar joined
13:23
Kaiepi joined
13:24
jgaz joined
|
|||
stevied | why does 0 ... Inf create an infinite loop while 0 ... * does not? | 13:41 | |
lizmat | there shouldn't be any difference? please make an issue if you can provide code showing the difference :-) | 13:42 | |
stevied | ah, ok. this was only happening in code that was getting .EVAL'd | 13:45 | |
ah, ok. this was only happening in code that was getting .EVAL'd | |||
thanks | |||
not sure why my code didn't throw an error. said "stub code" executed. anyway, ok. | 13:47 | ||
Anton Antonov | @guifa I think what you suggested should be put in a package named, say. `Hash::DeepLookup`. | 13:55 | |
@guifa I think what you suggested should be put in a package named, say, `Hash::DeepLookup`. | |||
13:58
jgaz left
14:24
frost left
15:20
jgaz joined
15:51
johnjaye left
16:10
jgaz left
16:32
dakkar left
|
|||
stevied | this code stops after the first for iterations: `(loop (my $i = 0; $i < 10; $i++) { say $i; })[3]` | 16:36 | |
but this code does not: `(for 1,2,3,4,5 { .say })[2];` | 16:37 | ||
anyone know why? | |||
this code stops after the first few iterations: `(loop (my $i = 0; $i < 10; $i++) { say $i; })[3]` | 16:38 | ||
Nemokosch | do you mean that the first one is lazy? | 16:43 | |
stevied | that's what I'm actually trying to learn about. laziness. So i'm fiddling with code examples to try to get a good handle on it | ||
guifa | huh, that's strange that it's lazy there | 16:44 | |
stevied | so a `loop` is lazy | 16:45 | |
Nemokosch | I'm not sure if this is a bug or a feature | ||
even $i stopped at 3 so the loop definitely didn't terminate on the condition | |||
guifa | per docs | ||
"Unlike a for loop, one should not rely on whether returned values are produced lazily. It would probably be best to use eager to guarantee that a loop whose return value may be used actually runs:" | |||
m: (eager loop (my $i = 0; $i < 10; $i++) { say $i; })[3] | 16:46 | ||
camelia | 0 1 2 3 4 5 6 7 8 9 |
||
stevied | yeah, so here's where I'm confused: docs.raku.org/language/list#Sequences | 16:47 | |
Nemokosch | so this is "undefined behavior" lol | ||
and indeed, lazy for also works, vice versa | |||
stevied | says "As it so happens, loops return Seqs." | ||
so `for` is a loop, right? | |||
Nemokosch | `for` is a loop but `for` is not a `loop` | 16:49 | |
question is, which one they meant xD | |||
first I read it as `loop`s but idk if it was meant that way | |||
stevied | it just says "loops". Does it mean `loops`s | ||
it just says "loops". Does it mean `loops`s? | |||
let me see if I can throw an is lazy on the for loop | 16:51 | ||
Nemokosch | you can say `lazy for` I tried that | ||
stevied | ok, yeah. huh. | ||
guifa | There something that could be cleaned up there for sure. | ||
A lazy for returns Seq, an eager returns List | |||
stevied | so I guess for loops are "eager" by default and a loop is "lazy" be default | 16:52 | |
Nemokosch | the return types differ for sure | ||
guifa | a while loop also produces a Seq | 16:53 | |
Nemokosch | a simple `for` returns a List | ||
while a simple `loop` returns a Seq | |||
Nahita | > Unlike a for loop, one should not rely on whether returned values are produced lazily | ||
Can someone translate this again in English? Does this mean, I can rely on returned values being produced lazily in case of "for" loops? | |||
stevied | ok, I see. and a List is not lazy | ||
Nahita | but it's not the case, is it | ||
Nemokosch | apparently it is the opposite but I think it can be read as the opposite as well | ||
stevied | yeah, I read that a few times and could not tell what it was saying | ||
Nemokosch | it says "whether", not "that" | ||
guifa | so basically, the only time you'll get a List is on an eager for | ||
Nemokosch | you should not rely on the outcome - which is apparently false? | ||
xD | |||
Nahita | :p | ||
16:55
Kaiepi left
|
|||
Nemokosch | anyway, there are multiple sources of confusion here | 16:55 | |
even if this is the intended behavior, it could be described more clearly | |||
or even stated at all | |||
Nahita | oh, as in "whether returned values are produced lazily *or not*" | ||
Nemokosch | "I can really on _whether_ a for loop is eager or not" | ||
Nahita | but then it's not saying anything in effect, i suppose... | ||
Nemokosch | like this only states consistency for me | ||
not an actual behavior xD | |||
guifa | "you should not rely on" means different compilers and different versions may result in a different behavior (with respect to laziness). This will only affect you if you have a loop with side effects | 16:56 | |
Nemokosch | and indeed | ||
(for 1..* { .say }) is a reactor melting | 16:57 | ||
it does try to generate it all | |||
is this surely not some syntax trickery? | |||
stevied | ok, so basically, the for loop is an exception and will do eager | ||
other loops will be lazy, but it can be compiler dependent. does that sound right? | 16:58 | ||
guifa | But basically, all loops return Seq *except* an eager for (and eager is the default for for) | ||
Nemokosch | pfff | 16:59 | |
does Roast have something about this? | |||
I guess it should | |||
17:05
jgaz joined
17:24
Kaiepi joined
|
|||
stevied | ``` | 17:34 | |
my $incremented = 0; | |||
my $var = do for <1 2 3 4> -> $d { }; | |||
say $var.^name; | |||
my $incremented = 0; | |||
my $var = lazy for <1 2 3 4> -> $d { }; | |||
say $var.^name; | |||
``` | |||
that spell it out nicely. first return List and second returns Seq | |||
19:20
MasterDuke left
19:34
MasterDuke joined
|
|||
I'm unable to retrieve a file in my module that is in the resource directory: | 20:45 | ||
``` | |||
my $blah = %?RESOURCES<examples/Lists/somefile>; | |||
say $blah; | |||
``` | |||
this just returns (Any) | |||
the file exists and it's in my meta file | |||
sienet_ja_LSD[m] | what if you add use lib $?FILE.IO.dirname; in the beginning? | 20:48 | |
umm, with the appropriate dir of course | |||
stevied | like this? `use lib $?FILE.IO.examples/Lists;` | 20:51 | |
SmokeMachine | m: (do for 1,2,3,4,5 { .say })[2] | ||
camelia | 1 2 3 4 5 |
||
sienet_ja_LSD[m] | FILE.IO.dirname gives you the current working directory, but you may add to it with .add, so: use lib $?FILe.IO.dirname.add("examples/Lists"); | 20:54 | |
might need .resolve.relative | 20:55 | ||
like there docs.raku.org/type/IO::Path#method_add | 20:56 | ||
stevied | doesn't work. just get "coud not evaluate arguments" | 20:57 | |
20:58
jgaz left
|
|||
sienet_ja_LSD[m] | use lib $?FILE.IO.dirname.add("examples/Lists").resolve.relative; | 20:58 | |
stevied | same error | 21:00 | |
sienet_ja_LSD[m] | hmm I'm getting that error too | 21:23 | |
Morfent | `$?FILE.IO.sibling(...)`? | 21:54 | |
sienet_ja_LSD[m] | %?RESOURCES should produce a Distribution::Resources object based on META6.json, but it's not doing it | 22:00 | |
stevied | does the module have to be run through make first? | 22:05 | |
sienet_ja_LSD[m] | not sure, but at least here it says that you should be able to run it with -Ilib directly from the source dir docs.raku.org/type/Distribution::Resource | 22:08 | |
stevied | This variable will work with the current repository chain structure, and will give you the right way to get to the resource independently of it being installed or not; | 22:10 | |
this has got to be a bug | 22:18 | ||
sienet_ja_LSD[m] | aye something's up | 22:19 | |
stevied | ok, got it working from a module | 22:22 | |
but it does not work from t/sometest.t | |||
weird | |||
github.com/rakudo/rakudo/issues/41...-762925099 | |||
sienet_ja_LSD[m] | well nice if it works at least half | 22:24 | |
lizmat | sienet_ja_LSD[m]: you must use -I. and have the META6.json correctly set up | 22:45 | |
sienet_ja_LSD[m] | I used, but I didn't do it like they told in that github discussion (write it in a sub) | 22:46 |