# Warnings, exceptions, and constant modifications, redux

**URL:** <https://www.ruby-forum.com/t/warnings-exceptions-and-constant-modifications-redux/121869>\
**Category:** Ruby\
**Created:** [December 2, 2007, 5:35am UTC](https://www.ruby-forum.com/t/warnings-exceptions-and-constant-modifications-redux/121869 "2007-12-02T05:35:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dumaiu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@Dumaiu](https://www.ruby-forum.com/u/Dumaiu)\
**Post date:** [December 2, 2007, 5:35am UTC](https://www.ruby-forum.com/t/warnings-exceptions-and-constant-modifications-redux/121869/1 "2007-12-02T05:35:37Z")

</div>

Hello, all. With your permission I’d like to resurrect a topic that  
seems to have died in 2002. At least, this is the most info I’ve  
found. The question was, Why does modification of a constant produce  
a warning and not an exception? Matz’s answer, ruby-talk 48168, was  
as follows (angle brackets added):

> M-x eval-ruby-expression  
> Eval: Foo = 42  
> bang!
> 
> |2. is there a beast called a ‘global constant’? i tried defining $Foo  
> |and ruby allows me to rebind $Foo later.
> 
> No. $Foo is a plain global variable.
> 
> ```
> matz.
> 
> ```

Unfortunately, I’m not familiar with ‘eval-ruby-expression’, which  
looks like some sort of Emacs command. So I still consider it a  
fairly serious problem that modification of a constant produces  
nothing more serious than a warning, which is useless without human  
supervision. Especially because, even if an exception were raised  
instead, a bypass system is still so easy to arrange:

class Module  
def const\_set!( name, val )  
remove\_const(name) if const\_defined?(name)  
const\_set( name, val )  
end  
end

Is this ‘embedded editor’ problem the same as it was five years ago?  
Could somebody who _does_ know about embedded editors explain what it  
is about them that makes constants so hard to deal with? Ruby-talk  
48271, from the same thread:

> for example, eval-current-buffer may cause trouble if it redefines  
> contants.
> 
> ```
> matz.
> 
> ```

How do embedded editors normally handle exceptions?  
Thanks to David G. for creating the prior thread.

- Jonathan
