<div class="gmail_quote">On Thu, Jul 30, 2009 at 10:14 AM, Laurens Van Houtven <span dir="ltr">&lt;<a href="mailto:lvh@laurensvh.be">lvh@laurensvh.be</a>&gt;</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&#39;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&#39;t do that -- even<br>
if you&#39;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&#39;t *really* make immutable python objects, but<br>

they&#39;d be immutable in the sense that:<br>
<br>
sentence.latitude, sentence.longitude = Coordinate(50.49),  Coordinate(-3.34)<br>
<br>
... wouldn&#39;t work (specifically, latitude and longitude aren&#39;t really<br>
attributes of the class, but things you can get with my __getattr__ --<br>
and I don&#39;t set __setattr__, so you&#39;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&#39;t really care, because I hope I&#39;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&#39;s important to have a return-a-modified-copy API if mutation is actually disallowed.  For example, point.moveTo(50.49, -3.34) =&gt; a new Point.<br>
<br></div></div>