why cannot assign to function call
mdw at distorted.org.uk
Sun Jan 11 04:25:24 CET 2009
Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> wrote:
> I don't believe it is a red-herring. As I understand it, Mark and Joe
> insist that C is pass-by-value *even in the case of arrays*, despite the
> semantics of array passing being identical to the semantics of pass-by-
> reference in (say) Pascal.
But they aren't. I've provided several examples to show this. Most
tellingly, the parameter types are different in the two cases.
> While Mark is willing to admit that arrays are "bizarre" (his term) in
> C, I don't think he accepts that passing arrays in C is anything but
For the purpose of clearing this up once and for all: arrays, in C, are
`don't-pass-at-all'. There is no way -- none whatever -- of declaring a
function parameter as having array type.
Furthermore, if (say) an argument expression consists only of an
identifier bound to an object of array type, the resulting argument
expression has pointer type, and is fully evaluated prior to the
sequence point before the function call. I provided chapter and verse
elsewhere, and I'm getting rather fed up of repeating myself. Certainly
a dissenting opinion should include references to at least a (specific)
draft of the ISO C standard.
> I think this gets very close to the bone of the debate. It demonstrates
> that "pass-by-value" as Mark and Joe understand it is such a broad
> concept that it can describe any argument passing behaviour at all and
> therefore is meaningless.
I've proven (not quite rigorously, but sketched a proof, and provided
definitions which are now sufficiently formal that you can fill in the
details) that my definition of pass-by-value excludes certain
behaviours. But, most significantly, you cannot implement `swap' given
-- [mdw], wondering whether Hanlon's razor is getting blunt.
More information about the Python-list