[ruby-talk:02508] Re: Variable scope -does this make sense?

From: Quinn Dunkan <quinn@...>
Date: 2000-04-18 18:28:25 UTC
List: ruby-talk #2508
>      Global variables are available throughout an
>      application. Reference to an uninitialized global variable
>      returns nil.
> 
>      Instance variables are available throughout a class
>      body. Reference to an uninitialized instance variable returns
>      nil.

You mention that an uninitialized {global,instance} variable evaluates to nil
(I'd say "evaluates to" rather than "reference to returns"), and so for
symmetry you should probably mention that evaluating an uninitialized local
variable throws a NameError.

> Normally I'd agree, but this section is entitled "Scope of Variables", 
> so I was trying hard (and failing later on) not to define scope in
> terms of scope.

Then you should probably define scope *before* you go on to describe ruby's
(somewhat complicated) idea of scope.  Scope is a simple concept that turns
out to have deep ramifications, but if you define the word first then you can
use the standard terminology to describe the ramifications.

In This Thread