[webkit-dev] converting by constructor
Darin Adler
darin at apple.com
Mon May 17 15:11:58 PDT 2010
I think the Google guideline is pretty close to what a WebKit guideline would be. The explicit keyword should almost always be used when a constructor is creating an object and not just converting type from one to another. Leaving out the explicit keyword should be thought of as equivalent to defining a conversion operator, albeit working in the opposite direction.
The AtomicString example Adam Barth cited is a problematic one. The cost of making an AtomicString from a String is high enough that having the conversion be implicit might be a mistake! But it was intentional
I think the best way for us to clarify our guideline for this would be to discuss a few individual cases where we have a non-explicit constructor. We can talk about why they are not explicit and see if we find they are just bugs or show a principle at work.
-- Darin
More information about the webkit-dev
mailing list