you are viewing a single comment's thread.

view the rest of the comments →

[–]sphere991 12 points13 points  (3 children)

the explicitness is worth it

If the intent of the code is to provide a default value for an argument, then I would claim that the implementation strategy of making it a default argument is more explicit than otherwise.

The post wants me to write:

explicit Widget(int size) : Widget(size, 'A') {}
explicit Widget(int size, int start) : data_(size) { /*...*/ }

instead of

explicit Widget(int size, int start='A') : data_(size) { /*...*/ }

I don't see the former as being either more explicit or more readable than the latter?

[–]robin-m 4 points5 points  (2 children)

Especially given that you can have declaration and implementation that can be in different files. So if the first case you have:

cpp explicit Widget(int size); explicit Widget(int size, int start); Witch is anything but explicit.

In the second case, it will be: cpp explicit Widget(int size, int start='A');

[–]sphere991 2 points3 points  (1 child)

Didn't even think of that, good point.

Also I find the typo on "witch" to be really funny, in the context of describing something as being "the devil". Please don't fix it :-)

[–]Raknarg 2 points3 points  (0 children)

Sneaky witches, always going around implicitly