in reply to Re^17: If you believe in Lists in Scalar Context, Clap your Hands
in thread If you believe in Lists in Scalar Context, Clap your Hands
Allow me to have those numbered for clearer reference:
- An operator imposes a context on its operands.
- Every operator decides what it returns based on context.
- An operator cannot return a list in scalar context.
Be prepared for questions of infix, prefix, and postfix forms, of arity, of precedence of the assignment operators, and of associativity. Be prepared for when someone asks if the commutative, associative, and distributive properties apply to assignment. When the syntactic sugar makes something appear to be mathematical and you must point out that it is only closely related, people will come up with all sorts of odd questions to confirm what can be inferred from math to the language.
I don't see how someone who's not a CS student or graduate gets either abstraction for free. Many of the people who program in Perl have studied little CS, have studied it informally, or have studied none of it at all. If they already have taught themselves along one line of thinking, which happens to be the one the docs seem to reinforce, then asking them to throw that away in favor of what's easier for someone already trained in CS might be asking a bit much.
The abstraction you present may help someone more in the long run, and probably will if they ever dig that deeply. It may turn them off the language completely in the short term, though, or delay their study of the particular topic. If they learn to think about it in a way that lets them write software and can change how they think about it later, I do not see the harm. The biggest complaints I've seen against the approach FunkyMonk took in Re: Scalar context of slice to explaining this situation in Perl is that it can be potentially misleading and that it can waste time to learn something more than once in different terms. I'm not sure either is such a terrible thing. Waiting to understand the actual way it happens inside perl might waste time, too.
I would rather encourage someone to learn whichever explanation makes more sense to them, with the caveat that one (the "simple" one) requires more information beforehand and the other one (the "complex" one) requires even more of the same rule and exception handling later.
|
---|