Re: qsort and arbitrary types
From: glen herrmannsfeldt (gah_at_ugcs.caltech.edu)
Date: 06/11/04
- Next message: James Giles: "Re: qsort and arbitrary types"
- Previous message: James Giles: "Re: qsort and arbitrary types"
- In reply to: Catherine Rees Lay: "Re: qsort and arbitrary types"
- Next in thread: James Giles: "Re: qsort and arbitrary types"
- Reply: James Giles: "Re: qsort and arbitrary types"
- Reply: *** Hendrickson: "Re: qsort and arbitrary types"
- Reply: Gerry Thomas: "Re: qsort and arbitrary types"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 11 Jun 2004 17:51:27 GMT
Catherine Rees Lay wrote:
(snip)
> If you can tell whether the arguments are pass-by-reference or not, the
> code isn't legal.
Yes.
> 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.
Well, the compilers that I know that don't do pass by reference
still have the same calling convention. The address of the
argument is passed to the callee. The difference is that the
called routine, instead of saving the address, copies the argument
(for scalar variables only) into local storage, and copies it back
before returning. This is technically called pass by value return,
but the argument list contains addresses of parameters, as usual.
In this case, as far as mixed language programming, it will
look the same, but if you alias the variables you can see
the difference. In the case of PL/I, which passes arrays
by descriptor the old trick in calling Fortran was to put
just one array element in the argument list, which was then
passed by address (reference), and the Fortran program could
reference the whole array.
In F66 it is legal to put an array element in the argument
list where the called routine expects an array. The called
routine then sees the remainder of the array starting from
that element. I don't know if this was kept in later
versions of the standard.
-- glen
- Next message: James Giles: "Re: qsort and arbitrary types"
- Previous message: James Giles: "Re: qsort and arbitrary types"
- In reply to: Catherine Rees Lay: "Re: qsort and arbitrary types"
- Next in thread: James Giles: "Re: qsort and arbitrary types"
- Reply: James Giles: "Re: qsort and arbitrary types"
- Reply: *** Hendrickson: "Re: qsort and arbitrary types"
- Reply: Gerry Thomas: "Re: qsort and arbitrary types"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]