On 5/9/17 9:17 AM, Nathan Froyd wrote:
On Tue, May 9, 2017 at 5:58 AM, Emilio Cobos Álvarez <emi...@crisal.io> wrote:
Personally, I don't think that the fact that they're not used as much as
they could/should is a good argument to prevent their usage, but I don't
know what's the general opinion on that.

The argument I have always heard, Gecko-wise and elsewhere [1], is to
prefer pointers for modification

This is for primitive-typed out or inout params, right?

In other words, we should prefer "int*" to "int&" for places where we expect the callee to modify the int, just like we should prefer "MyClass**" to "MyClass*&". I guess the same for POD structs if we expect people to be writing to them wholesale via assignment operators? Not sure.

But for object-typed things like dom::Element or nsIFrame, it seems better to me to pass references instead of pointers (i.e "Element&" vs "Element*") for what are fundamentally in params, even though the callee may call mutators on the passed-in object. That is, the internal state of the element may change, but its identity will not.

-Boris
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to