POV-Ray : Newsgroups : povray.off-topic : Binary trees, branches and leaves : Re: Binary trees, branches and leaves Server Time
4 Sep 2024 09:20:56 EDT (-0400)
  Re: Binary trees, branches and leaves  
From: Orchid XP v8
Date: 4 Mar 2010 13:15:41
Message: <4b8ff8cd$1@news.povray.org>
>> More succinctly: In OO, trees are usually mutable. In Haskell, trees 
>> are usually immutable.
> 
> Not that so much as identity is an important aspect of OO, where it 
> isn't in functional programming. Two different objects with exactly the 
> same value are nevertheless not interchangable.

The OO definition of "object": "An object has identity, state and 
behaviour."

Of course, objects have identity *because* they're mutable. For 
immutable objects, identity is irrelevant. (Even in an OO system it's 
unimportant, regardless of whether you can measure it or not.)

Since most Haskell things are immutable, identity isn't much of an issue.

(The other thing, of course, is the whole "behaviour" part. Objects 
aren't passive data structures, but active mini-programs. This makes 
identity kinda important!)

>> A bigger part of it is that, while essentially Haskell has pointers, 
>> null pointers are explicitly prohibited.
> 
> You could always have Branch hold a couple of Maybe Leaf's.

Sure. But it's simpler (and probably more performant) to just define 
multiple node types. ;-)

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.