This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Bit Bashing with Guile


Maciej Stachowiak writes:
 > 
 > forcer@mindless.com writes:
 > > This happens on a 32bit box:
 > > 
 > > guile> (logand #b1000000000000000000000000000000 0)
 > > 0
 > > guile> (logand #b10000000000000000000000000000000 0)
 > > ERROR: In procedure logand in expression (logand 2147483648 0):
 > > ERROR: Wrong type argument in position 1: 2147483648
 > > ABORT: (wrong-type-arg)
 > > 
 > > I conclude from this this that Guile is unable to handle 32+ bit numbers
 > > with logical functions, is this correct?
 > > Since i need this (i'm trying to implement CAST-128 encryption as per RFC2144)
 > > i wonder wether anyone found any solution to this problem already
 > > short of using vectors for the bit patterns?
 > > I know i could patch the guile sources to include a CAST encryption function,
 > > but i'd prefer a Scheme-only solution.
 > > Any help is appreciated, and thanks in advance,
 > 
 > Guile can logically and anything up to the range of a signed long on
 > the target platform. IMO, it should use unsigned long instead as a
 > stopgap; ultimately, the logical boolean functions should be extended
 > to handle bignums, again IMO. I suspect Jim would accept a patch to
 > that effect. I would really like such a feature myself (scwm goes
 > through some gyrations to do bit-twiddling on 32-bit unsigned
 > quantities) and would code a patch if I had time.

Ouch that breaks the bitflag-based sysinterned constants in my wrapped curses
modules (highlighting attributes etc. are encoded as 32-bitmasks in ncurses).

Klaus Schilling