guile-devel
[Top][All Lists]
Advanced

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

Re: The empty string and other empty strings


From: Mike Gran
Subject: Re: The empty string and other empty strings
Date: Tue, 10 Jan 2012 03:28:27 -0800 (PST)

> From: Ludovic Courtès <address@hidden>
> A related question: can we have both narrow and wide empty strings?

The intention is that a string is encoded as wide only if it can't
be encoded as narrow.  So _newly created_ empty strings should only be narrow.
 
Right now it seems that zero-length shared substring of a wide string is
wide.  A zero-length substring still shares the stringbuf of the
original string.
 
(%string-dump
  (substring
    (apply string (map integer->char (list 2001 2002 2003)))
   3))
 
So I guess the answer is that you can have both wide and narrow empty
strings if you believe that zero-length substrings need to point to a
zero-length part of the stringbuf of the parent string from which
they were generated.  This is a little pedantic, but I think it might
be the right answer.
 
What do you think about that?  Do zero-length substrings need to
still share stringbufs with their parent strings?
 
In any case, a string-copy of a narrow substring of an otherwise wide string
should be a new narrow string.  This should apply to zero-length
substrings as well.  This isn't happening, because we're missing
a scm_i_try_narrow_string in string-copy, which is a bug.
 
Thanks,
 
Mike



reply via email to

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