[Edu-sig] Properties use case

Scott David Daniels Scott.Daniels at Acm.Org
Sat Mar 18 01:23:08 CET 2006


ajsiegel at optonline.net wrote:

> Instead of having my geometric objects of the complex plane *be* complex numbes, 
> there is certainly the solution of having a complex number as an attribute of these objects - 
> and then I can take more your approach, and at the speed of C, since I would then 
> be using the built-in for arithmettic operations.
> 
> There remained something unsatisfying to me about that approach.  
> 
> Until something blows up about my current approach, I am quite happy with it. 

The thing that typically blows up is when you are (for example)
computing with a complex number that is changed halfway through
the computation by another thread (say a mouse drag).  The square
root winds up being neither the square root of the original number
nor of the new changed number.  Further, it becomes dicey to
try to prove that your square root function will always terminate
(a step size from one that is guaranteed to settle might be a
disaster at the new-improved value.

So, that's why CS people like immutable primitive types.

-- Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Edu-sig mailing list