Subject: | Use of K::D::Arg for optional arguments breaks API and is not documented as such |
Damian, thanks for this module, which I have been using in my own dists for a year or two. I also greatly enjoyed your Inception conference-talk video. :)
In v0.001015, my Test::OnlySome breaks: https://rt.cpan.org/Ticket/Display.html?id=131643 (thanks to ANDK for the report). The keyword declaration is:
keyword os(String? $debug_var, Var? $opts_name, Num? $N,
Block|Statement $controlled)
(e.g., to be used as `os ok(1, "this test passed (if it was run)")`).
In <= v0.001014, optional $debug_var, $opts_name, and $N are undef if the corresponding syntactic element is not present where the keyword is used. However, in v0.001015, all three are K::D::Arg instances, thus defined, regardless of whether the element is present. This contradicts the examples in the K::D POD, which still use `defined` to check whether an optional parameter is present. (E.g., https://metacpan.org/pod/release/DCONWAY/Keyword-Declare-0.001015/lib/Keyword/Declare.pm#DESCRIPTION ).
- If you still intend `defined` to be usable to check whether an optional parameter is present, would you please not pass a K::D::Arg instance?
- If K::D::Arg is the desired API change even for this situation, would you please update the documentation to show how to check for presence of the argument? If you wish, please feel free to use my current hack: https://github.com/cxw42/Test-OnlySome/commit/1986bfb40f04e240f0c2645fd82126a9bb719c4e#diff-cbf0d9a93b7e8b6018777e7e108fbe18R521-R541 . (However, there's almost certainly a better way!)
Thank you for considering this request!