all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Dmitry Antipov <dmantipov@yandex.ru>
Cc: emacs-devel@gnu.org
Subject: Re: [RFC] some reworking of struct window
Date: Fri, 22 Mar 2013 10:47:55 +0200	[thread overview]
Message-ID: <837gkz6csk.fsf@gnu.org> (raw)
In-Reply-To: <514BF696.2020208@yandex.ru>

> Date: Fri, 22 Mar 2013 10:13:42 +0400
> From: Dmitry Antipov <dmantipov@yandex.ru>
> CC: emacs-devel@gnu.org
> 
> On 03/21/2013 10:21 PM, Eli Zaretskii wrote:
> 
> >> @@ -838,16 +838,8 @@
> >>   {
> >>     while (w)
> >>       {
> >> -      if (!NILP (w->hchild))
> >> -	{
> >> -	  eassert (WINDOWP (w->hchild));
> >> -	  clear_window_matrices (XWINDOW (w->hchild), desired_p);
> >> -	}
> >> -      else if (!NILP (w->vchild))
> >> -	{
> >> -	  eassert (WINDOWP (w->vchild));
> >> -	  clear_window_matrices (XWINDOW (w->vchild), desired_p);
> >> -	}
> >> +      if (WINDOWP (w->object))
> >> +	clear_window_matrices (XWINDOW (w->object), desired_p);
> >>         else
> >>   	{
> >>   	  if (desired_p)
> >
> > Here, you effectively lost the assertion that w->object can only be a
> > window or a buffer.  With the new code, if it's neither a window nor a
> > buffer, you will behave as if it were a buffer, without checking.
> 
> No, because clear_window_matrices doesn't check whether w->buffer is not
> nil and call clear_glyph_matrix anyway.

Sorry, I'm not following your reasoning.

> I assume that the most of display-related functions should not be called
> for the deleted windows. E.g. this code just silences possible error:
> 
> if (WINDOWP (w->object))
>    foo (w->object);
> else if (BUFFERP (w->object))
>    bar (w->object);
> 
> The following is better since XBUFFER implies eassert if --enable-checking:
> 
> if (WINDOWP (w->object))
>    foo (w->object);
> else
>    bar (XBUFFER (w->object));
> 
> Or:
> 
> if (WINDOWP (w->object))
>    foo (w->object);
> else if (BUFFERP (w->object))
>    bar (w->object);
> else
>    emacs_abort ();
> 
> The latter example leaves the conditional call to emacs_abort even without
> --enable-checking. I suspect that this is too paranoid, and would prefer:
> 
> eassert (!NILP (w->object));
> if (WINDOWP (w->object))
>    foo (w->object);
> else
>    bar (w->object);

But the latter is only protected against nil objects, while the code
only handles windows and buffers.  Any non-nil Lisp object that is
neither a window nor a buffer will slip the assertion.

If there's an immediate XBUFFER in the 'else' branch, then indeed an
assertion is not needed.  But in many cases, this one included,
there's no such call to XBUFFER at all, or it is much later in the
control flow, which makes it harder to find such bugs.

> >> @@ -2069,22 +2060,18 @@
> >>     if (!NILP (parent) && NILP (w->combination_limit))
> >>       {
> >>         p = XWINDOW (parent);
> >> -      if (((!NILP (p->vchild) && !NILP (w->vchild))
> >> -	   || (!NILP (p->hchild) && !NILP (w->hchild))))
> >> +      if (p->type == w->type && p->type > WINDOW_LEAF)
> >                                     ^^^^^^^^^^^^^^^^^^^^^
> > I think you are not supposed to compare enumerated types, except for
> > equality.  How exactly the compiler assigns numerical values to
> > enumerated types is implementation-defined, I think.
> 
> No.
> 
> "An enumerator with = defines its enumeration constant as the value of the constant
> expression. If the first enumerator has no =, the value of its enumeration constant
> is 0. Each subsequent enumerator with no = defines its enumeration constant as the
> value of the constant expression obtained by adding 1 to the value of the previous
> enumeration constant".
> 
> This is from the latest C99 draft (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf
> 6.7.2.2 "Enumeration specifiers"), but I believe it was so since long time ago.

OK, so what happens if the enumeration is reshuffled at some later
point in time?  And why did you need to use > anyway, when != would do
the same, and be free of the problem altogether?

> >> -  /* P's buffer slot may change from nil to a buffer.  */
> >> -  adjust_window_count (p, 1);
> >
> > Why did you remove this call?
> 
> Because I also remove wset_buffer (p, Qnil) few lines below, and per-buffer window counters
> should be balanced.

Sorry, you lost me here.



      reply	other threads:[~2013-03-22  8:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-21  9:39 [RFC] some reworking of struct window Dmitry Antipov
2013-03-21 11:38 ` martin rudalics
2013-03-21 18:45   ` Eli Zaretskii
2013-03-21 21:17     ` martin rudalics
2013-03-21 14:26 ` Davis Herring
2013-03-21 14:46 ` Stefan Monnier
2013-03-21 15:01   ` Dmitry Antipov
2013-03-21 17:40     ` Eli Zaretskii
2013-03-21 18:21 ` Eli Zaretskii
2013-03-21 23:50   ` Stefan Monnier
2013-03-22  7:40     ` Alternate design [Was: Re: [RFC] some reworking of struct window] Dmitry Antipov
2013-03-22 13:34       ` Stefan Monnier
2013-03-25 15:29         ` Dmitry Antipov
2013-03-25 19:02           ` Stefan Monnier
2013-03-22  6:13   ` [RFC] some reworking of struct window Dmitry Antipov
2013-03-22  8:47     ` Eli Zaretskii [this message]

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=837gkz6csk.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=dmantipov@yandex.ru \
    --cc=emacs-devel@gnu.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 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.