From: Gavin Sinclair Date: 2003-09-12T09:31:37+09:00 Subject: Re: Global object instance? > I'm thinking, why do we have globals at all? I wonder if it would be > possible to just corral all the "global" stuff (methods, variables, > etc.) and just assign all that to a top-level object instance and use > that object as the default "global context?" > > I'm thinking: no fixed global context at all. Just an object instance > that acts as the global context. > > [.................] > > Kind of a nutty idea, maybe? > > Sean O'Dell Kinda nutty, yeah :) The example you presented (and others of its ilk) are easily implemented in ruby with no inelegance. Besides, it's bad form to be modifying the behavious of global functions. The point is, really, that Kernel contains a bunch of useful methods, as well as some that are, frankly, a relic of the past (open, sub). They manage no state; they just do stuff. It's a convenient and harmless way of adding regular features to the language (e.g. loop, puts, throw, catch) while keeping the core language simple, as well as exposing necessary "kernel" services (local_variables, callcc, syscall). Therefore, there's no need to feel like "something ought to be done" about Kernel. It's not on par with global variables. But what _did_ catch my attention with your post was the idea that global _variables_ might be better wrapped in a class called Global. But it wouldn't make enough purity difference to justify the hassle, IMO. Gavin