Why can I extend, but not include, DL::Importable?

Hi all,

Windows XP Pro
Ruby 1.8.2 (Installer)

I'm just curious why I can't include DL::Importable in a class.

require "dl/import"

# This works
module Foo
   extend DL::Importable
   dlload("advapi32")
   
   extern("HANDLE OpenEventLog(char*,char*)")
   extern("BOOL CloseEventLog(HANDLE)")
end

# This doesn't
module Foo
   class Bar
      include DL::Importable # also tried 'extend' for kicks
      dlload("advapi32")

      extern("HANDLE OpenEventLog(char*,char*)")
      extern("BOOL CloseEventLog(HANDLE)")
   end
end

I feel I'm missing something obvious here, but I don't know what it
is. Insight appreciated. Thanks.

Dan

module Foo
   class Bar
      include DL::Importable # also tried 'extend' for kicks

Bar is a class

svg% ruby -e 'module A def aa() end; module_function :aa end'
svg%

svg% ruby -e 'class A; def aa() end; module_function :aa end'
-e:1: undefined method `module_function' for A:Class (NoMethodError)
svg%

Guy Decoux

ts <decoux@moulon.inra.fr> wrote in message news:<200410280959.i9S9x3U06031@moulon.inra.fr>...

> module Foo
> class Bar
> include DL::Importable # also tried 'extend' for kicks

Bar is a class

svg% ruby -e 'module A def aa() end; module_function :aa end'
svg%

svg% ruby -e 'class A; def aa() end; module_function :aa end'
-e:1: undefined method `module_function' for A:Class (NoMethodError)
svg%

Guy Decoux

So, DL automatically tries to convert externs into module functions?
Wouldn't it be better if I could decide?

Dan

Hi,

At Fri, 29 Oct 2004 02:48:59 +0900,
Daniel Berger wrote in [ruby-talk:118145]:

So, DL automatically tries to convert externs into module functions?
Wouldn't it be better if I could decide?

What will you decide, whether instance methods or module
functions? C functions don't have self so they cannot be
instance methods.

···

--
Nobu Nakada

nobu.nokada@softhome.net wrote in message news:<200410290219.i9T2JmcZ020075@sharui.nakada.niregi.kanuma.tochigi.jp>...

Hi,

At Fri, 29 Oct 2004 02:48:59 +0900,
Daniel Berger wrote in [ruby-talk:118145]:
> So, DL automatically tries to convert externs into module functions?
> Wouldn't it be better if I could decide?

What will you decide, whether instance methods or module
functions? C functions don't have self so they cannot be
instance methods.

Class methods.

- Dan