On 5/27/14 11:04 AM, Simon Sapin wrote:
On 27/05/2014 18:14, Patrick Walton wrote:
On 5/26/14 3:11 PM, Simon Sapin wrote:
I’m fine with that, but I’m more interested in the signature than the
naming. That is, which of these (or others) to have, for each private
field?

fn(&self) -> T
fn(&mut self, T)
fn(&'a mut self) -> &'a mut T

Hmm. My gut tells me the first and the third. I think we need at least
two, to handle immutable receivers and mutable receivers. I don't see
any pressing need for a `.set()`-style method, as it only takes one
extra character for the caller to use the mut-ref method as a set method
(`*`) and that's fewer characters than `set` would be.

I just realized that the third only works when there is a corresponding
field stored as is. Anything "computed" (e.g. physical coordinate
accessors on a logical point) would have have the second signature.

Yes, that's true. I guess we need the second signature, at least sometimes.

Also, maybe there is no need to check the writing mode when accessing
"non computed" fields directly, which could just be made public to avoid
the ugly accessor?

Sure.

Patrick
_______________________________________________
dev-servo mailing list
dev-servo@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-servo

Reply via email to