Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   Why can I extend, but not include, DL::Importable? (http://www.velocityreviews.com/forums/t817601-why-can-i-extend-but-not-include-dl-importable.html)

Daniel Berger 10-27-2004 08:41 PM

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

ts 10-28-2004 09:59 AM

Re: Why can I extend, but not include, DL::Importable?
 
>>>>> "D" == Daniel Berger <djberg96@hotmail.com> writes:

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



Daniel Berger 10-28-2004 05:46 PM

Re: Why can I extend, but not include, DL::Importable?
 
ts <decoux@moulon.inra.fr> wrote in message news:<200410280959.i9S9x3U06031@moulon.inra.fr>...
> >>>>> "D" == Daniel Berger <djberg96@hotmail.com> writes:

>
> 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

Daniel Berger 10-30-2004 03:34 AM

Re: Why can I extend, but not include, DL::Importable?
 
nobu.nokada@softhome.net wrote in message news:<200410290219.i9T2JmcZ020075@sharui.nakada.ni regi.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


All times are GMT. The time now is 04:33 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.