----- Original Message ----- 
From: "Jim Freeze" <jim / freeze.org>
To: "ruby-talk ML" <ruby-talk / ruby-lang.org>
Sent: Thursday, May 08, 2003 5:31 PM
Subject: Re: Can a global be a constant?


> Actually, what I am thinking about is how
> to declare application state. 
> For example, if an app is run with a --verbose
> or a --debug option, I want every object that
> I instantiate to respond appropriately, including
> threads and forks.
> 
> In addition, I think it is in bad taste to use
> global variables. So I have been playing around
> with constants and such. (I was comparing scope
> between globals and constants when I discovered
> this.)
> 
> So, I either have to relinquish my hesitation to use
> global variables, or find a suitable alternative.
> 
> Do you have any suggestions?

Well, I'm not sure of all your needs.

I sometimes use instance variables as globals at the 
top level... they act global since they go into Object's 
class, and if/when I wrap stuff in a class, I don't 
have to change them all.

I've also noticed that we don't mind that a class is
global, if you know what I mean. You could always
encapsulate all your global data in a class called
State (with class variables and accessors for them).

Then you could pretend to be doing something clever
when actually you're just using one big fancy global
variable. :)

Hal