<div class="gmail_quote">On Thu, Jul 30, 2009 at 10:14 AM, Laurens Van Houtven <span dir="ltr"><<a href="mailto:lvh@laurensvh.be">lvh@laurensvh.be</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Oh, by the way: would you guys expect NMEASentences to be immutable objects?<br>
</blockquote><div><br>Yes, but by convention, not necessarily by enforcement. The really important thing is that the framework should not share or mutate NMEASentence objects internally.<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I suppose it makes sense, but maybe I've been thinking too much<br>
Haskell recently. After all, an NMEASentence is an alternative way of<br>
describing a past event (namely, something that a GPS told you).<br>
Changing it would be like changing history, you can't do that -- even<br>
if you're really replacing it with the same data but encoded<br>
differently.<br></blockquote><div> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I know that you can't *really* make immutable python objects, but<br>
they'd be immutable in the sense that:<br>
<br>
sentence.latitude, sentence.longitude = Coordinate(50.49), Coordinate(-3.34)<br>
<br>
... wouldn't work (specifically, latitude and longitude aren't really<br>
attributes of the class, but things you can get with my __getattr__ --<br>
and I don't set __setattr__, so you'd need to know the guts of the<br>
class, which currently are public but I might make private before the<br>
code review).<br>
<div><div></div><div class="h5"></div></div></blockquote><div><br>Ugh. __getattr__, really? Is that necessary? It would be nice not to rely on this kind of magic.<br><br>For NMEASentence, I don't really care, because I hope I'm never going to write an application that actually deals with one of those. But if you have a Point object or something like that, then I think it's important to have a return-a-modified-copy API if mutation is actually disallowed. For example, point.moveTo(50.49, -3.34) => a new Point.<br>
<br></div></div>