[
https://issues.apache.org/jira/browse/MESOS-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13921587#comment-13921587
]
Benjamin Hindman commented on MESOS-1057:
-----------------------------------------
To follow up on [~jieyu]'s comment, there are a lot of places where we rely on
implicit conversions through constructors that are safe, and we want to keep
those. I do, however, think an audit of the single argument constructors is a
fine thing to do to find places where we have not used 'explicit' but would
prefer to. This is a clear place where we diverge from the Google style guide,
and we should probably update our style guide to mark that distinction.
> libprocess: Add explicit to single argument constructors
> --------------------------------------------------------
>
> Key: MESOS-1057
> URL: https://issues.apache.org/jira/browse/MESOS-1057
> Project: Mesos
> Issue Type: Improvement
> Components: libprocess
> Reporter: Bernd Mathiske
> Assignee: Bernd Mathiske
> Priority: Minor
> Labels: newbie, style
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> Exactly like MESOS-1055, just splitting out the task for lib process into a
> separate issue.
> From the google style guide:
> Normally, if a constructor takes one argument, it can be used as a
> conversion. For instance, if you define Foo::Foo(string name) and then pass a
> string to a function that expects a Foo, the constructor will be called to
> convert the string into a Foo and will pass the Foo to your function for you.
> This can be convenient but is also a source of trouble when things get
> converted and new objects created without you meaning them to. Declaring a
> constructor explicit prevents it from being invoked implicitly as a
> conversion.
> Implicit conversions should be the exception to avoid unwanted and unexpected
> behaviour.
--
This message was sent by Atlassian JIRA
(v6.2#6252)