manpagez: man pages & more
info guile
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.13.11.2 Signalling Type Errors

Every function visible at the Scheme level should aggressively check the types of its arguments, to avoid misinterpreting a value, and perhaps causing a segmentation fault. Guile provides some macros to make this easier.

Macro: void SCM_ASSERT (int test, SCM obj, unsigned int position, const char *subr)
Macro: void SCM_ASSERT_TYPE (int test, SCM obj, unsigned int position, const char *subr, const char *expected)

If test is zero, signal a “wrong type argument” error, attributed to the subroutine named subr, operating on the value obj, which is the position’th argument of subr.

In SCM_ASSERT_TYPE, expected is a C string describing the type of argument that was expected.

Macro: int SCM_ARG1
Macro: int SCM_ARG2
Macro: int SCM_ARG3
Macro: int SCM_ARG4
Macro: int SCM_ARG5
Macro: int SCM_ARG6
Macro: int SCM_ARG7

One of the above values can be used for position to indicate the number of the argument of subr which is being checked. Alternatively, a positive integer number can be used, which allows to check arguments after the seventh. However, for parameter numbers up to seven it is preferable to use SCM_ARGN instead of the corresponding raw number, since it will make the code easier to understand.

Macro: int SCM_ARGn

Passing a value of zero or SCM_ARGn for position allows to leave it unspecified which argument’s type is incorrect. Again, SCM_ARGn should be preferred over a raw zero constant.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on April 20, 2013 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.