[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.
- Re: master 37889523278: Add new `swap` macro and use it, (continued)
- Re: master 37889523278: Add new `swap` macro and use it, Po Lu, 2024/01/06
- Re: master 37889523278: Add new `swap` macro and use it, Stefan Kangas, 2024/01/06
- Re: master 37889523278: Add new `swap` macro and use it, Po Lu, 2024/01/06
- Re: master 37889523278: Add new `swap` macro and use it, Eli Zaretskii, 2024/01/06
- Re: master 37889523278: Add new `swap` macro and use it, Po Lu, 2024/01/06
- Re: master 37889523278: Add new `swap` macro and use it, Eli Zaretskii, 2024/01/06
- Re: master 37889523278: Add new `swap` macro and use it, Po Lu, 2024/01/06
- Re: master 37889523278: Add new `swap` macro and use it, Stefan Kangas, 2024/01/07
- Re: master 37889523278: Add new `swap` macro and use it, Po Lu, 2024/01/07
- Re: master 37889523278: Add new `swap` macro and use it, Eli Zaretskii, 2024/01/07
- Re: master 37889523278: Add new `swap` macro and use it,
Stefan Kangas <=
- Re: master 37889523278: Add new `swap` macro and use it, Po Lu, 2024/01/07
- Re: master 37889523278: Add new `swap` macro and use it, Eli Zaretskii, 2024/01/07
- Re: master 37889523278: Add new `swap` macro and use it, Po Lu, 2024/01/07
- Re: master 37889523278: Add new `swap` macro and use it, Eli Zaretskii, 2024/01/07
- Re: master 37889523278: Add new `swap` macro and use it, Stefan Kangas, 2024/01/07
- Re: master 37889523278: Add new `swap` macro and use it, Po Lu, 2024/01/07
- Re: master 37889523278: Add new `swap` macro and use it, Eli Zaretskii, 2024/01/07
- Re: master 37889523278: Add new `swap` macro and use it, Gregory Heytings, 2024/01/11
- Re: master 37889523278: Add new `swap` macro and use it, Stefan Kangas, 2024/01/13
- Re: master 37889523278: Add new `swap` macro and use it, Richard Stallman, 2024/01/13