Re: [Scheme-reports] mutable unicode strings John Cowan (02 Jul 2014 23:42 UTC)
Re: [Scheme-reports] mutable unicode strings Per Bothner (02 Jul 2014 23:52 UTC)
Re: [Scheme-reports] mutable unicode strings John Cowan (03 Jul 2014 03:03 UTC)
Re: [Scheme-reports] mutable unicode strings Per Bothner (03 Jul 2014 06:44 UTC)

Re: [Scheme-reports] mutable unicode strings Per Bothner 02 Jul 2014 23:48 UTC


On 07/02/2014 04:34 PM, John Cowan wrote:
> Per Bothner scripsit:
>
>> When it comes to BuffersCowan, it seems reasonable enough.  One comment:
>> What is the point of point?  I.e. the concept seems redundant if you have
>> markers. In Emacs point is a special marker corresponding to the "current
>> position", but I don't think that makes sense for a Scheme library API.
>
> The idea of point is that it's where you can insert text into the buffer.
> This reflects a classical buffer-gap implementation, in which the buffer
> is a big array of characters, with everything before point left-justified
> in the buffer, and everything after point right-justified.

I don't believe Emacs does this.  IIRC the gap is only moved when text is
inserted/deleted, not when point is moved.

>  Therefore,
> as long as the buffer doesn't overflow, inserting at point is O(k)
> where k is the number of characters inserted, rather than O(n*k).
> The trade-off is that shifting point by k characters is also O(k).
> It is therefore optimized for inserting single characters and shifting
> by a single character, both of which are O(1).

Why would you want to treat point different from any other (advancing)
markers?  Instead of:

    (buffer-insert! buffer . strings)

you can have:

    (marker-insert! marker . strings)

If the marker is 'advancing', then this is a pure buffer operation:
Insert at the position of the marker (after moving the gap as necessary);
the marker would get automatically updated along with all the other markers.

--
	--Per Bothner
per@bothner.com   http://per.bothner.com/

_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports