The D Programming Language

Herman Rubin cik at l.cc.purdue.edu
Wed Mar 9 23:06:40 AEST 1988


In article <17351 at glacier.STANFORD.EDU>, jbn at glacier.STANFORD.EDU (John B. Nagle) writes:
> 
>     If you want multiple values from functions, look at Mesa, which offers
> an efficient approach.  In Mesa, all functions effectively take one argument
> and return one result, but both are structures.  The normal function call
> syntax is treated as a structure constructor which builds a structure out
> of the arguments, then passes the structure as a unit.  The structure is usually
> built on the stack, and thus this is equivalent in an implementation sense
> to the passing of parameters on the stack.  In turn, a function returns a
> result which is a structure.  The space for that structure is allocated by
> the caller, on the stack, and its address is passed to the function, which
> then fills it in.
> 
>     This approach seems to work.

There are two problems with this.  While using stacks may be easy to program,
it involves lots of loads and stores.  I know of at least one machine on which
the normal subroutine call and return do not use stacks.  Furthermore, if the
called routine may make additional calls, it may be necessary to use a 
separate return stack, and this may require each such subroutine to maintain
its own return stack.  In some cases this should be the way to do things,
but not always.

Another problem comes with inline functions.  I believe that many function
calls, if not most, should be inline.  In this case, I think the result should
go to its destination at the time produced.  If the destinations involve
registers or register indirects, the expression of the algorithm must take
the busy set of registers into account.  This admittedly makes coding 
difficult, and is one reason why I believe DNA can optimize better than
silicon.  (The two should be used together, but I do not know of any compiler
which allows the programmer to even give it a hint as to how to optimize,
let alone improve the resulting product.)


-- 
Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907
Phone: (317)494-6054
hrubin at l.cc.purdue.edu (ARPA or UUCP) or hrubin at purccvm.bitnet



More information about the Comp.lang.c mailing list