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: Po Lu
Subject: Re: master 37889523278: Add new `swap` macro and use it
Date: Sat, 06 Jan 2024 17:09:04 +0800
User-agent: Gnus/5.13 (Gnus v5.13)

Stefan Kangas <stefankangas@gmail.com> writes:

> Ouch, right.  I was inspired by some other large project, let's leave it
> unnamed, but their C chops were big enough that I let my guard down.
> Unfortunately for me, they happen to support far fewer compilers than we
> do.  Sorry about that, and thanks for being on your toes.
>
> I had a look at what Gnulib has, and came up with the attached patch.
> It still lets us avoid the type conversion problems on GCC, clang and
> reasonably recent versions of IBM C and sunc.  I'm not sure it's worth
> it though, so perhaps my original patch should just be reverted.

That's worse, since code using the macro incorrectly will function on
some compilers but not others.  I suggest leaving programmers to
manually swap variables as they have always done: the brief fascination
with macros all C programmers experience never fails to produce
unnecessary macros for simple operations that yield little benefit, and
"swap" operations are no exception.


reply via email to

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