Your skill will accomplishwhat the force of many cannot 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 ( #720008=note: print w/replies, xml ) Need Help??

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
Please take no offense, but your question still reads to me like "If eggs aren't utensils, how can an omelette pan be a utensil". Maybe you could try rephrasing it for the dense such as me?
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".

Thanks for taking the time to make the connections more explicit.

Create A New User
Node Status?
node history
Node Type: note [id://720008]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (9)
As of 2018-03-17 17:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
When I think of a mole I think of:

Results (225 votes). Check out past polls.

Notices?