emacs-devel
[Top][All Lists]
Advanced

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

Re: master 37889523278: Add new `swap` macro and use it


From: Eli Zaretskii
Subject: Re: master 37889523278: Add new `swap` macro and use it
Date: Sun, 07 Jan 2024 13:34:53 +0200

> From: Po Lu <luangruo@yahoo.com>
> Cc: Eli Zaretskii <eliz@gnu.org>,  emacs-devel@gnu.org
> Date: Sun, 07 Jan 2024 18:36:07 +0800
> 
> Stefan Kangas <stefankangas@gmail.com> writes:
> 
> > 2. "the first argument can easily become out of date without notice"
> >
> >     This is true, but of course only when _GL_HAVE___TYPEOF__.
> >
> >     When !_GL_HAVE___TYPEOF__,
> >
> >         swap (T, x, y);
> >
> >     is subject to the same basic type errors as
> >
> >         T tmp = x; x = y; y = tmp;
> >
> >     If that is not workable, we could, as a last resort, just forego
> >     using typeof altogether.  But at that point, the macro is reduced to
> >     be mostly aesthetic.
> 
> There are no "basic type errors" inherent in this statement.  In most
> instances where the type of a variable is modified, it is from one
> integer type to another (e.g. long to ptrdiff_t), which means
> inconsistencies between the type in the swap statement and the values
> being swapped might result in truncation on compilers where __typeof__
> is absent.  As they do not emit diagnostics in response to such errors,
> bugs so introduced won't appear until the erroneous code is in fact
> executed and the values involved are sufficiently large that truncation
> produces a visible malfunction; worse yet, such bugs cannot be
> discovered by developers using GCC.

Please raise these issues with the Gnulib folks, not here.  Meanwhile,
what's good enough for Gnulib should be good enough for us.

> Never in my life have I heard the statements for swapping two variables
> characterized as "insufficiently readable"

With all due respect, if you don't want your own stylistic preferences
to be questioned, please don't question those of others.  Let's all
respect the preferences of each other, okay?



reply via email to

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