Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^9: If you believe in Lists in Scalar Context, Clap your Hands

by ysth (Canon)
on Oct 28, 2008 at 06:27 UTC ( #719917=note: print w/ replies, xml ) Need Help??


in reply to Re^8: If you believe in Lists in Scalar Context, Clap your Hands
in thread If you believe in Lists in Scalar Context, Clap your Hands

If you can't have a list in a scalar context, how can you have the assignment of a list in scalar context?
This seems like a non-question. A list is a value, an assignment is an operation.


Comment on Re^9: If you believe in Lists in Scalar Context, Clap your Hands
Re^10: If you believe in Lists in Scalar Context, Clap your Hands
by mr_mischief (Monsignor) on Oct 28, 2008 at 14:11 UTC
    No. Just, no.

    People are saying there are only three little things to remember so their model is much simpler.

    The ideas that "list" is a "value", "assignment" is an "operation", and that a "list of scalars" in the syntax does not become a "list value" in the semantics are at least three more concepts to that abstraction.

    It's not a non-question, because I can answer how it happens: a list of scalars doesn't propagate its own value, and in an assignment is processed by the assignment operator which in a scalar context returns the last value in the list. This last value is typically the last value returned by the comma operator.

    Without the additional concepts of "list of scalars" vs. just "list", "list value" vs. just "list", the idea that the syntactic "list of scalars" is not what propagates the value, that the assignment operator does, and just what the comma operator is doing (or that it is an operator at all and not just part of a "list syntax"), the simple "three" rule explanation doesn't explain anything to the uninitiated.

        You and I both know you're not dense, so this miscommunication is probably because we're talking from different points of view.

        In order to explain to someone that one can see a list assignment in scalar context without having the list in scalar context, one must often first explain that there is a difference between a syntactic list of scalars and a semantic list of values (as merlyn did pretty simply elsewhere in the thread) and you may also have to explain what that difference is.

        In order to explain that the list to the left of a list assignment and the list to the right of a list assignment are both in list context and that the assignment itself is in scalar context (which is an edge case normally best left as separate statements for clarity anyway) one must explain to anyone who doesn't understand "context" not only "context" but also "operands", "side effects", and possibly "infix notation", "arity", and "associativity".

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://719917]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2014-08-30 08:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (291 votes), past polls