Re: qsort and arbitrary types

From: Catherine Rees Lay (spamtrap_at_polyhedron.org.uk)
Date: 06/11/04


Date: Fri, 11 Jun 2004 09:38:38 +0100

In article <slrnccf3ru.2f0.jblomqvi@vipunen.hut.fi>, Janne Blomqvist
<jblomqvi@roskaposti.invalid> writes
>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.
>
If you can tell whether the arguments are pass-by-reference or not, the
code isn't legal.

Having said that, most (all?) mixed language programming, especially
under Windows using compilers from different vendors, requires you to
know how your compiler passes arguments. Hopefully the f2k3
interoperability stuff will remove this requirement.

Catherine.

-- 
Catherine Rees Lay
To email me, use my first name in front of the "at".


Relevant Pages

  • Re: qsort and arbitrary types
    ... the exceptions are becoming less ... Some new features are pretty much impossible to ... >>implement with pass by reference. ... The Fortran rules were designed to allow the compiler to ...
    (comp.lang.fortran)
  • Re: qsort and arbitrary types
    ... This has never been specified in the standard. ... With newer features and compilers, the exceptions are becoming less ... implement with pass by reference. ...
    (comp.lang.fortran)
  • Re: Another C99 challenge
    ... reason to believe that GCC is lying about their own work? ... C99-specific features anyway, at least in delivered code, until our ... I wouldn't mind if GCC did fully support C99, ... compilers using a "reasonable" variety of features new to C99. ...
    (comp.std.c)
  • Re: .Net COM+
    ... write your own IUnknown to expose a programmatic interface to ... management leaves a lot to be desired (Reference counts isn't perfect, ... transaction features can be used .. ...
    (microsoft.public.dotnet.distributed_apps)
  • Re: MS Data Access Block
    ... features, I meant in my program that uses the block, not that I made changes ... in project 'Forms1' cannot be copied to the run directory because it would ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)