Warnings, exceptions, and constant modifications, redux.

Discussion in 'Ruby' started by Dumaiu, Dec 2, 2007.

  1. Dumaiu

    Dumaiu Guest

    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):

    > Hi,
    >
    > In message "warning modifying constant & 'global constant'"
    > on 02/08/26, David Garamond <davegaramond / icqmail.com> writes:
    >
    > |1. if someone attempts to modify a constant, why does ruby choose to
    > |emit a warning instead of a fatal error?
    >
    > If it is a fatal error, something like Ruby embedded editor will meet
    > serious problems, e.g.
    >
    > M-x eval-ruby-expression
    > Eval: Foo = 42<ret>
    > 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:

    > Hi,
    >
    > In message "Re: warning modifying constant & 'global constant'"
    > on 02/08/27, Paul Brannan <pbrannan / atdesk.com> writes:
    >
    > |> M-x eval-ruby-expression
    > |> Eval: Foo = 42<ret>
    > |> bang!
    > |
    > |What problems would there be with making it an exception?
    >
    > for example, eval-current-buffer may cause trouble if it redefines
    > contants.
    >
    > matz.


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



    - Jonathan
    Dumaiu, Dec 2, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pete Davis

    Control modifications and AutoPostBack

    Pete Davis, Jan 17, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    395
    |{evin
    Jan 17, 2004
  2. =?Utf-8?B?U2FjaGk=?=

    Menu modifications...query!

    =?Utf-8?B?U2FjaGk=?=, Jun 23, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    297
    =?Utf-8?B?U2FjaGk=?=
    Jun 23, 2004
  3. Andrea Hahn
    Replies:
    0
    Views:
    437
    Andrea Hahn
    Aug 18, 2003
  4. Replies:
    1
    Views:
    481
    alessandro basili
    Sep 21, 2006
  5. Ted Sung
    Replies:
    1
    Views:
    299
    Sherm Pendley
    Aug 30, 2004
Loading...

Share This Page