Hi --

On Tue, 18 Feb 2003, Gavin Sinclair wrote:

> I like the idea of autovivification within certain rules.
>
> class A
> end
>
> module A::B
> end                      # error

In this case, it's not autoviv., because A already exists, so it's an
explicit creation of B.

But still, why would the above be an error?  Why not equivalent to:

  class A
    module B
    end
  end

> The rule is that the Xi in
>   module X1::X2::...::Xn
> must all be either:
>  - modules (not classes); or

Why not classes?

>  - non-existent (so an empty module can be created)

But it could be an empty Class -- meaning, if X2 (or whatever)
doesn't exist yet, there's no reason to favor the idea that
it's supposed to be a Module rather than a Class.  There's just
no way to know.

A case that's somewhat analogous to this, but without the ambiguity,
is:

  mkdir -p a/b/c

which creates all three directories if they don't exist.  In that
case, there's no ambiguity; there's nothing else they can be, because
mkdir only does one thing in the first place.  But the :: path
notation in module A::B::C does not have that kind of single meaning.
Of course, C has to be a module, and there are things that A and B
*can't* be, but there's more than one thing each of them can be.


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav