I think passing non-nullable things by reference is good, but I think we
should keep it consistent for a given type. So, for example, we shouldn't
have some callsites that take an nsPresContext* and others that take an
nsPresContext& (unless we have a rare case of a nullable presContext arg,
in which case |nsPresContext* aPresContextOrNull| would suffice).

Basically, I think consistency is important, but maintaining that
consistency per-type rather than system-wide seems like a reasonable
compromise. Curious as to what others think here.

bholley

On Tue, May 9, 2017 at 11:58 AM, Emilio Cobos Álvarez <emi...@crisal.io>
wrote:

> Hi dev-platform@,
>
> So, yesterday was working on a bug (bug 1362991, if you're curious) when
> I decided to do some spring cleanup and pass some non-optional argument
> as a reference instead of as a pointer.
>
> I got the cleanup patch rejected, because it went against the prevailing
> style of the codebase, and I was told that moving to references required
> a discussion in dev-platform, resulting in something more explicit in
> the style guide.
>
> So, I'll revert that patch for now, but I'm sending this mail to
> kickstart that discussion :)
>
> TL;DR: I think references are useful. We have encoded nullability of
> arguments and return values implicitly or explicitly in different ways:
> assertions inside of the function, naming conventions...
>
> I think references help to encode that a bit more in the type system,
> and help reasoning about the code without having to look at the
> implementation of the function you're calling into, or without having to
> rely on the callers to know that you expect a non-null argument.
>
> 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.
>
> Thanks for reading.
>
>  -- Emilio
>
> _______________________________________________
> dev-platform mailing list
> dev-platform@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-platform
>
>
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to