[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Wrong error messages with string>? and friends
From: |
Martin Grabmueller |
Subject: |
Wrong error messages with string>? and friends |
Date: |
Wed, 24 Jan 2001 16:00:47 +0100 |
Hello Guilers,
when reading through `strorder.c', I notices that some of the ordering
predicates are defined in terms of others. Of course this reduces
code size and duplication, but unfortunately the argument checking
code gives strange error messages on misuse.
Example:
address@hidden (~/cvs/guile-core): guile
guile> (string>? "as" 2)
ERROR: In procedure string<? in expression (string>? "as" 2):
ERROR: Wrong type argument in position 1 (expecting STRINGP): 2
ABORT: (wrong-type-arg)
Type "(backtrace)" to get more information or "(debug)" to enter the debugger.
guile>
In this case the wrong procedure name is reported, and the argument
number is wrong, because `string>?' swaps its arguments and calls
`string<?'.
I have thought about a solution, like changing the definition of
`string>?' from
SCM_DEFINE1 (scm_string_gr_p, "string>?", scm_tc7_rpsubr,
(SCM s1, SCM s2),
"Lexicographic ordering predicate; returns @t{#t} if @var{s1}\n"
"is lexicographically greater than @var{s2}. (r5rs)")
#define FUNC_NAME s_scm_string_gr_p
{
return scm_string_less_p (s2, s1);
}
#undef FUNC_NAME
to this:
SCM_DEFINE1 (scm_string_gr_p, "string>?", scm_tc7_rpsubr,
(SCM s1, SCM s2),
"Lexicographic ordering predicate; returns @t{#t} if @var{s1}\n"
"is lexicographically greater than @var{s2}. (r5rs)")
#define FUNC_NAME s_scm_string_gr_p
{
SCM_VALIDATE_STRING (1, s1);
SCM_VALIDATE_STRING (2, s2);
return scm_string_less_p (s2, s1);
}
#undef FUNC_NAME
This would fix the error message, but introduce duplication of the
argument validation code.
Another solution would be to create static helper functions which do
not do argument checking and call them from the primitives, which will
validate the arguments before calling the helpers.
So, what do you think about this problem? I don't know if it is even
worth fixing, but correct error messages are always nice when chasing
bugs.
I can make a patch implementing one of the two solutions outlined
above if someone with write privs decides which is the best ;)
Thx,
'Martin
--
Martin Grabmueller address@hidden
http://www.pintus.de/mgrabmue/ address@hidden on EFnet
- Wrong error messages with string>? and friends,
Martin Grabmueller <=