|laziness, impatience, and hubris|
Re^2: RFC: User subroutine hinting interface for autodie (terse, unhidden)by pjf (Curate)
|on Mar 05, 2009 at 12:27 UTC||Need Help??|
Tye, this is excellent, and is exactly the sort of discussion and thoughts I was after. I really appreciate the feedback, even though I'm about to argue against most of it. ;)
I agree that having secret hints is going to result in some bad surprises. Those surprises are going to especially bad when a production system lags behind the development system, and an otherwise correct piece of code suddenly and silently becomes incorrect. That's a really great argument for getting hints out in the open.
However I don't think that users providing their own hints is a good idea. For starters, it means that users need to know much more about the subroutines they're using than they should. I shouldn't need to care about how File::Copy signals failure if I've delegated that task to autodie. I certainly don't want to provide hints every time I invoke the pragma, since that gives me extra chances to get them wrong.
As a lazy consumer, what I do need to know is that when I've delegated something to autodie that it's up to the task. In this sense, I like your idea of using '?' or some other marker to indicate that hints should exist for a given subroutine; I can trigger a compile-time error if they don't.
The other thing I can do is to have autodie insist that all autodying user subroutines have hints, and introduce a marker to indicate that a subroutine is allowed to use the defaults and be hint-free. I really like this, since it makes sure there are no surprises, and it keeps the common syntax both clean and safe. Unfortunately, it also breaks backwards compatibility with existing uses of the module. That's bad.
In any case, a way of signalling that we must know hints for a user-sub is essential for any interface that autodie makes public.
Thanks again for the input, it's hugely appreciated!
Perl Training Australia