[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Questions about floating numbers, rethink and bug report

From: Keith Wright
Subject: Re: Questions about floating numbers, rethink and bug report
Date: Thu, 11 Oct 2001 00:45:26 -0400

> From: Chris Cramer <address@hidden>
> On Tue, Oct 09, 2001 at 01:09:30AM -0400, Keith Wright wrote:
> > So #u(#t #t #f #t) is a bit vector and #u(3.14 2.71) is floating point.
> The problem is that types overlap. You may want to use a long double
> array, but have only integers in the array to start with.

But this is a literal!  That's why I mentioned that it is an error
to assign to a literal.  Dealing with mutable uniform vectors
is more complicated, but that has nothing to do with the syntax
of the literal.

> Or a better example would be a long int array with starting values
> that could fit in bytes.

You could do a copy-on-write implementation that starts with the
smallest possible representation and re-allocates whenever an
element is assigned that does not fit.  This would probably
not be good for Guile, because it makes it too hard to interface
with C.  But again, this has nothing to do with literals.

> BTW R5RS doesn't seem consistent on this subject; at one point it refers
> to "many systems," and then goes on with, "In such systems literal
> constants...  are immutable objects... It is an error to attempt to
> store a new value into a location that is denoted by an immutable object."

I agree that it is muddled here.  It trys to say too many things at once,
description, and justification, and implementation.  There is a
clearer description of the rule at the end of section 4.1.2:

     As noted in section 3.4, it is an error to alter a constant
     (i.e. the value of a literal expression) using a mutation
     procedure like set-car! or string-set!.

> I use them. I like the low-level representation, but the Scheme
> interface (the use of prototypes, and the weird overlap of vectors,
> arrays, and uniform arrays) is bizarre and I would be happy to scrap
> that.  If they were more automatic the way you describe it, it would
> actually be less automatic from the C side, so I wouldn't like that.

Yes, there should be some fairly straightforward way to write Scheme
code that ensures a vector will be represented so that C will see it
as float [], or short int[], or whatever.  That doesn't preclude also
choosing a compact representation automatically when the Scheme
programmer does nothing explicit to specify the representation.

     -- Keith Wright  <address@hidden>

Programmer in Chief, Free Computer Shop <>
         ---  Food, Shelter, Source code.  ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]