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: New uniform vectors design - Draft I


On Thu, 22 Oct 1998, Dirk Herrmann wrote:

> In this case we had:
> 4 tags for strings: managed/freed/indirect/indirect-read-only
> 1 tag for SCM vectors: managed
> 1 tag for uniform vectors: flag contained in scm_contained_type_info struct


When I thought a little more about it, I was wondering why it could 
be desired to support uniform vectors as an integral part of guile,
instead of an extension that could be loaded at run time. Or, put
differently, what are the disadvantes of using smobs for uniform vectors
(or _one_ smob for the generic solution which was suggested by Michael N.
Livshin)?

My first (naive) thought was, that with builtin support all standard
functions like vector-ref would be automatically supported. But now I
realized that this is not an issue: first, currently vector-ref in guile
does not handle uniform vectors either, and second, you could redefine all
vector related functions, like (obviously you would do it in C):

(let* ((r*rs-vector-ref vector-ref))
  (set! vector-ref
	(lambda (v n)
          (cond ((uniform-vector? v) (uniform-vector-ref v n))
                (else (r*rs-vector-ref v n))))))

So what would be a benefit of having built-in support for uniform vectors?
Until convinced otherwise, I'm very much in favor of simplifying guile's
type system and remove the tags for uniform vectors completely, using one
or several smobs instead.

As soon as the smob space is extended, even encoding of flags within the
smob tags may become an interesting option (see my next mail).

Best regards, 
Dirk Herrmann