emacs-devel
[Top][All Lists]
Advanced

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

Re: Very interesting analysis of "the state of Emacs"


From: David Hansen
Subject: Re: Very interesting analysis of "the state of Emacs"
Date: Thu, 01 May 2008 08:31:45 +0200
User-agent: Gnus/5.110009 (No Gnus v0.9) Emacs/23.0.60 (gnu/linux)

On Wed, 30 Apr 2008 23:23:03 -0500 Jonathan Rockway wrote:

> But of course... what do you do for things that can't be copied, like
> buffers or window layouts?  What happens if something like this
> executes in parallel:
>
>    A (some-slow-function) (goto-char 42)
>    B (save-excursion (goto-char 0) (do-something))
>
> And the execution order happens to be:
>
>   (goto-char 1234)
>   A (some-slow-function)
>   B (save-excursion (goto-char 0)
>   A (goto-char 42)
>   B (do-something)
>   B )
>
> Where is the point now?  Logically it would be at 42, since the
> save-excursion shouldn't have moved it... but the save-excursion sets it
> back to the initial value of 1234 when it unwinds.  This makes sense
> when you look at the execution order, but that's non-deterministic so it
> will never be consistent.
>

That's exactly why I think co-routines are the way to go.  You just
don't `yield' within a `save-excursion' (the macro could even flet it to
some NOP).  And if you do `yield' you know exactly that you can't rely
on some state before it.

I don't think globals are a huge problem.  It's either some internal
state of a package.  Then it's just the job of the programmer of the
package to be more careful.  Or it's some user setting, then you have to
let bind it at the beginning of your lengthy calculation.

(let ((option *user-setting*)) (do-lots-of-stuff))

This would be a rare exception anyways, most commands are short and fast
and won't `yield' at all.

David





reply via email to

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