Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Some Insights from a Traveler Between Languages

by chromatic (Archbishop)
on Apr 23, 2005 at 19:39 UTC ( #450783=note: print w/replies, xml ) Need Help??


in reply to Some Insights from a Traveler Between Languages

Would you have such conceptual trouble if the syntax were instead:

store_into( array_foo, list_of_values (1, 2, 3) ); store_into( scalar_bar, array_reference( list_of_values( 1, 2, 3 ) ); store_into( scalar_baz, last_expression_of_list( 1; 2; 3; ) ); store_into( array_biz, array_reference( list_of_values( 1, 2, 3 ) );

I'm not suggesting that's great syntax or that it's even clear syntax, but I am suggesting that that's effectively the way you have to think about the code if you want to understand what it's doing. (That also explains why your interpretation of the third case is incorrect.)

Is it inconsistent? I don't think so. All four are doing different things and all four look very different. As you suggest, it's similar to the difference between Python tuples (immutable) and lists (mutable). They may look similar if you don't pay attention to the brackets, but they look different because they behave differently.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://450783]
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 2020-07-08 11:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?