Topic: Use of non-static data members in default
Author: David Krauss <potswa@gmail.com>
Date: Wed, 19 Mar 2014 07:07:09 +0800
Raw View
--Apple-Mail=_0B763BF2-9AAE-4008-BD07-AE698EA83888
Content-Type: text/plain; charset=ISO-8859-1
The standard provides the rationale in a note section. It would make the default argument dependent on computation of the implicit this argument.
Requiring the compiler to detect default argument dependencies and order computations correctly doesn't seem like such a tall order. Removing the restriction might only be a DR, it's just a decision whether to do it.
On 2014-03-19, at 7:03 AM, xavi <gratal@gmail.com> wrote:
> Is there any compelling reason why non-static data members (and expressions containing them) cannot be used in default arguments to non-static member functions?
> Has there been any proposal in the direction of allowing them?
>
> --
>
> ---
> 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.
> Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--Apple-Mail=_0B763BF2-9AAE-4008-BD07-AE698EA83888
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;">The standard provides =
the rationale in a note section. It would make the default argument depende=
nt on computation of the implicit <font face=3D"Courier">this</font> argume=
nt.<div><br></div><div>Requiring the compiler to detect default argument de=
pendencies and order computations correctly doesn’t seem like such a =
tall order. Removing the restriction might only be a DR, it’s just a =
decision whether to do it.<br><div><br><div><div>On 2014–03–19,=
at 7:03 AM, xavi <<a href=3D"mailto:gratal@gmail.com">gratal@gmail.com<=
/a>> wrote:</div><br class=3D"Apple-interchange-newline"><blockquote typ=
e=3D"cite"><div dir=3D"ltr">Is there any compelling reason why non-static d=
ata members (and expressions containing them) cannot be used in default arg=
uments to non-static member functions?<div>Has there been any proposal in t=
he direction of allowing them?</div>
</div><div><br class=3D"webkit-block-placeholder"></div>
-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups "=
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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br>
</blockquote></div><br></div></div></body></html>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--Apple-Mail=_0B763BF2-9AAE-4008-BD07-AE698EA83888--
.
Author: Richard Smith <richard@metafoo.co.uk>
Date: Tue, 18 Mar 2014 17:53:00 -0700
Raw View
--001a113376fe0948c404f4eb13e0
Content-Type: text/plain; charset=ISO-8859-1
On Tue, Mar 18, 2014 at 4:07 PM, David Krauss <potswa@gmail.com> wrote:
> The standard provides the rationale in a note section. It would make the
> default argument dependent on computation of the implicit this argument.
>
> Requiring the compiler to detect default argument dependencies and order
> computations correctly doesn't seem like such a tall order. Removing the
> restriction might only be a DR, it's just a decision whether to do it.
>
One option would be for the standard to require default arguments to be
evaluated left-to-right after evaluating the callee and the other
arguments, and then they could depend on prior arguments as well as 'this'.
I've many times wanted to write the equivalent of:
void f(A a, B b = g(a));
(There's at least one problem with this: there are ABIs that destroy
parameters in the callee left-to-right, and thus require them to be
initialized right-to-left to guarantee that destruction order is the
reverse of construction order.)
On 2014-03-19, at 7:03 AM, xavi <gratal@gmail.com> wrote:
>
> Is there any compelling reason why non-static data members (and
> expressions containing them) cannot be used in default arguments to
> non-static member functions?
> Has there been any proposal in the direction of allowing them?
>
> --
>
> ---
> 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.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
>
> --
>
> ---
> 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.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--001a113376fe0948c404f4eb13e0
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
ue, Mar 18, 2014 at 4:07 PM, David Krauss <span dir=3D"ltr"><<a href=3D"=
mailto:potswa@gmail.com" target=3D"_blank">potswa@gmail.com</a>></span> =
wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div style=3D"word-wrap:break-word">The stan=
dard provides the rationale in a note section. It would make the default ar=
gument dependent on computation of the implicit <font face=3D"Courier">this=
</font> argument.<div>
<br></div><div>Requiring the compiler to detect default argument dependenci=
es and order computations correctly doesn’t seem like such a tall ord=
er. Removing the restriction might only be a DR, it’s just a decision=
whether to do it.</div>
</div></blockquote><div><br></div><div>One option would be for the standard=
to require default arguments to be evaluated left-to-right after evaluatin=
g the callee and the other arguments, and then they could depend on prior a=
rguments as well as 'this'. I've many times wanted to write the=
equivalent of:</div>
<div><br></div><div> void f(A a, B b =3D g(a));</div><div><br></div><=
div>(There's at least one problem with this: there are ABIs that destro=
y parameters in the callee left-to-right, and thus require them to be initi=
alized right-to-left to guarantee that destruction order is the reverse of =
construction order.)</div>
<div><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex=
;border-left:1px #ccc solid;padding-left:1ex"><div style=3D"word-wrap:break=
-word"><div><div><div class=3D"h5"><div><div><div>On 2014–03–19=
, at 7:03 AM, xavi <<a href=3D"mailto:gratal@gmail.com" target=3D"_blank=
">gratal@gmail.com</a>> wrote:</div>
<br><blockquote type=3D"cite"><div dir=3D"ltr">Is there any compelling reas=
on why non-static data members (and expressions containing them) cannot be =
used in default arguments to non-static member functions?<div>Has there bee=
n any proposal in the direction of allowing them?</div>
</div><div><br></div>
-- <br>
<br>
--- <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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</blockquote></div><br></div></div></div></div></div><div class=3D"HOEnZb">=
<div class=3D"h5">
<p></p>
-- <br>
<br>
--- <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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--001a113376fe0948c404f4eb13e0--
.