guile-devel
[Top][All Lists]
Advanced

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

Re: SCM_LENGTH -> SCM_STRING_LENGTH etc?


From: Dirk Herrmann
Subject: Re: SCM_LENGTH -> SCM_STRING_LENGTH etc?
Date: Mon, 25 Sep 2000 11:41:36 +0200 (MEST)

On 22 Sep 2000, Keisuke Nishida wrote:

> It seems the macro SCM_CHARS has been renamed to SCM_STRING_CHARS
> and SCM_SYMBOL_CHARS.  What about SCM_LENGTH?  I think it should
> be renamed to SCM_STRING_LENGTH, SCM_SYMBOL_LENGTH, and SCM_VECTOR_
> LENGTH, too.

True, but please note that the transition from SCM_CHARS is not finished
yet.  There are still a lot of places where SCM_CHARS is used and where I
couldn't by a short look figure out which type is to be expected
there.  And uniform vectors also use SCM_CHARS to get the base address of
their memory field.

> Also, I'd like to see SCM_VELTS renamed to some better name, like
> SCM_VECTOR_ELEMENTS.  Or instead, providing new macros SCM_VECTOR_REF
> and SCM_VECTOR_SET might be better.

Guile has `normal' scheme vectors and uniform vectors.  SCM_VELTS returns
the base address of the memory regions as a SCM*.  For the uniform vector
implementation, SCM_CHARS is used since it returns a char*, and some of
the uniform vector types are smaller than a SCM value.

The question is, whether we want unified handling between all vector
types, or whether we would like to separate at least SCM vectors and all
other kinds of uniform vectors?  I'd favor a separate handling, since the
layout of uniform vectors may be different:  A uniform vector needs
additional information about the size and type of the vector
elements.  Currently this is encoded in the type of the uniform vector,
but that might change.

What about the following set of macros for SCM vectors:

- SCM_VECTOR_LENGTH
- SCM_VECTOR_BASE --> gives the base address as a scm_bits_t*.
- SCM_VECTOR_REF
- SCM_VECTOR_SET

And for uniform vectors:

- SCM_UVECTOR_LENGTH
- SCM_UVECTOR_BASE --> gives the base address as a void*.

Size and type of the elements of a uniform vector are encoded in its type
tag.  If this was changed to a more explicit representation then some
of the following macros would also make sense:

- SCM_UVECTOR_ELEMENT_SIZE
- SCM_UVECTOR_ELEMENT_PTR --> take a uvector and an index, deliver a void*
  to the element.
- SCM_UVECTOR_ELEMENT_TYPE

For example, with double cells we could just make all uniform vectors into
a single smob, like:  <smob-type/element-type/element-size, length,
base-address>

But this is something that we can think about later.

Best regards
Dirk Herrmann




reply via email to

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