emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Elpa: Pinpoint semantics of `seq-subseq' for streams


From: Michael Heerdegen
Subject: Re: [PATCH] Elpa: Pinpoint semantics of `seq-subseq' for streams
Date: Thu, 15 Sep 2016 02:58:20 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Clément Pit--Claudel <address@hidden> writes:

> Ok, so we agree on this part :) Note that it may be nonsense to load
> the file into a buffer, too; holding the full file in a list is more
> or less as bad as holding the full file in a buffer.  If the file is
> large, that's very inefficient.

Ok.  But how do you refer to the file's contents from elisp, then?
As a string?


> > Do you have an example where this would be useful for streams in
> > Emacs, different from the "last n lines" one (see my comment about
> > that below).
>
> Sure: if I have a stream of numbers, I may want to calculate the
> average of the last n numbers.

> Or if I have a stream of non-overlapping buffer spans, I may want to
> remove just the last one.

Sure, but with what I mean, the error (inefficiency) would already be in
the "I have..." part.


> To continue on the `last n lines' example, I may be interested in only
> the last n lines of output of a running process (think dmesg | tail).

As a string, right?  Or in which way do you refer to the process output
via streams?  Can you please explain in short how you are using streams
in your use case?  (Sorry, I'm more a mathematician than a programmer,
so it's not your fault if I miss the point).  And should we add `stream'
method implementations for building streams from files and/or processes
to stream.el if such stuff is useful?

But I guess I'm beginning to understand: if you have a string (or
something "similar") consisting of multiple lines (or records or
whatever), and you are interested in the last n lines, in contrast to a
buffer, the "go to the end and then n times backwards" approach might
not even be possible, so there is no alternative to dissect the complete
string into entities from the start until you hit the end (and throw
away most of the stuff without accumulation) -- i.e. to the sliding
window approach implemented by seq-subseq with negative indexes.  If
there are such use cases in Emacs Lisp (with no more efficient
alternative), you have convinced me that negative indexes would indeed
be useful.



Thanks,

Michael.



reply via email to

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