From: georgesawyer Date: 2005-01-09T10:46:30+09:00 Subject: Re: Ruby design question: lazy construction of object graph containi "itsme213" Jan 6, 2005 at 06:59 AM wrote: >Consider [a kind of] Ruby object graph being constructed .... The >graph gets built monotonically; i.e., all slots are either >uninitialized, or initialized, but not modified once initialized. I recommend Ruby constants. >I would like to force resolution of (selected or all) unresolved >references, either: >a) at a time of my choosing (raising exceptions if needed), or >b) incrementally whenever a given reference becomes resolvable, or >c) when something is done with that reference, i.e. some method > [is] invoked on it .... >I can assume that 'nil' is a distinguished sentinel value >indicating an uninitialized slot, ... but I don't know how much >that will help .... [E]ven nil has a whole heap of defined >methods. I can change any of the assignment methods as needed. Or perhaps not nil, as below. >What would be a good way to accomplish this? I was thinking I >could create a trail of proc-like things representing bits of >suspended computation (a bit like 'futures') Cool! >but can't really figure ... if it would be a good approach. Do >continuations offer some magic that would help? The following dynamic capability can support, I believe, your graph: =>class A ;end =>A::B =5 =>print A.const_defined?( :B) ;A.const_defined? :C truefalse =>class A ;remove_const( :B) ;end =>A.const_defined? :B false The class Module is the parent class of the class Class. Module defines these methods.