emacs-devel
[Top][All Lists]
Advanced

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

Re: Buffer names are sometimes read-only objects in daemonized emacs


From: Wojciech Meyer
Subject: Re: Buffer names are sometimes read-only objects in daemonized emacs
Date: Fri, 30 Jul 2010 21:46:32 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Tassilo Horn <address@hidden> writes:

>> How would you do this? I see that the check can be performed on only
>> at runtime. Bytecompiler will not warn, because the value might be
>> propagated, and Lisp is dynamicaly typed. (in simple cases like this
>> it is apparent, but consider just returning this value from function).
>
> No no, you got me wrong.  I just meant the docstring of `buffer-name'
> (and any other function that returns some thing whose modification would
> have undesired, non-obvious side-effects) should explicitly state that
> modifying that returned string will indeed modify the buffer name.

Sry. I now got it.
The thing is that you should never modify inplace other string refs then
returned from make-string, the same applies to string literals.  e.g
text surounded by double quotes. (this could land easily in some read
only area). You could assume that all the string refs, are passed by
ref, and the string (mainly for performance reasons) will the same
object as in the buffer-list. So the advise is, modify inplace only if
you are sure it will not clobber the data in the other corner of Emacs
Also, Elisp has highly stateful nature, and it is hard to avoid such
quirks.

>
> Johan argued the other way round, that it's clear that you should not do
> that because the function doesn't explicitly state that the returned
> string is a fresh copy.

Yes, that's indeed better idea, as it will happen less often.

>
> Bye,
> Tassilo

Wojciech



reply via email to

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