On 10/10/24 00:24, Marc Chantreux wrote:
hello People,

As I started to write some code again, I gave a talk about "why Raku for
the research community" (It's in french, sorry about that).

I had positive feedbacks and some questions so I wrote the ones I
remembered there:

https://git.unistra.fr/mc/talks/-/blob/stable/why_raku/raku.slides?ref_type=heads#L364

the "things I miss from perl" triggered me.  Any help about it ?

regards


Hi Marc,

liz made a port of the P5 Env module:

https://github.com/lizmat/Env

For your multi-has, there is already

has ($.foo, $.bar, $.baz) is rw

and with a role that's parameterized on a list of strings for attribute names you can have the role's ^parameterize method build up the attributes and also a method new that does the @attrs Z=> @args step for you.

That would probably make for a good ecosystem module. Something like Tuple::Named, because it's a bit like python's namedtuple?

On the way out, you may find the Capture method interesting, which by default gives you named parameters in it for each attribute.

call .pairs on the Capture, then you'll have Pair objects which already .Str to key and value joined by a \t by default.

I'm not sure what you mean by $o->$_ exactly, my guess is the @user{ @attrs } = ... bit?

For addressing an attribute by its name, you would want to use "method named by string" syntax: $foo."the_name_is_$foo"() which you can then assign to if you like.

Hope that helps!
  - Timo

Reply via email to