emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Macro CHECK_NUMBER?


From: Ken Raeburn
Subject: Re: Macro CHECK_NUMBER?
Date: Thu, 25 Oct 2001 08:58:43 -0400
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.0.107

Eli Zaretskii <address@hidden> writes:
> On Wed, 24 Oct 2001, Pavel =?iso-8859-2?q?Jan=EDk?= wrote:
>> in lisp.h we have:
>> #define CHECK_NUMBER(x, i) \
>>   do { if (!INTEGERP ((x))) x = wrong_type_argument (Qintegerp, (x)); } 
>> while (0)
>> What is the purpose of having two arguments? What is the meaning of i?
>
> See the block under "#ifdef ENABLE_CHECKING" earlier in lisp.h.  The
> second argument is supposed to be a message to print when enhanced
> checking of data types is enabled.

That's just the CHECK macro, not related to CHECK_NUMBER and friends.
Possibly I should've chosen a different name for CHECK to make the
distinction more clear.

The second argument to CHECK_NUMBER is an integer, which I've always
thought was the function argument number.  From spot-checking a couple
old versions in CVS, I don't think that macro argument was ever used.

I think it'd be more constructive to find a way to use the number when
reporting an error, than to eliminate it.  Guile's wrong-type-arg
handling does so:

    ERROR: In procedure car in expression (car 1):
    ERROR: Wrong type argument in position 1: 1
    ABORT: (wrong-type-arg)

(Though failing to report the desired type is rather unfortunate.)

Reporting just the value doesn't always make it perfectly clear.  Try
"(aref nil nil)" to see what I mean; it complains that "nil" isn't an
integer, but gives no hint as to which position the integer should be
in.  (Finding some way to report meaningful names for the desired
arguments might help even more.  But if the programmer is *really*
lost, they should be looking at the doc strings....)

Ken



reply via email to

[Prev in Thread] Current Thread [Next in Thread]