guile-devel
[Top][All Lists]
Advanced

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

Re: Unicode and Guile


From: Tom Lord
Subject: Re: Unicode and Guile
Date: Tue, 11 Nov 2003 20:03:18 -0800 (PST)

    > From: Marius Vollmer <address@hidden>
    > Tom Lord <address@hidden> writes:

    > >     > >     ~ (make-text-marker text index) => <marker>

    > >     > What about having _only_ markers and not allow integers as
    > >     > indices?

    > > Seems excessive and aribtrary.  How do I implement (Emacs') GOTO-CHAR
    > > without standing on my head?

    > Yes, right, there need to be conversions between markers and integers,
    > but I'm worried that people will write code like

    >     (do ((i 0 (1+ i))
    >          (>= i (text-length text)))
    >       (... (text-ref text i) ...))

    > and we'll have trouble implementing this efficiently for graphemes of
    > variable sizes.  When people are encouraged to use markers like this

    >     (do ((i (text-start text) (marker-forward i 1))
    >          ((marker-at-end? i)))
    >       (... (marker-ref i) ...))

    > things should be easier.  (Of course, there should also be things like
    > 'text-map', etc.)

Integer indexes can be implemented quite efficiently.   Again, imagine
a splay tree representation of text in which each node is labled with
its integer offsets.  ("splay" is not the only possible tree type to
which this idea applies.)


    > > (I strongly suggest splay trees as an ideal implementation strategy
    > > for for TEXT?.   They would make _both_ mutating and functional
    > > REPLACE efficient.)

    > Ok, if there is no cost for making texts mutable, we should of course
    > do it.

Yup.

    > > Graphemes are a reasonable "what the user thinks of as a character".

    > Yep, the concept of graphemes is useable, if only in the
    > documentation.  What I really had in mind was not the concept, but the
    > data type.  Is it important to have a new data type, or could we just
    > have

    >     (define (grapheme? obj) (and (text? obj) (= (text-length obj) 1)))
    >     (define grapheme=? text=?)
    >     (define grapheme<? text<?)
    >     ...

    > 'read-grapheme' etc would probably need to remain.

That's essentially what I proposed.   I wasn't trying to spec the
absolute _minimal_ basis set, just a usefully small basis set.

-t







reply via email to

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