Parameter Passing

Sather - A Language Tutorial
Prev | Chapter 14. Interfacing with ANSI C | Next

# 14.4. Parameter Passing

The ANSI C standard prescribes that a copy is made of each call argument and all argument-passing is done strictly by value. To conform to ANSI C, all "in" arguments are passed by value. In the case of the built-in C types, a copy of a variable is passed. In the case of user defined external C types, a pointer to the object is copied and passed by value.

In addition, for extra flexibility, Sather supports `"out"` and `"inout"` argument modes for external C routines. `"out"` and "`inout"` arguments are passed by a pointer to a local, which may be legally modified by the called routine. The Sather implementation guarantee that such modifications cannot be observed until the routine returns. For C routines called from Sather this is guaranteed by emitting special code for the caller. For Sather routines that may be called from C, this is guaranteed by emitting special function prologues for the callee.

Prev | Home | Next
User-defined External C types | Up | Inlining C Code