"Paul \"LeoNerd\" Evans" <leonerd@leonerd.org.uk> writes: > On Mon, 29 Aug 2022 16:28:32 -0300 > breno <oainikusama@gmail.com> wrote: > >> On Fri, Aug 26, 2022 at 2:30 PM Paul "LeoNerd" Evans >> <leonerd@leonerd.org.uk> wrote: >> >> > Plus I'm open to the idea I may still have missed some useful >> > abilities. The point of the RFC is not to create a fully-exhaustive >> > list, but to create the module with enough useful pieces to begin >> > with, in the hope that more will be added over time as the need >> > becomes apparent. >> > >> >> Given a subroutine declaration with signatures, I'd love to be able >> to at least see >> variable names, "types" and defaults. I am unaware of any way to do >> it, and I think it >> would be good for auto-documentation and code completion within >> editors. > > Seeing the names isn't too bad; it's just an inspection of the pad. > > Don't forget though that defaults come from expressions, not mere > values. > > sub f($x, $y = lc($x), $z = substr($y, 0, 5)) { ... } > > Here, it would be easy to say that: > > * min arity is 1 > * max arity is 3 > * parameter names are qw( $x $y $z ) Don't forget that the max arity can be undef, for slurpy args. We'd also need to expose the arity parity, for surpy hash args. E.g `sub f(%f)` has even parity, while `sub f($x, %y)` has odd parity, and `sub f($x, @foo)` has undef parity. - ilmariThread Previous | Thread Next