[plt-scheme] scheme_signal_error

From: Olivier ORABONA (orabonao at clio.unice.fr)
Date: Fri Apr 18 09:19:05 EDT 2003


Well in fact you were right, I've messed up things with pointers and the problem was in bar function (that was not that _irrelevant_ after all).

But I'm still confused with the tests: should I use
while(SCHEME_PAIRP(tmp)) or while(!SCHEME_NULLP(tmp)) now ?

While writing my answer, I still experiment and I have another question.
Consider the following code:

Scheme_Object* foo(void* p, int argc, Scheme_Object** argv) {
	Scheme_Object* tmp = argv[0];

	while(!SCHEME_NULLP(tmp)) {
		/* short circuit bar and directly try scheme_signal_error() */
		scheme_signal_error("Bad input : %S",SCHEME_CAR(tmp));
		tmp = SCHEME_CDR(tmp);
	return scheme_true;

When foo is called (foo '(one two three)) this code returns :
Bad input : one

This works great with symbols ok.
Now I experiment scheme_signal_error with other input types :

I change "%S" to "%d" so that (foo '(1 2 3)) would work (mzscheme dll hangs otherwise) and at top level :
> (foo '(1 2 3))
Bad input : 3
> (foo '(1))
Bad input : 3
> (foo '(12345))
Bad input : 24691
> (foo '(one))
Bad input : 67392512

Ok the last one was just for fun.

Where am I wrong now ?

Thanx a lot.

Posted on the users mailing list.