> -----Original Message-----
> From: Paul Brannan [mailto:pbrannan / atdesk.com]
> Sent: Tuesday, September 18, 2001 6:57 PM
> To: ruby-talk ML
> Subject: [ruby-talk:21328] const-correctness
>
>
> If I do this:
>
>   X = 'this is a test'         # this is a const reference to an object
>   x = X                        # this is a non-const reference to the same
>   x << '... testing ...'       # let's try and modify a "const" object
>   p x
>   p X
>
> Then when I run ruby -w, I get:
>
>   "this is a test... testing ..."
>   "this is a test... testing ..."
>
> 1) Should Ruby issue a warning about modifiny a constant object?
Maybe, but 2) seems more reasonable

> 2) Should I have frozen X explicitly to avoid this?
yeah ... constants provide constant references, not values

> 3) Could this lead to hidden bugs in Ruby code?
Maybe ... though such constant usage reminds me of using explicitly smth
like const_cast in C++ and then wondering why compiler never warned you
about possible errors.

Aristarkh A Zagorodnikov, Lead Programmer, W3D Group
http://www.w3d.ru /// xm / w3d.ru /// ICQ UIN 36987938