https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112012-08-04T04:39:13ZRuby Issue Tracking SystemRuby master - Feature #6828: Constancy of Constantshttps://redmine.ruby-lang.org/issues/6828?journal_id=286342012-08-04T04:39:13Zalexeymuranov (Alexey Muranov)
<ul></ul><p>Did you mean <a class="issue tracker-2 status-2 priority-4 priority-default" title="Feature: `module A::B; end` is not equivalent to `module A; module B; end; end` with respect to constant l... (Assigned)" href="https://redmine.ruby-lang.org/issues/6810">#6810</a> by any chance?</p> Ruby master - Feature #6828: Constancy of Constantshttps://redmine.ruby-lang.org/issues/6828?journal_id=288912012-08-15T21:00:47ZMasterLambaster (Alex N)masterlambaster@gmail.com
<ul></ul><p>=begin<br>
I think it might be implemented but i'd rather not do that.<br>
The reason why its not equivalent is because the first statement means:<br>
((|Define module Baz under Foo::Bar|))<br>
The second one means:<br>
((|Define module Foo, define module Bar under Foo, define module Baz under Foo::Bar|))</p>
<p>So it's not an issue in a common sense. In first case you try to create module under namespace that does not exist, that leads to error, and I think that's as it should be. In the second case you you explicitly define all module structure.</p>
<p>=end</p> Ruby master - Feature #6828: Constancy of Constantshttps://redmine.ruby-lang.org/issues/6828?journal_id=288952012-08-15T23:49:34Ztrans (Thomas Sawyer)
<ul></ul><p>=begin<br>
It's not that. It's the constant lookup:</p>
<p>module Foo<br>
X = 1<br>
module Bar<br>
p X #=> 1<br>
end<br>
end</p>
<p>module Foo::Bar<br>
p X #=> NameError<br>
end</p>
<p>Personally I would prefer undefined namespaces be automatically instantiated as modules. If that was not the intent another error will pick it up quickly enough anyway. But that's not the main issue --the constant lookup is the important thing.</p>
<p>=end</p> Ruby master - Feature #6828: Constancy of Constantshttps://redmine.ruby-lang.org/issues/6828?journal_id=288962012-08-15T23:51:49Ztrans (Thomas Sawyer)
<ul></ul><p><a class="user active user-mention" href="https://redmine.ruby-lang.org/users/3468">@alexeymuranov (Alexey Muranov)</a> Yes, <a class="issue tracker-2 status-2 priority-4 priority-default" title="Feature: `module A::B; end` is not equivalent to `module A; module B; end; end` with respect to constant l... (Assigned)" href="https://redmine.ruby-lang.org/issues/6810">#6810</a> that's the one. Probably why I did not find it --it listed as a Bug. I would agree, actually.</p> Ruby master - Feature #6828: Constancy of Constantshttps://redmine.ruby-lang.org/issues/6828?journal_id=289002012-08-16T03:01:01Zdrbrain (Eric Hodel)drbrain@segment7.net
<ul><li><strong>Target version</strong> changed from <i>2.0.0</i> to <i>3.0</i></li></ul><p>=begin<br>
I rely on this feature of constant lookup.</p>
<p>It allows me to define (({File})) and other top-level constants in my library's namespace, but still use the top-level (({File})) without littering (({::})) everywhere in my library. It also helps me reduce confusion of contributors. They don't have to wonder if "File" is (({::File})) or (({MyLibrary::File})), it's always the top-level constant unless listed under my namespace. (In particular, RDoc has (({RDoc::Encoding})) and would break with this change.)</p>
<p>Changing the constant lookup will break ruby libraries that use this feature, so I have changed the target to 3.0<br>
=end</p> Ruby master - Feature #6828: Constancy of Constantshttps://redmine.ruby-lang.org/issues/6828?journal_id=890862020-12-10T08:47:35Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Target version</strong> deleted (<del><i>3.0</i></del>)</li></ul>