Module This::Encompassing::That

Not sure what 'this modification' is, because the above works under 1.6.8
already as far as I can tell.

Thanks to Babelfish I get from [ruby-dev:18184]:

"Because Nakata's method very
mounting is simple, the air does whether this way it is not to be good
being.
Lottery"

So that's clear then :slight_smile:

Regards,

Brian.

···

On Thu, Feb 20, 2003 at 10:00:20AM +0900, nobu.nokada@softhome.net wrote:

Brian Candler wrote:
> Would it not be clearer to eliminate the duplication of all those prefixes
> though? e.g.
>
> module Utils
> autoload :ClassA, 'utils/classa'
> autoload :ClassB, 'utils/classb'
> autoload :ClassC, 'utils/classc'
> autoload :ClassD, 'utils/classd'
> end

This modification had been discussed in ruby-dev, from
[ruby-dev:16165] and [ruby-dev:18103]. Perhaps, the final
patch is [ruby-dev:18184].

Hi,

Would it not be clearer to eliminate the duplication of all those prefixes
though? e.g.

module Utils
autoload :ClassA, ‘utils/classa’
autoload :ClassB, ‘utils/classb’
autoload :ClassC, ‘utils/classc’
autoload :ClassD, ‘utils/classd’
end

This modification had been discussed in ruby-dev, from
[ruby-dev:16165] and [ruby-dev:18103]. Perhaps, the final
patch is [ruby-dev:18184].

Not sure what ‘this modification’ is, because the above works under 1.6.8
already as far as I can tell.

Autoload affects only top level constants, even in module
definition. I suspected that you wanted the files to get
loaded by access to constants under Utils. Excuse my
misunderstanding.

Thanks to Babelfish I get from [ruby-dev:18184]:

“Because Nakata’s method very
mounting is simple, the air does whether this way it is not to be good
being.
Lottery”

Hmmm,

"Because Nakada’s implementation is simple, it looks good
enough for me.

Okuji"

···

At Thu, 20 Feb 2003 20:02:07 +0900, Brian Candler wrote:

–
Nobu Nakada

No, it is me who still misunderstands :slight_smile: I did:

  a = Utils::ClassA.new

and it worked. Attached is a full example, which gives:

$ ruby main.rb
I am foo
99
I am bar
123
$

Regards,

Brian.

main.rb (279 Bytes)

classa.rb (53 Bytes)

constb.rb (12 Bytes)

classc.rb (53 Bytes)

constd.rb (13 Bytes)

···

On Thu, Feb 20, 2003 at 09:14:31PM +0900, nobu.nokada@softhome.net wrote:

Autoload affects only top level constants, even in module
definition. I suspected that you wanted the files to get
loaded by access to constants under Utils. Excuse my
misunderstanding.

No, it is me who still misunderstands :slight_smile: I did:

Try this, to see the difference

module Utils
autoload :ClassA, ‘classa’
class ClassB
end
end

p Utils::ClassA.new
p Utils::ClassB.new
p Utils.constants

Guy Decoux

And this works too:

module Foo
autoload :ClassA, ‘classa’
def Foo.test
a = ClassA.new
puts a.foo
puts a.class
end
end

Foo.test

Ah, but this has generated ClassA and not Foo::ClassA. I guess that’s the
problem.

B.

···

On Thu, Feb 20, 2003 at 11:06:55PM +0900, Brian Candler wrote:

On Thu, Feb 20, 2003 at 09:14:31PM +0900, nobu.nokada@softhome.net wrote:

Autoload affects only top level constants, even in module
definition. I suspected that you wanted the files to get
loaded by access to constants under Utils. Excuse my
misunderstanding.

No, it is me who still misunderstands :slight_smile: I did:

a = Utils::ClassA.new

and it worked.