Next: , Up: Argument Conversion   [Contents][Index]


2.4.1 Function Parameters, Arity, and Return Values

When using Guile-GI, the Scheme versions of introspected native functions and callbacks will not always have the same number of input, output, and return parameters as the native functions do. The GObject Introspection information designates the parameters to native functions as either in, in/out or out parameters. The in/out and out parameters are native pointers, so that the C function may return data by reference. To understand how they will appear in the Scheme mapping, a few rules must be understood.

The basic rules as follows:

By these rules, if the native function returns void and has no out or in/out parameters, the return value of the Scheme procedure is *unspecified*.

If a native function returns a non-void value and has zero out or in/out parameters, or if a native function returns void and has a single out or in/out parameter, the Scheme binding will return a value.

Otherwise, the Scheme binding will return multiple values, as with the Guile procedures values and receive.

;; In C, the declaration of g_unix_mount_at is
;; GUnixMountEntry *g_unix_mount_at(const char *path,  /*in*/
;;                                  guint64 *time_read /*out*/)
(receive (mount-entry time-read)
    (unix-mount-at path))

Next: Booleans, Up: Argument Conversion   [Contents][Index]