Date: Sat, 16 Apr 2022 11:46:55 -0700
On Saturday, 16 April 2022 06:12:50 PDT Jonathan Sweemer via Std-Proposals
wrote:
> What I would like to propose is a new syntax for deducing either a value
> type or a const reference type depending on whether the type being deduced
> is both a) trivially copyable and b) two words in size or fewer.
Why two words? Why not one? Why not a cacheline in size? If this is a fixed
rule, you must give motivation for the number; if it's going to be
implementation-defined, you must explain why it is and how the compilers
should select a value. And how developers should deal with those changes.
> I am aware of the call_traits library
> <https://www.boost.org/doc/libs/master/libs/utility/doc/html/utility/utiliti
> es/call_traits.html> in boost that offers similar functionality, but as far
> as I understand, call_traits results in all user-defined types being passed
> by reference, whereas I am proposing that even user-defined types can be
> passed by value as long as they meet the requirements.
That might change once we have a proper trait for relocatability and trivial
relocatability. Maybe you should investigate why they have this limitation and
address that root cause. Then we can have a library solution instead.
> The second potential drawback is that the two times word size limit is a
> bit arbitrary, and there might be those who want the limit to be one word
> or three words or something else. Perhaps there is a better way to
> standardize the limit based on the platform, or perhaps it can be left up
> to vendors to decide.
Then you need to expand on motivation. You have not given any. I have some
suspicions on why it would be. I did, after all, institute the rule that all
trivial-and-two-pointers-or-less-in-size types would be passed by value in the
Qt API. But note the important differences:
1) There's no auto. All types are spelled out because that's not template
code.
2) In fact, all such functions are out-of-line. That's where there's an ABI
benefit. For inline functions, parameter passing by-const-ref and by-value are
practically identical.
3) Qt cares about retaining ABI, so your advantage of seamlessly changing when
more members are added to a type is irrelevant. In fact, we'd want the
opposite: preferably, that we catch it as a compile-time failure before any
release is made.
wrote:
> What I would like to propose is a new syntax for deducing either a value
> type or a const reference type depending on whether the type being deduced
> is both a) trivially copyable and b) two words in size or fewer.
Why two words? Why not one? Why not a cacheline in size? If this is a fixed
rule, you must give motivation for the number; if it's going to be
implementation-defined, you must explain why it is and how the compilers
should select a value. And how developers should deal with those changes.
> I am aware of the call_traits library
> <https://www.boost.org/doc/libs/master/libs/utility/doc/html/utility/utiliti
> es/call_traits.html> in boost that offers similar functionality, but as far
> as I understand, call_traits results in all user-defined types being passed
> by reference, whereas I am proposing that even user-defined types can be
> passed by value as long as they meet the requirements.
That might change once we have a proper trait for relocatability and trivial
relocatability. Maybe you should investigate why they have this limitation and
address that root cause. Then we can have a library solution instead.
> The second potential drawback is that the two times word size limit is a
> bit arbitrary, and there might be those who want the limit to be one word
> or three words or something else. Perhaps there is a better way to
> standardize the limit based on the platform, or perhaps it can be left up
> to vendors to decide.
Then you need to expand on motivation. You have not given any. I have some
suspicions on why it would be. I did, after all, institute the rule that all
trivial-and-two-pointers-or-less-in-size types would be passed by value in the
Qt API. But note the important differences:
1) There's no auto. All types are spelled out because that's not template
code.
2) In fact, all such functions are out-of-line. That's where there's an ABI
benefit. For inline functions, parameter passing by-const-ref and by-value are
practically identical.
3) Qt cares about retaining ABI, so your advantage of seamlessly changing when
more members are added to a type is irrelevant. In fact, we'd want the
opposite: preferably, that we catch it as a compile-time failure before any
release is made.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Software Architect - Intel DPG Cloud Engineering
Received on 2022-04-16 18:46:56