From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Noam Postavsky <npostavs@users.sourceforge.net>
Cc: John Wiegley <jwiegley@gmail.com>, Eli Zaretskii <eliz@gnu.org>,
emacs-devel@gnu.org
Subject: Re: Lisp watchpoints
Date: Sat, 14 Nov 2015 17:29:07 -0500 [thread overview]
Message-ID: <jwvlha0wcne.fsf-monnier+Inbox@gnu.org> (raw)
In-Reply-To: <CAM-tV-8v_GN9a9ZCAObeYULJRzKVMNjQ_dbzGLQL2oph0H+76g@mail.gmail.com> (Noam Postavsky's message of "Sat, 14 Nov 2015 13:14:15 -0500")
>> Actually, I think it's not that complicated:
>> - Look at the definition of SYMBOL_CONSTANT_P.
> There is a comment on Lisp_Symbol's `constant' field saying "If the
> value is 3, then the var can be changed, but only by `defconst'".
> However, I can't find any code that uses this value.
It's a mistake (I had such a thing working locally at some point but
I dropped it before I installed the code in the repository): I just
forgot to update the comment.
> Is it safe to ignore?
Yes.
>> - Change its name to SYMBOL_SLOWWRITE_P.
>> - Change the field it tests from being a boolean to being a 3-valued
>> thingy, with values "fullspeed", "hooked", and "readonly".
> Would it be sensible to implement "readonly" as "hooked" + some hook
> that signals error on write?
Could be, but I think I'd rather not take the risk that some advice
could turn nil's value to something else than nil.
IOW those vars currently marked as "read-only" should *really*
be kept read-only.
OTOH if we make sure that the "read-only" hook can't be
overridden/changed/skipped by Elisp code, it might be fine.
>> Maybe it'd be nice to make sure that "defvaralias" could be
>> re-implemented on top of those hooks, even though I don't think such
>> a reimplementation is desirable at this point.
> To do that we'd have to trap reads as well as writes, right?
I don't think so. We just need to keep the two vars "synchronized" so
any assignment to one also changes the other.
> Which could be useful for debugging too.
I think a hook on variable reads is not a good idea. Fundamentally the
issue is similar to the one for assignments, but the trade-offs work
differently:
- we currently don't have a CONSTANT_P check for reads, so adding
a HOOKED_P check would incur an additional cost.
- When debugging it's much less frequent to need to catch reads than writes.
- The risk involved in running arbitrary Lisp code for a variable-read
seems higher.
So the cost and risks are higher whereas the expected benefits are lower.
If/when dynamic-binding is the exception, maybe this could be
reconsidered but there'd also need to be a compelling argument in favor.
Stefan
next prev parent reply other threads:[~2015-11-14 22:29 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-14 18:14 Lisp watchpoints (Was: [Emacs-diffs] master 19e09cf: Ensure redisplay after evaluation) Noam Postavsky
2015-11-14 22:29 ` Stefan Monnier [this message]
2015-11-22 20:13 ` Lisp watchpoints Noam Postavsky
2015-11-22 20:41 ` Eli Zaretskii
2015-11-22 21:25 ` Stefan Monnier
2015-11-23 3:32 ` Eli Zaretskii
2015-11-23 2:31 ` Noam Postavsky
2015-11-29 2:04 ` Noam Postavsky
2015-11-29 4:44 ` Stefan Monnier
2015-11-29 5:12 ` Noam Postavsky
2015-11-29 11:28 ` Andreas Schwab
2015-11-29 14:12 ` Noam Postavsky
2015-11-29 15:37 ` Stefan Monnier
2015-11-29 16:10 ` Eli Zaretskii
2015-11-30 0:57 ` Noam Postavsky
2015-11-30 1:14 ` Stefan Monnier
2015-11-30 15:49 ` Eli Zaretskii
2015-11-29 11:28 ` Andreas Schwab
2015-11-29 15:39 ` Stefan Monnier
2015-11-29 15:45 ` Eli Zaretskii
2015-11-29 16:01 ` Noam Postavsky
2015-11-29 16:04 ` Noam Postavsky
2015-11-29 17:13 ` Eli Zaretskii
2015-11-29 22:24 ` Stefan Monnier
2015-11-29 17:11 ` Eli Zaretskii
2015-11-29 16:06 ` Stefan Monnier
2015-11-29 16:43 ` Eli Zaretskii
2015-11-29 19:40 ` Noam Postavsky
2015-11-29 19:54 ` Eli Zaretskii
2015-11-29 20:35 ` Noam Postavsky
2015-11-29 20:45 ` Eli Zaretskii
2015-11-29 21:33 ` Noam Postavsky
2015-11-29 20:00 ` Andreas Schwab
2015-11-29 20:19 ` Eli Zaretskii
-- strict thread matches above, loose matches on Subject: below --
2016-12-03 14:51 Kaushal Modi
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvlha0wcne.fsf-monnier+Inbox@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=jwiegley@gmail.com \
--cc=npostavs@users.sourceforge.net \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.