in reply to Re: Use of wantarray Considered Harmful
in thread Use of wantarray Considered Harmful
If you don't like user subs returning different things depending on context, what is your feeling about buildins? If you don't like the fact buildins have different behaviour depending on context, why do you program in Perl? But if you don't mind, why do you mind if user subs do?
Good questions.
I think that built-ins can have different rules basically because they are built-ins, they are well documented, and they are finite. I have not memorized all the myriad ways that they change their behavior (see On Scalar Context), but I certainly know all the ones I've encountered with any frequency, and a lot of them do what I expected to begin with.
Adapting to the behavior of Perl built-ins is easy and well worth it. There aren't that many strange behaviors, they're all well documented, and I use them over and over.
User code, on the other hand, is mostly unknown, often poorly documented (if at all), far more vast, and far less useful. I don't want to have to be suspicious of every one of every sub I might encounter, and since the code I work on is not documented very well, I rely on examples from the code to tell me how something is to be used. There's more of it that I have to check, and the payoff is not very great because I won't spend my whole career working with it.
|
---|