guile-user
[Top][All Lists]
Advanced

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

Re: Questions about floating numbers, rethink and bug report


From: Chris Cramer
Subject: Re: Questions about floating numbers, rethink and bug report
Date: Wed, 10 Oct 2001 02:35:52 -0500
User-agent: Mutt/1.2.5i

On Tue, Oct 09, 2001 at 01:09:30AM -0400, Keith Wright wrote:
> Why do we need eleven different prefix letters for different types of
> uniform vector anyway?  Is there not an stunning algorithm that,
> given a _single_ code for uniform-array and a list of objects all
> of the same type, computes the common type?  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. Or a better
example would be a long int array with starting values that could fit
in bytes.

> Keep in mind it is an error to assign to a vector constant
> (R5RS, end of 3.4, literal constants are immutable objects,
> and 7.1.(2|3) <literal>::='<datum>::=<vector>).

R5RS compliance is great, but I really think that is going too far. If
you do it that way, there's a way to specify read-only literals, but
there's no way to specify writable literals, and I'd much rather
it be the other way around. I don't know how many programs I've written
that would break if Guile actually followed this.

For instance, in C, you can do

        const static char foo[] = "blah";

which will make it read-only, or you can do

        static char foo[] = "blah";

which will make it writable. Scheme doesn't have a way to specify this.

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."

> Now I'm getting really wound up.  Why have any special syntax
> at all?  If the interpreter is prepared to handle uniform vectors
> as a special case, just do it.  Sometimes a later use of the vector
> may force the interpreter to convert, but how can that be worse
> that forcing 10^n programmers to play "Simon says" in order to
> get the short representation.

This would be a huge PITA for interfacing with C. Sometimes I want to use
an array of a certain type, and I don't want to bother with converting
them into that certain type.

> This would require careful design and implementation to make the
> semantics predictable, avoid thrashing representations, and interface
> well with C.  Is anybody using uniform vectors?  Do they like them?
> Would they like them better if they were more automatic?

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.

-- 
C. Ray C. aka Christopher Cramer
address@hidden
http://www.pyro.net/~crayc/



reply via email to

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