Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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 ( [id://720008]=note: print w/replies, xml ) Need Help??


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

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.

  • Comment on Re^10: If you believe in Lists in Scalar Context, Clap your Hands

Replies are listed 'Best First'.
Re^11: If you believe in Lists in Scalar Context, Clap your Hands
by ysth (Canon) on Oct 28, 2008 at 18:44 UTC
      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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://720008]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-24 03:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found