On Sep 24, 2014 3:29 AM, "Mounir Lamouri" <mou...@lamouri.fr> wrote:
>
> What:
> Allow use of delegated constructor.
>
> Why:
> Improves code readability.
>
> For example:
>
> class Foo {
> public:
> explicit Foo(int a);
> Foo(); // uses a default value for a
For sake of example/discussion, isn't this just default argument smuggling via a different route (e.g. something the style guide prohibits)?
I realize it's possible to do this today, but the Init() duplication is usually enough of a smell to trigger reviewers' Spidey sense.
>
> private:
> int a_;
> };
>
> Without this feature, you would have to write:
> Foo:Foo(int a) {
> Init(a);
> }
> Foo::Foo() {
> Init(kDefaultValue);
> }
> Foo::Init(int a) {
> a_ = a;
> }
>
> With the feature enabled, you can write:
> Foo::Foo(int a)
> : a_(a) {
> }
> Foo::Foo()
> : Foo(kDefaultValue) {
> }
>
> Not having to use Init() makes things more readable and more natural. It
> also allows the members to be initialized in the initialization list
> instead of a function.
>
> -- Mounir
>
> --
> --
> Chromium Developers mailing list: chromi...@chromium.org
> View archives, change email options, or unsubscribe:
> http://groups.google.com/a/chromium.org/group/chromium-dev
Note that the current style guide discourages complex work in constructors. The discussions of Init() and its reasonings are complex and lengthy, full of both pros and cons, but am I correct that you would see this as a way to de-Init() things that would otherwise have Init()?
I'm not trying to bait anything - I don't gave strong feelings one way or the other. But I do want to check what the end result may look like, and whether or not we want that.
> View archives, change email options, or unsubscribe:
> http://groups.google.com/a/chromium.org/group/chromium-dev
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
For sake of example/discussion, isn't this just default argument smuggling via a different route (e.g. something the style guide prohibits)?
For sake of example/discussion, isn't this just default argument smuggling via a different route (e.g. something the style guide prohibits)?
--
--
Chromium Developers mailing list: chromi...@chromium.org
To me, this seems like a stronger case for in-class member
initializers than delegated constructors. Then you could just say (in
the header):
int child_id = 0;
int gl_id = 0;
// ...
On Thu, Sep 25, 2014 at 10:22 AM, Dana Jansens wrote:
> I know I've wanted this before. For example the 4 constructors of
> ResourceProvider::Resource could be simpler:
> https://code.google.com/p/chromium/codesearch#chromium/src/cc/resources/resource_provider.cc&l=209
>
> On Thu, Sep 25, 2014 at 4:16 AM, Maciej Pawlowski
I know I've wanted this before. For example the 4 constructors of ResourceProvider::Resource could be simpler: https://code.google.com/p/chromium/codesearch#chromium/src/cc/resources/resource_provider.cc&l=209
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
It sounds as if support for this varies, but there's no real opposition, and some explicit support from notable owners.Can we go ahead and put this in the allowed list?
PK
Send a patch that moves the feature to the correct place in styleguide/c++/c++11.html *and* uses the feature in some bit of cross-platform code so we can make sure it works and I'll approve it once the trybots are green.\
--
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.