As I pointed out, Ruby already handles unitialized variables as a
separate case.  Ruby makes a distinction between uninitialized and
initialized variables.  Just because a variable happens to be set to
nil doesn't make that variable uninitialized.

On 5/8/05, John Carter <john.carter / tait.co.nz> wrote:
> On Mon, 9 May 2005, David A. Black wrote:
> 
> > Or do you mean instance variables and global variables, which evaluate
> > to nil by default prior to being initialized?
> 
> Well, that one is clearly a case of nil === "uninitialized"
> 
> > Do you mean there's a convention of initializing variables to nil, prior
> > to (say) their use as iterator variables or counters?  If so, that's
> > very different from an uninitialized variable.
> 
> Let me bounce that question back to you...
> 
> When _you_ personally do that, what do you mean? Do you mean
> "This is ruby's, umm, curious way of declaring local variables, namely by
> initializing them to something. I am initializing this local variable to
> nil. By this I, David A. Black mean (tick one)
> 
>    a) This local variable is uninitialized and I wish ruby to throw an
>       error if I invoke a method on it before initializing it to
>       something meaningful.
> 
>    b) This local variable holds "no thing", and doing nothing and
>       returning nothing would be an appropriate action on invoking a
>       method on it.
> 
> Myself, John Carter, would like on some occasions to tick one and on
> other occasions to tick the other. Currently, whatever I mean, the
> effect is a).
> 
> I can, and am currently writing a Nothing class that allows me to
> assign NOTHING, the sole instance of my Nothing class to a local
> variable in the case you describe.
> 
> But I'm running up against the gotcha that deep in "ruby.h" is a macro
> RTEST.
> 
> Rubies interpretor, eval.c uses RTEST in many places. In "if",
> in "unless", in "while", in....
> 
> RTEST is 0 (false) in the C speaking world of eval if an ruby
> expression evaluates to false or nil.
> 
> For my Nothing class to really work well, I would need RTEST to
> evaluate to 0 for nil,false and NOTHING.
> 
> All Work arounds and suggestions welcome...
> 
> 
> John Carter                             Phone : (64)(3) 358 6639
> Tait Electronics                        Fax   : (64)(3) 359 4632
> PO Box 1645 Christchurch                Email : john.carter / tait.co.nz
> New Zealand
> 
> Surprisingly enough, this email does not originate from a beetle.
> 
> 


-- 
Bill Atkins