Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Apparently the second example used to be the default behavior. Why it was changed I don't know.

    It appears that even the author is puzzled as to why he did that [].

    However, I've heard people didn't want it changed back because it would break their code,

    Indeed, the proposal got many complaints [] that this would break backwards compatibility, so the author decided not to go ahead [] (after accepting a syntax improvement that made things not quite so bad).

    so I think my patch is completely backwards compatible.

    Unfortunately not, for reasons previously discussed [] (twice []): UNIVERSAL is universal.

    It occurred to me that having the method croak when invoked in void context might work: this would still be backwards incompatible, but not for anybody who's currently checking the return value and doing something appropriate with it. Code which is already invoking it in void context is broken anyway (quite possibly because the author was expecting errors to be fatal) and this behaviour change would probably be an improvement.

    The main disadvantage I can see of doing this is that if you get into the habit of calling it without checking the return value then it becomes too easy to unthinkingly (or even unknowingly) do so somewhere that isn't actually void context, such as in the final line of a subroutine.

    Perhaps just having a warning when invoked in void context would be better: the interface would still be always to check the return value, but at least you would often get warned if you forget (or hadn't yet realized).