Topic: Nodiscard in STL
Author: williamsson@gmail.com
Date: Thu, 17 Nov 2016 15:33:11 -0800 (PST)
Raw View
------=_Part_5318_815582148.1479425591605
Content-Type: multipart/alternative;
boundary="----=_Part_5319_545201491.1479425591605"
------=_Part_5319_545201491.1479425591605
Content-Type: text/plain; charset=UTF-8
In STL there are many const declared member functions, without parameters,
that return a value.
There is no reason to call such functions without checking the result.
One example is std::vector::empty(). Beginners often mistake it for the
verb "to make empty" and disregard the returned boolean (hopefully it will
be called "is_empty" in STL 2.0 to avoid ambiguity).
If the nodiscard attribute was added, the compiler would be encouraged to
issue a warning when such a function is used incorrectly.
Do you think that would be a good idea?
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/3c43135f-9b1e-4331-8765-ce05466fe145%40isocpp.org.
------=_Part_5319_545201491.1479425591605
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>In STL there are many const declared member functions=
, without parameters, that return a value.<br><br>There is no reason to cal=
l such functions without checking the result.<br><br>One example is std::ve=
ctor::empty(). Beginners often mistake it for the verb "to make empty&=
quot; and disregard the returned boolean (hopefully it will be called "=
;is_empty" in STL 2.0 to avoid ambiguity).<br><br>If the nodiscard att=
ribute was added, the compiler would be encouraged to issue a warning when =
such a function is used incorrectly.<br><br>Do you think that would be=C2=
=A0a good idea?</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/3c43135f-9b1e-4331-8765-ce05466fe145%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/3c43135f-9b1e-4331-8765-ce05466fe145=
%40isocpp.org</a>.<br />
------=_Part_5319_545201491.1479425591605--
------=_Part_5318_815582148.1479425591605--
.
Author: "D. B." <db0451@gmail.com>
Date: Thu, 17 Nov 2016 23:44:04 +0000
Raw View
--001a11442612c86489054187c392
Content-Type: text/plain; charset=UTF-8
The problem here is that many newbies are not sufficiently informed that
they should compile with all warnings on, where unused return values are a
common warning if they did. How would nodiscard help with that, unless it
was made mandatory to warn about it regardless of the user's settings?
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhHSGB4Ean2-hJOXkyP%2BhaZ35SpmFxvc8hxL%3Dd0n1_j%3DBw%40mail.gmail.com.
--001a11442612c86489054187c392
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">The problem here is that many newbies are not sufficiently=
informed that they should compile with all warnings on, where unused retur=
n values are a common warning if they did. How would nodiscard help with th=
at, unless it was made mandatory to warn about it regardless of the user=
9;s settings?<br></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CACGiwhHSGB4Ean2-hJOXkyP%2BhaZ35SpmFx=
vc8hxL%3Dd0n1_j%3DBw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhHSGB=
4Ean2-hJOXkyP%2BhaZ35SpmFxvc8hxL%3Dd0n1_j%3DBw%40mail.gmail.com</a>.<br />
--001a11442612c86489054187c392--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Thu, 17 Nov 2016 15:49:23 -0800 (PST)
Raw View
------=_Part_6288_511579964.1479426563683
Content-Type: multipart/alternative;
boundary="----=_Part_6289_1940678412.1479426563684"
------=_Part_6289_1940678412.1479426563684
Content-Type: text/plain; charset=UTF-8
This seems more like a quality-of-implementation thing. It's not like
`[[noreturn]]`, which the compiler can actually use to optimize code
better. This attribute exists solely to cause warnings to happen.
So let implementers decide when they want to issue such warnings.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/99048e66-8aee-4bb8-a7bc-7cfc0cfdcf02%40isocpp.org.
------=_Part_6289_1940678412.1479426563684
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">This seems more like a quality-of-implementation thing. It=
's not like `[[noreturn]]`, which the compiler can actually use to opti=
mize code better. This attribute exists solely to cause warnings to happen.=
<br><br>So let implementers decide when they want to issue such warnings.<b=
r></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/99048e66-8aee-4bb8-a7bc-7cfc0cfdcf02%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/99048e66-8aee-4bb8-a7bc-7cfc0cfdcf02=
%40isocpp.org</a>.<br />
------=_Part_6289_1940678412.1479426563684--
------=_Part_6288_511579964.1479426563683--
.
Author: williamsson@gmail.com
Date: Thu, 17 Nov 2016 15:56:46 -0800 (PST)
Raw View
------=_Part_2812_1797691877.1479427006699
Content-Type: multipart/alternative;
boundary="----=_Part_2813_195215165.1479427006699"
------=_Part_2813_195215165.1479427006699
Content-Type: text/plain; charset=UTF-8
I think the warning should be enabled at a less strict warning level than
"all".
Sometimes it makes sense to ignore return values, but never with functions
such as empty().
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/47108f7d-ccbf-4421-b466-23df7ed56eec%40isocpp.org.
------=_Part_2813_195215165.1479427006699
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>I think the warning should be enabled at a less stric=
t warning level than "all".</div><div><br></div><div>Sometimes it=
makes sense to ignore return values, but never with=C2=A0functions such as=
empty().=C2=A0</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/47108f7d-ccbf-4421-b466-23df7ed56eec%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/47108f7d-ccbf-4421-b466-23df7ed56eec=
%40isocpp.org</a>.<br />
------=_Part_2813_195215165.1479427006699--
------=_Part_2812_1797691877.1479427006699--
.
Author: Nevin Liber <nevin@eviloverlord.com>
Date: Thu, 17 Nov 2016 18:20:19 -0600
Raw View
--001a11c15902cd13dc054188471f
Content-Type: text/plain; charset=UTF-8
On Thu, Nov 17, 2016 at 5:49 PM, Nicol Bolas <jmckesson@gmail.com> wrote:
> So let implementers decide when they want to issue such warnings.
>
+1. Especially since if the standard gets it wrong, it takes 3-6 years to
correct it (if it ever gets fixed at all).
Are these hiding real bugs? You call functions to modify state and/or
query state. In my experience, it's the functions that modify state
*and* return
some other state that are prime candidates (and even then, most of those
functions are correct and legal to call while ignoring their return value).
--
Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> +1-847-691-1404
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGg_6%2BOH4aLW84oePoT-hfpdL6vBn%3DC%2Brk0s7Y%2B7Qa0YP1eqxw%40mail.gmail.com.
--001a11c15902cd13dc054188471f
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra">On Thu, Nov 17, 2016 at 5:49 PM=
, Nicol Bolas <span dir=3D"ltr"><<a href=3D"mailto:jmckesson@gmail.com" =
target=3D"_blank">jmckesson@gmail.com</a>></span> wrote:<br><div class=
=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8=
ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">So let imp=
lementers decide when they want to issue such warnings.</div></blockquote><=
div>=C2=A0</div></div>+1.=C2=A0 Especially since if the standard gets it wr=
ong, it takes 3-6 years to correct it (if it ever gets fixed at all).</div>=
<div class=3D"gmail_extra"><br></div><div class=3D"gmail_extra">Are these h=
iding real bugs?=C2=A0 You call functions to modify state and/or query stat=
e.=C2=A0 In my experience, it's the functions that modify state <i>and<=
/i>=C2=A0return some other state that are prime candidates (and even then, =
most of those functions are correct and legal to call while ignoring their =
return value).<br>-- <br><div class=3D"gmail_signature" data-smartmail=3D"g=
mail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><div>=C2=A0Nevin &qu=
ot;:-)" Liber=C2=A0 <mailto:<a href=3D"mailto:nevin@eviloverlord.co=
m" target=3D"_blank">nevin@eviloverlord.com</a>> =C2=A0+1-847-691-1404</=
div></div></div></div></div>
</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAGg_6%2BOH4aLW84oePoT-hfpdL6vBn%3DC%=
2Brk0s7Y%2B7Qa0YP1eqxw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoo=
ter">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGg_6%2B=
OH4aLW84oePoT-hfpdL6vBn%3DC%2Brk0s7Y%2B7Qa0YP1eqxw%40mail.gmail.com</a>.<br=
/>
--001a11c15902cd13dc054188471f--
.
Author: williamsson@gmail.com
Date: Fri, 18 Nov 2016 00:29:03 -0800 (PST)
Raw View
------=_Part_1958_277751635.1479457743975
Content-Type: multipart/alternative;
boundary="----=_Part_1959_1450709458.1479457743975"
------=_Part_1959_1450709458.1479457743975
Content-Type: text/plain; charset=UTF-8
Well, at least I've seen such bugs. I think implementers should consider it.
My main concern is with function names that doesn't make clear what the
function does.
"Class names are nouns, function names are verbs" is a common naming
convention.
It can be a bit confusing to introduce STL in codebases where names like
"empty" and "size" have the verb meaning.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b9efa99d-8d91-4e64-8046-02b0aba7bc67%40isocpp.org.
------=_Part_1959_1450709458.1479457743975
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Well, at least I've seen such bugs. I think imple=
menters should consider it.<br><br>My main concern is with function names t=
hat doesn't make clear what the function does.<br><br>"Class names=
are nouns, function names are verbs" is a common naming convention.<b=
r><br>It can be a bit confusing to introduce STL in codebases where names l=
ike "empty" and "size" have the verb meaning.</div></di=
v>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/b9efa99d-8d91-4e64-8046-02b0aba7bc67%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/b9efa99d-8d91-4e64-8046-02b0aba7bc67=
%40isocpp.org</a>.<br />
------=_Part_1959_1450709458.1479457743975--
------=_Part_1958_277751635.1479457743975--
.
Author: Nevin Liber <nevin@eviloverlord.com>
Date: Fri, 18 Nov 2016 03:14:34 -0600
Raw View
--94eb2c094b186cc3f605418fbe11
Content-Type: text/plain; charset=UTF-8
On Fri, Nov 18, 2016 at 2:29 AM, <williamsson@gmail.com> wrote:
> It can be a bit confusing to introduce STL in codebases where names like
> "empty" and "size" have the verb meaning.
>
>
While some newbie might think empty() clears the container (by ignoring
that it is a const member function, but they can would think it returns the
previous emptiness state of the container, and just cast the result to
void), I cannot imagine what they believe size() with no parameters would
do. Since you've seen these bugs, could you describe them in more detail?
--
Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> +1-847-691-1404
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGg_6%2BNUB1OG6uaqqu_%3DNYD%2B4XcrVdfEo4rXCga9kxhz5qA5hw%40mail.gmail.com.
--94eb2c094b186cc3f605418fbe11
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra">On Fri, Nov 18, 2016 at 2:29 AM=
, <span dir=3D"ltr"><<a href=3D"mailto:williamsson@gmail.com" target=3D=
"_blank">williamsson@gmail.com</a>></span> wrote:<br><div class=3D"gmail=
_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border=
-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>It can be a bi=
t confusing to introduce STL in codebases where names like "empty"=
; and "size" have the verb meaning.</div></div><span class=3D"">
<p></p></span></blockquote></div><br>While some newbie might think empty() =
clears the container (by ignoring that it is a const member function, but t=
hey can would think it returns the previous emptiness state of the containe=
r, and just cast the result to void), I cannot imagine what they believe si=
ze() with no parameters would do.=C2=A0 Since you've seen these bugs, c=
ould you describe them in more detail?<br>-- <br><div class=3D"gmail_signat=
ure" data-smartmail=3D"gmail_signature"><div dir=3D"ltr"><div><div dir=3D"l=
tr"><div>=C2=A0Nevin ":-)" Liber=C2=A0 <mailto:<a href=3D"mail=
to:nevin@eviloverlord.com" target=3D"_blank">nevin@eviloverlord.com</a>>=
=C2=A0+1-847-691-1404</div></div></div></div></div>
</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAGg_6%2BNUB1OG6uaqqu_%3DNYD%2B4XcrVd=
fEo4rXCga9kxhz5qA5hw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGg_6%2BNU=
B1OG6uaqqu_%3DNYD%2B4XcrVdfEo4rXCga9kxhz5qA5hw%40mail.gmail.com</a>.<br />
--94eb2c094b186cc3f605418fbe11--
.
Author: williamsson@gmail.com
Date: Fri, 18 Nov 2016 05:40:24 -0800 (PST)
Raw View
------=_Part_6119_2107965272.1479476425064
Content-Type: multipart/alternative;
boundary="----=_Part_6120_573248694.1479476425064"
------=_Part_6120_573248694.1479476425064
Content-Type: text/plain; charset=UTF-8
I haven't seen size() being used incorrectly, but I've seen bugs where
programmers called empty as they thought it cleared the vector. The name is
misleading.
A warning might create suspicion, but like you said we can't know for sure
if it stops them from casting to void.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/a1966b27-0499-4cf1-be46-fcf867aec5d7%40isocpp.org.
------=_Part_6120_573248694.1479476425064
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>I haven't=C2=A0seen size() being used incorrectly=
, but I've seen bugs where programmers called empty as they thought it =
cleared the vector. The name is misleading.</div><div><br>A warning might c=
reate suspicion, but like you said we can't know for sure if it stops t=
hem from casting to void.</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/a1966b27-0499-4cf1-be46-fcf867aec5d7%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/a1966b27-0499-4cf1-be46-fcf867aec5d7=
%40isocpp.org</a>.<br />
------=_Part_6120_573248694.1479476425064--
------=_Part_6119_2107965272.1479476425064--
.
Author: "D. B." <db0451@gmail.com>
Date: Fri, 18 Nov 2016 13:41:14 +0000
Raw View
--001a114ccb68bb950d05419375aa
Content-Type: text/plain; charset=UTF-8
The kind of new user who would make that mistake about empty() is not going
to know that casting to void is a thing that can be done.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhERJuu6VZz3%2B-Lfmrr2i8YHO7Zk7UMa3kg3L_fpaoTnQg%40mail.gmail.com.
--001a114ccb68bb950d05419375aa
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">The kind of new user who would make that mistake about emp=
ty() is not going to know that casting to void is a thing that can be done.=
<br></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CACGiwhERJuu6VZz3%2B-Lfmrr2i8YHO7Zk7U=
Ma3kg3L_fpaoTnQg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhERJuu6VZ=
z3%2B-Lfmrr2i8YHO7Zk7UMa3kg3L_fpaoTnQg%40mail.gmail.com</a>.<br />
--001a114ccb68bb950d05419375aa--
.
Author: Matthew Woehlke <mwoehlke.floss@gmail.com>
Date: Fri, 18 Nov 2016 10:38:24 -0500
Raw View
On 2016-11-18 03:29, williamsson@gmail.com wrote:
> "Class names are nouns, function names are verbs" is a common naming
> convention.
This is incomplete. *Imperative* functions are verbs. *Introspective*
functions may be *linking* verbs, sometimes with a noun or adjective
(e.g. `is_X`, `has_X`, `contains`), but may *also* be nouns (but more
specifically, *attributive* nouns) or adjectives alone. (Unless you're
one of those people that think everything should start with `get`.)
> It can be a bit confusing to introduce STL in codebases where names like
> "empty" and "size" have the verb meaning.
The trouble, of course, is that `empty` can be *either* a verb or an
adjective; `is_empty` - being unambiguously in the introspective
function category - would have been better.
--
Matthew
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/582F2070.9080103%40gmail.com.
.
Author: HarD Gamer <rodrigojose690@gmail.com>
Date: Fri, 18 Nov 2016 12:52:20 -0800 (PST)
Raw View
------=_Part_1859_1179210018.1479502340341
Content-Type: multipart/alternative;
boundary="----=_Part_1860_1833659549.1479502340341"
------=_Part_1860_1833659549.1479502340341
Content-Type: text/plain; charset=UTF-8
The big problem is that all std is made without is_x has_x, Making
is_empty() we are organizing the C++ naming notation, and if empty() will
be changed, why not all the std will go along?
Ex:
ostream::precision() -> set_precision()
ostream::fill() -> set_fill()
equal() -> is_equal()
.............
[Acidentally C++11 has a is_permutation() STL function]
Em quinta-feira, 17 de novembro de 2016 21:33:11 UTC-2, willi...@gmail.com
escreveu:
>
> In STL there are many const declared member functions, without parameters,
> that return a value.
>
> There is no reason to call such functions without checking the result.
>
> One example is std::vector::empty(). Beginners often mistake it for the
> verb "to make empty" and disregard the returned boolean (hopefully it will
> be called "is_empty" in STL 2.0 to avoid ambiguity).
>
> If the nodiscard attribute was added, the compiler would be encouraged to
> issue a warning when such a function is used incorrectly.
>
> Do you think that would be a good idea?
>
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/16747693-f721-45ae-ab1a-80ce5ebd7420%40isocpp.org.
------=_Part_1860_1833659549.1479502340341
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">The big problem is that all std is made without is_x =C2=
=A0has_x, Making is_empty() we are organizing the C++ naming notation, and =
if empty() will be changed, why not all the std will go along?<div>Ex:</div=
><div>ostream::precision() -> set_precision()</div><div>ostream::fill() =
-> set_fill()<br></div><div>equal() -> is_equal()</div><div>.........=
....</div><div><br></div><div>[Acidentally C++11 has a is_permutation() STL =
function]</div><div><br></div><div><br><br>Em quinta-feira, 17 de novembro =
de 2016 21:33:11 UTC-2, willi...@gmail.com escreveu:<blockquote class=3D"g=
mail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc sol=
id;padding-left: 1ex;"><div dir=3D"ltr"><div>In STL there are many const de=
clared member functions, without parameters, that return a value.<br><br>Th=
ere is no reason to call such functions without checking the result.<br><br=
>One example is std::vector::empty(). Beginners often mistake it for the ve=
rb "to make empty" and disregard the returned boolean (hopefully =
it will be called "is_empty" in STL 2.0 to avoid ambiguity).<br><=
br>If the nodiscard attribute was added, the compiler would be encouraged t=
o issue a warning when such a function is used incorrectly.<br><br>Do you t=
hink that would be=C2=A0a good idea?</div></div></blockquote></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/16747693-f721-45ae-ab1a-80ce5ebd7420%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/16747693-f721-45ae-ab1a-80ce5ebd7420=
%40isocpp.org</a>.<br />
------=_Part_1860_1833659549.1479502340341--
------=_Part_1859_1179210018.1479502340341--
.