Next: , Previous: , Up: Numbers   [Contents][Index]

5.11.10 Interactions With Local Call

Local call has many advantages (see local-call); one relevant to our discussion here is that local call extends the usefulness of non-descriptor representations. If the compiler knows from the argument type that an argument has a non-descriptor representation, then the argument will be passed in that representation. The easiest way to ensure that the argument type is known at compile time is to always declare the argument type in the called function, like:

(defun 2+f (x)
  (declare (single-float x))
  (+ x 2.0))

The advantages of passing arguments and return values in a non-descriptor representation are the same as for non-descriptor representations in general: reduced consing and memory access (see non-descriptor.) This extends the applicative programming styles discussed in section local-call to numeric code. Also, if source files are kept reasonably small, block compilation can be used to reduce number consing to a minimum.

Note that non-descriptor return values can only be used with the known return convention (section local-call-return.) If the compiler can’t prove that a function always returns the same number of values, then it must use the unknown values return convention, which requires a descriptor representation. Pay attention to the known return efficiency notes to avoid number consing.