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

D

Daniel Berger

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
 
T

ts

D> module Foo
D> class Bar
D> 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
 
D

Daniel Berger

ts said:
D> module Foo
D> class Bar
D> 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
 
D

Daniel Berger

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top