in reply to Re: Re: Re: What should be returned in scalar context?
in thread What should be returned in scalar context?

You missed the significance of the phrase, The hidden assumption is that it only makes sense to impose scalar context when you are transforming a single element, so behaving badly if you try to transform multiple elements in scalar context is OK. Which is an explicit reference to the misbehaviour that you are pointing out.

Returning a nonsense result that the programmer will puzzle over makes sense to me because strange answers are a clue that you are doing something wrong. Returning something sort of sensible may make the mistake less immediately apparent. Putting an explicit error makes more sense still - if you want to put the effort out. Retrofitting a 2 line map into an existing function is easier than rewriting it.

  • Comment on Re: Re: Re: Re: What should be returned in scalar context?