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?
Mikael Djurfeldt <mdj@mdj.nada.kth.se> writes:
> "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.
Making it work with bignums is more than just a matter of argument
conversion, right?
> > 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.
But should
(logior (exact->inexact 1) 2)
throw an error? I.e., if it happens to be an inexact number that, for
all intents and purposes is an integer, should the primitive be that
picky? I don't do enough numerical coding in Scheme to have a feel for
how big of a deal this is.
Greg