Multi-dimensional list initialization

Jussi Piitulainen jpiitula at ling.helsinki.fi
Wed Nov 7 03:52:49 EST 2012


Steven D'Aprano writes:
> On Wed, 07 Nov 2012 00:23:44 +0000, MRAB wrote:

> > I prefer the term "reference semantics".
> 
> Oh good, because what the world needs is yet another name for the
> same behaviour.
> 
> - call by sharing
> - call by object sharing
> - call by object reference
> - call by object
> - call by value, where "values" are references 
>   (according to the Java community)
> - call by reference, where "references" refer to objects, not variables
>   (according to the Ruby community)
> - reference semantics
> 
> Anything else?
> 
> http://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_sharing

Something else:

There's a call-by-* versus pass-by-* distinction, where the call-by-*
would be rather different from any of the above:

- call-by-value is what most languages now use: argument expressions
  are reduced to values before they are passed to the function /
  procedure / method / whatever.

- call-by-name was something Algol 60 had by default: something like
  evaluating the argument expression every time its value is needed

- call-by-need: argument expression is reduced to a value the first
  time its value is needed (if ever)

- call-by-lazy (increasingly silly terminology, and I don't quite have
  an idea what it means in contrast to call-by-need)

The modern confusions would then be mostly over the pass-by-* family,
invariably using call-by-value in the above sense. The terminology for
these tends to produce more heat than light, but I think the relevant
distinctions are mostly just these:

- can one modify the argument effectively [Python: yes]

- can one modify the parameter with abandon [Python: don't]

- can one swap [Python: no]

- possibly: is it expensive to pass large objects? [Python: no]

The actual rule in Scheme, Java, and Python is the same simple and
sane rule: what are passed are values (argument expressions are fully
evaluated before the actual call takes place), parameter passing does
not involve any (observable) copying, and the arguments are bound to
fresh variables (no aliasing of variables).

Different communities use different words. Sometimes they use the same
words about different things. Resulting in more heat than light :(

(I'd have a few more things in the something-else department, but this
is already much longer than I thought. Ends.)



More information about the Python-list mailing list