Date: Wed, 28 Aug 2024 00:11:20 +0300
On 8/27/24 23:09, Tiago Freire via Std-Proposals wrote:
> I’m going to be a bit ranty here.
>
> People... we are going too far of the rails. I don't think the point is
> to change current behavior, most compilers that matter already have it.
>
> The only thing that it would change if at all would be for some obscure
> compiler that does not have it to have to pick an implementation.
>
> All it has to do is to say that #pragma once precludes the #include
> directive from evaluating the file if that file is the same. That is it!
>
> Whatever that means for that system it’s an implementation detail, left
> for the compiler vendor as an exercise.
First, that's not what is written in the proposal.
Second, what's the point in putting a feature into the standard with the
behavior that amounts to "implementation-defined"? You can just use the
non-standard `#pragma once` if you're happy with it.
> I'm going to be perfectly honest with you, if you are doing things
> right, these “differences” in behavior they don’t matter at all, they
> never did.
And by "right" you mean "your right", right?
> The shear volume of cross-platform projects that use pragma once
> exclusively (despite the fact that they work with different tools), say
> that it doesn’t matter. They don’t seam to mind that the behavior is
> different, like at all.
Any cross-platform project I've worked with did not rely exclusively on
`#pragma once` - exactly because it is not portable. Basically, the only
reason to use `#pragma once` today at all is legacy - a leftover from
times when it offered some, possibly theoretical performance benefit.
Modern compilers are able to recognize #include guards and eliminate
performance benefits that it used to have.
Honestly, this `#pragma once` proposal is trying to solve a non-issue.
Include guards work, they are reliable and as fast as `#pragma once`,
and they are widely supported by IDEs (i.e. you get include guards
automatically when you create a header in most IDEs). For the rare cases
when you have to type them manually, copy&paste is a thing, so typos are
unlikely. OTOH, if `#pragma once` is standardized, and in a wrong way,
that can cause problems if it gets more widely and unconditionally used.
> I’m going to be a bit ranty here.
>
> People... we are going too far of the rails. I don't think the point is
> to change current behavior, most compilers that matter already have it.
>
> The only thing that it would change if at all would be for some obscure
> compiler that does not have it to have to pick an implementation.
>
> All it has to do is to say that #pragma once precludes the #include
> directive from evaluating the file if that file is the same. That is it!
>
> Whatever that means for that system it’s an implementation detail, left
> for the compiler vendor as an exercise.
First, that's not what is written in the proposal.
Second, what's the point in putting a feature into the standard with the
behavior that amounts to "implementation-defined"? You can just use the
non-standard `#pragma once` if you're happy with it.
> I'm going to be perfectly honest with you, if you are doing things
> right, these “differences” in behavior they don’t matter at all, they
> never did.
And by "right" you mean "your right", right?
> The shear volume of cross-platform projects that use pragma once
> exclusively (despite the fact that they work with different tools), say
> that it doesn’t matter. They don’t seam to mind that the behavior is
> different, like at all.
Any cross-platform project I've worked with did not rely exclusively on
`#pragma once` - exactly because it is not portable. Basically, the only
reason to use `#pragma once` today at all is legacy - a leftover from
times when it offered some, possibly theoretical performance benefit.
Modern compilers are able to recognize #include guards and eliminate
performance benefits that it used to have.
Honestly, this `#pragma once` proposal is trying to solve a non-issue.
Include guards work, they are reliable and as fast as `#pragma once`,
and they are widely supported by IDEs (i.e. you get include guards
automatically when you create a header in most IDEs). For the rare cases
when you have to type them manually, copy&paste is a thing, so typos are
unlikely. OTOH, if `#pragma once` is standardized, and in a wrong way,
that can cause problems if it gets more widely and unconditionally used.
Received on 2024-08-27 21:11:24