[plt-scheme] Bit manipulation in PLT Scheme
On Mar 16, Matthew Flatt wrote:
> At Thu, 16 Mar 2006 12:23:32 -0500, Eli Barzilay wrote:
> > On Mar 16, Matthew Flatt wrote:
> > > At Wed, 15 Mar 2006 19:53:58 +0000, "Paulo J. Matos" wrote:
> > > > How can I know when I have a 30 or 62 bit fixnum then?
> > >
> > > There's no simple way to tell, currently.
> >
> > Wouldn't
> >
> > (eq? (expt 2 35) (expt 2 35))
> >
> > work?
>
> This is fragile. MzScheme will compile the above expression to the
> constant #t or #f.
Ah... (There's always the `eval' back door... except that you have to
bend low to use it...)
> This sort of problem is why I'm reluctant to add `fixnum?' to the
> language. Right now, I think that "fixnum" is just an implementation
> and performance concept, instead of being part of the language.
>
> > And related to that -- it seems that something like a `fixnum?' or
> > `most-positive-fixnum' would be useful for bit-manipulation cases
> > and foreign interaction...
>
> Foreign interaction is a good idea: using `(lib "foreign.ss")',
> `(compiler-sizeof 'long)' will return 4 for a 32-bit platform or 8
> for a 64-bit platform.
I think that what's missing here is the set of assumptions that
MzScheme does, like the fact that a `long' is what's used as a single
fixnum/pointer.
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://www.barzilay.org/ Maze is Life!