|Syntactic Confectionery Delight|
Re^6: Use of wantarray Considered Harmfulby BrowserUk (Pope)
|on Dec 14, 2008 at 09:50 UTC||Need Help??|
Surprise, surprise! ...there is really only one good use of wantarray - to return an array or an iterator.
Hm. I agree that is a very good use case. And by itself, it justifies having context sensitivity. But once you have context sensitivity, it is certainly not the only good use case.
Another contention above is: "a subroutine should return one and only one type of entity.". Not only does the "iterator or array" assertion flatly contradict this--an iterator is either a scalar or a coderef; but certainly not an array--but from another view point, a subroutine can either return a list, or a scalar (or nothing). And a scalar is just a single element list. And nothing is the empty list.
That makes the return always of one type: a list of 0, 1, or many elements. Sounds pretty CS to me.
Context only becomes a problem when you stop thinking in Perl and start thinking in terms of some other language, or overarching paradymn. Just as Great Circle math becomes a problem if you are a flat earther.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.