Re: qsort and arbitrary types

From: Janne Blomqvist (jblomqvi_at_roskaposti.invalid)
Date: 06/10/04


Date: Thu, 10 Jun 2004 01:30:22 +0300 (EEST)

In article <m1smd41m52.fsf@macfortran.local>, Richard Maine wrote:

[pass by reference...]

> With newer features and compilers, the exceptions are becoming less
> and less exceptional. Some new features are pretty much impossible to
> implement with pass by reference. Even for old features, things like
> copy-in/copy-out are sometimes used by modern optimizers.

You are of course correct. Although I perhaps didn't express myself
very clearly, what I meant was that semantically, argument passing
behaves like pass by reference in the sense that modifying an argument
in a procedure also modifies it in the caller. Obviously, if an
argument is marked as INTENT(IN) or VALUE that isn't true, but I was
talking about the "general" case.

Whether the argument passing is actually implemented as pass by
reference, pass by value-result or in some other way is implementation
dependent, as you say.

> I recommend against programming based on the assumption that arguments
> will be passed by reference. It certainly doesn't seem like an
> assumption that will leave you well prepared for the future... or
> even some parts of the present.

Hmm., are there actually legal programs which work differently
depending on if pass by reference is used or not? I can think of a few
examples where pass by reference would differ from pass by
value-result, but those examples would require aliasing which isn't
allowed anyway.

-- 
Janne Blomqvist