Look at the following dialogue:

  guile> (define x '(1 2 . 3))
  guile> (append x x)
  ERROR: In procedure append in expression (append x x):
  ERROR: Wrong type argument (expecting NULLP): 3
  ABORT: (wrong-type-arg)
  guile> 

This error message is confusing.

1. Guile says that I have given the argument 3 to append which isn't true.

2. It is not obvious to the user that "expecting NULLP" means
   "expecting the empty list".

3. Guile is *not* expecting the empty list as argument.

Problem 1 and 3 are due to misuse of an SCM_VALIDATE_XXX macro.  Such
macros can only be used when the type test is applied directly to the
procedure argument.

Problem 2 is a problem with the current validate macros that we have
to solve.

I propose that we let SCM_MAKE_VALIDATE take a fourth argument which
is the expected type in plain English.

Note that sometimes might want to make several validate macros for the
same test:

#define SCM_VALIDATE_CONS(pos, scm) \
  SCM_MAKE_VALIDATE (pos, scm, CONSP, "pair")

#define SCM_SLOPPY_VALIDATE_LIST(pos, scm) \
  SCM_MAKE_VALIDATE (pos, scm, CONSP, "list")

Reply via email to