unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Wojciech Meyer <wojciech.meyer@googlemail.com>
To: Tassilo Horn <tassilo@member.fsf.org>
Cc: "Wojciech Meyer" <wojciech.meyer@googlemail.com>,
	"Johan Bockgård" <bojohan@gnu.org>,
	emacs-devel@gnu.org
Subject: Re: Buffer names are sometimes read-only objects in daemonized emacs
Date: Fri, 30 Jul 2010 21:46:32 +0100	[thread overview]
Message-ID: <8762zw8zpz.fsf@gmail.com> (raw)
In-Reply-To: <201007302208.27352.tassilo@member.fsf.org> (Tassilo Horn's message of "Fri, 30 Jul 2010 22:08:26 +0200")

Tassilo Horn <tassilo@member.fsf.org> 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	other threads:[~2010-07-30 20:46 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-29 20:30 How do I debug errors in post-command-hook? Tassilo Horn
2010-07-29 21:33 ` Lennart Borgman
2010-07-30  0:11 ` Johan Bockgård
2010-07-30  6:54   ` Tassilo Horn
2010-07-30 11:58     ` Johan Bockgård
2010-07-30 14:23       ` Buffer names are sometimes read-only objects in daemonized emacs (was: How do I debug errors in post-command-hook?) Tassilo Horn
2010-07-30 17:46         ` Buffer names are sometimes read-only objects in daemonized emacs Johan Bockgård
2010-07-30 18:41           ` Tassilo Horn
2010-07-30 19:54             ` Wojciech Meyer
2010-07-30 20:08               ` Tassilo Horn
2010-07-30 20:46                 ` Wojciech Meyer [this message]
2010-07-30 21:48                 ` Stefan Monnier
2010-07-30 22:07                   ` Lennart Borgman
2010-08-01 23:09                     ` Stefan Monnier
2010-07-30 23:35                   ` Johan Bockgård
2010-08-01 23:10                     ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8762zw8zpz.fsf@gmail.com \
    --to=wojciech.meyer@googlemail.com \
    --cc=bojohan@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=tassilo@member.fsf.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).