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: Stefan Kangas
Subject: Re: master 37889523278: Add new `swap` macro and use it
Date: Sun, 7 Jan 2024 01:45:54 -0800

Po Lu <luangruo@yahoo.com> writes:

> Stefan Kangas <stefankangas@gmail.com> writes:
>
>> That is a serious objection if it is true.  But nothing approaching that
>> has been shown to be true so far, not in this thread at any rate.
>
> How is that so?  I and Andreas have both demonstrated that in our
> respective replies in this thread.

The objections I have seen are:

1. "__tmp as a reserved identifier might clash with future
   implementations"

   This is true and can be fixed by renaming it.

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.

So no, I don't currently see any evidence for the claims that this
"cannot be fixed" or is "impossible to implement in C".  If there is any
substance to that, you will probably have to explain it again.

Now, as I have already explained, the macro is certainly less
subjectively appealing if we have to manually write out the type every
time.  In my view it is still a bit better, since we get both more
readable code and additional safety on our main targets.  (Note that we
don't currently use -Wconversion in Emacs.)

I'm still open to hearing people's opinion about this, of course.



reply via email to

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