houseabsolute / Params-ValidationCompiler

Build an optimized subroutine parameter validator once, use it forever
https://metacpan.org/release/Params-ValidationCompiler/
Other
4 stars 5 forks source link

Interface is clumsy. #2

Closed 2shortplanks closed 8 years ago

2shortplanks commented 8 years ago

The interface whereby you compile the validator outside the body of the subroutine is clumsy and makes the code harder to follow.

I suppose with a modern perl you could move this inside the subroutine and cache the validator with a state variable, but this means that your validator compilation is happening at run time rather than itself being validated at compile time.

One possibility would be to provide an alternative interface, quite probably in a separate distribution that used pluggable keyword generation to produce a similar interface to a module that does not have a seperate compile stage but lift this work at compile time

autarch commented 8 years ago

Yeah, I agree that the UI is a bit gross. There are existing tools that provide much more featureful signatures for Perl, such as Kavorka, Method::Signatures, and Function::Parameters. I'm not sure that I have much to add on top of what those do, though I haven't looked to see to what degree they take advantage of inlining opportunties. From a quick glance it seems like Kavorka does inlining, at least.

That all said, I think for many folks the fact that this provides a very low magic interface might be a feature for this distro, not a bug.