> On 7 Sep 2025, at 10:51, Marc Chantreux <[email protected]> wrote:
> I just gave a look on the new raku.org website and would like to
> congrat as it's really beautiful.
It is :-)
> Aside, I saw the example which reminds me an old dicsussion about
> "spurt parameters should be flipped" and there is a perfect exemple
> in the homepage:
>
> my $content = "example.txt".IO.slurp; # Read file
> $content ~~ s/Hello/Hi/; # Modify content
> spurt $filename, $content; # Write back to file
FWIW, I don't know why that example isn't doing:
$filename.IO.spurt($content)
as the same .IO coercer is used on slurping the file.
Or even as a one-liner:
$filename.IO.spurt( "example.txt".IO.slurp.subst("Hello","Hi") )
> which could be writen
>
> with "example.txt".IO.slurp {
> s/Hello/Hi/;
> spurt $filename, $_
> }
>
> but it we were able to write this:
>
> with "example.txt".IO.slurp {
> s/Hello/Hi/;
> .&spurt: $filename;
> }
>
I really dislike indirect object syntax used this way. What does this bring?
Why not just $filename.spurt($_) ?
> or if Str had a spurt method:
>
> with "example.txt".IO.slurp {
> s/Hello/Hi/;
> .spurt: $filename;
> }
Now *that* I find to be an interesting idea. The oneliner would then become:
"example.txt".IO.slurp.subst("Hello","Hi").spurt($filename)
which has a nice left-to-right feel.