This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Wrong type argument in position 1: %S



> > Right... I see what's going on.  SCM_UNDEFINED effectively truncates
> > the argument list.
> > 
> > The thing is, code should never be trying to print SCM_UNDEFINED in
> > the first place.  It's not a valid Scheme value.  The error should be
> > caught and reported earlier.
> 
> This IS the error reporting! A function has tried to operate on a value
> that is SCM_UNDEFINED and is now making an attempt to complain about it.

I understand that.

> Even if you clean up your guile-core routines so that this can never
> happen, it may still occur as a result of buggy SMOB code when
> someone is trying to write an extension -- the error reporting
> really should be able to give an accurate report of what has occured
> (i.e. a function has recieved SCM_UNDEFINED as a non-optional
> argument). It can be caused by something as simple as getting the
> number of optional/non-optional arguments wrong when registering a C
> function to scheme... how are you going to trap that?

It's not meaningful to try to handle SCM_UNDEFINED more gracefully;
eventually you'll just want to pass it as an optional argument to
something, and you'll lose.  It's a metavalue, and it needs to stay
that way.

I'm not sure how to gracefully detect incorrect argument counts, but
trying to handle SCM_UNDEFINED gracefully throughout Guile is still
not the answer.