This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Should logior (and friends) operate only on inums?
"Greg J. Badros" <gjb@cs.washington.edu> writes:
> Janis Dzerins <jonis@mt.lv> writes:
>
> > Or should they be more general? (At the moment I need logXXX to act on
> > longs with the mask like #xf0000000, but, only INMUS accepted)
>
> I asked the same question a little while ago on the devel-guile list but
> I don't think anyone responded.
I think logXXX should work for bignums as well because that seems
useful, and, at the same time, avoids the problem of ulongs.
> I was concerned more about whether inexact numbers should be
> converted and usable;
It seems that operations which are only reasonable for integers should
only accept integers as arguments. This is also how R5RS is written.
> We need to figure out which of the routines in numbers.c should be used
> for which functions. I think there should probably be:
>
> SCM_VALIDATE_LONG_COPY
>
> and
>
> SCM_VALIDATE_ULONG_COPY
>
> macros that then call appropriate functions from numbers.c to convert
> and verify argument type.
To me, this seems like a good idea.
> Again, the issue is that SCM_NUM2ULONG allows inexact numbers as its
> argument (but does throw an outofrange if the number isn't equal to
> a long). Is this a problem?
Yes. I think so. For operations which don't have a natural
interpretation when operating on inexact numbers, the user should do
(inexact->exact ...) explicitly.