[#1026] Is this a bug? — Dave Thomas <Dave@...>

18 messages 2000/01/03

[#1084] Infinite loop — Dave Thomas <Dave@...>

17 messages 2000/01/11

[#1104] The value of while... — Dave Thomas <Dave@...>

24 messages 2000/01/11

[ruby-talk:01095] Re: YADQ (Yet Another Dumb Question)

From: Dave Thomas <Dave@...>
Date: 2000-01-11 15:05:50 UTC
List: ruby-talk #1095
matz@netlab.co.jp (Yukihiro Matsumoto) writes:

> It used to give a error before.  But it was not good for
> 
>   * interactive programming, e.g.

>   * reloading files, evaluate program fragment by eval.


I think the concept of a constant is an important one--constants are
used to hold values that are significant to some piece of
code. Allowing them to be silently changed undermines our confidence
in that piece of code.

Personally, I feel the damage done by an altered constant is far more
severe than the inconvenience of the above two cases.

So... how about a compromise? We could have a global method, say
'unset <list>', that unsets all the variables in it's list. That way,
if you want to redefine a constant, you could:

  module Math
    unset PI
    PI = 2
  end

  area = Math::PI * r * r

That way, you make it explicit that you _meant_ to make the change.

Regards

Dave

 

In This Thread