7.4 Accessing arguments

7.4.1 Accessing input arguments


Declares a new variable of type OZ_Term named var, which is initialized with the value of the n-th (counting starts from zero) input argument.

In case you plan to use unification for passing output arguments, you still have to pass the logic variable with which you want to unify as input argument.


Works like OZ_declareTerm but additionally suspends if the input argument is a free variable.


The function expects in input argument number n an Oz integer. It then declares a variable named var of type int and initializes var with the value of this argument. The macro raises an exception if the argument is ill typed and suspends if the argument is an unbound variable.


Works like OZ_declareInt but expectes an Oz float and declares a variable of type double.


Works like OZ_declareInt but expectes an Oz atom and declares a variable of type char *.


Works like OZ_declareInt but expectes an Oz virtual string and declares a variable of type char *.


Like OZ_declareVirtualString, but additionally sets len to the size of the result.


Declares a variable of type int named var, which is non-zero iff the n-th argument is equal to true.

The above macros always declare a new C variable and then do some checks. Therefore, in C (not in C++) only one of them can be used only at the start of a new block statement. For this reason there is also a second set of macros named OZ_set* that expect that their second argument has already been declared. Thus in C++ you can use


whereas in plain C you have to write

  char *mystring;
  int myint;

7.4.2 Accessing output arguments


Abstract access to output argument number n (counting starts with 0). Should only be used for writing an output argument and never for reading. Usage is like

  OZ_out(3) = OZ_atom("myResult");

This macro should only be used in case a function returns more than one value. For returning values in the first output argument one of the functions below should be used.


Returns from the C function with output value V. It is a macro which expands to

  return (OZ_out(0)=V,OZ_ENTAILED)

For convenience we also provide the following macros:


Return a C integer. Expands to OZ_RETURN(OZ_int(I))


Return a C integer. Expands to OZ_RETURN(OZ_atom(A))


Return a C integer. Expands to OZ_RETURN(OZ_string(S))


Returns false if X equals to 0, true otherwise. Expands to OZ_RETURN((X)?OZ_true():OZ_false())

Michael Mehl, Tobias Müller, Christian Schulte and Ralf Scheidhauer
Version 1.4.0 (20080702)