Version française
Home     About     Download     Resources     Contact us    
Browse thread
Type problem... possible design problem
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: chris.danx <chris.danx@n...>
Subject: Re: [Caml-list] Type problem... possible design problem
Jon Harrop wrote:
> On Saturday 18 December 2004 00:42, chris.danx wrote:
> 
>>What is the solution to the following problem?  There are two types of
>>object in a scene graph, those that may have children and those may not.
>>     A leaf may not have children.
> 
> 
> Could you redefine this as "There is one type of node in a scenegraph, which 
> has an arbitrary number of children"? Leaf nodes are then nodes with zero 
> children.

I could.  The problem was that I wanted to enforce that leaf nodes are 
the only renderable objects and internal nodes are for grouping and 
state changes - lights, transformations, etc.


>>I've not programmed in O'Caml for a while and am not yet fully
>>comfortable with ocamls object system anyway, so I may be being silly.
>>Can anyone shed some light on a solution to this?
> 
> Why are you using OO? Can you do what you want with modules and variant types 
> more easily?

I was using OO because I want to extend the nodes available.  I suppose 
I can use closures.

My concern with variants is sharing subgraphs in graphs, will they be 
shared or copied?