From: Nicholas Van Weerdenburg Date: 2004-08-03T14:42:58+09:00 Subject: Re: convention for deep classes/modules What is the reason they are not interchangeable? Thanks, Nick David A. Black wrote: >Hi -- > >On Mon, 2 Aug 2004, David Garamond wrote: > > > >>Is the more common convention: >> >> module Foo >> module Bar >> class Baz >> ... >> end >> end >> end >> >>or this: >> >> module Foo; end >> module Foo::Bar; end >> class Foo::Bar::Baz >> ... >> end >> >>I prefer the second because I dislike having to indent several times. >> >> > >Keep in mind that they're not interchangeable: > > module A > X = 1 > class B > puts X # A::X is visible here > end > end > > module C > X = 1 > end > > class C::B > puts X # C::X is not visible here > end > > > > >>Also, is there a possibility that Ruby will "autovivify": >> >> module Foo::Bar::Baz >> class Foo::Bar::Baz2 >> >>so it creates modules Foo, Bar, Baz automatically? >> >> > >No, because you can't tell whether the lefthand ones (Foo and Bar in >your example) are modules or classes. > > >David > > >