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

Discussion in 'Ruby' started by Daniel Berger, Oct 27, 2004.

  1. 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
     
    Daniel Berger, Oct 27, 2004
    #1
    1. Advertising

  2. Daniel Berger

    ts Guest

    >>>>> "D" == Daniel Berger <> 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
     
    ts, Oct 28, 2004
    #2
    1. Advertising

  3. ts <> wrote in message news:<>...
    > >>>>> "D" == Daniel Berger <> 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, Oct 28, 2004
    #3
  4. wrote in message news:<>...
    > 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
     
    Daniel Berger, Oct 30, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,031
    Smokey Grindel
    Dec 2, 2006
  2. Val
    Replies:
    2
    Views:
    371
  3. Robert P. J. Day

    how to check if a module is importable?

    Robert P. J. Day, Jan 20, 2010, in forum: Python
    Replies:
    2
    Views:
    247
    Robert P. J. Day
    Jan 20, 2010
  4. Kevin Howe

    Ruby DL::Importable struct issue

    Kevin Howe, Nov 23, 2004, in forum: Ruby
    Replies:
    7
    Views:
    167
    Kevin Howe
    Nov 25, 2004
  5. Terry Reedy

    Building importable _tkinter on Windows

    Terry Reedy, Mar 10, 2013, in forum: Python
    Replies:
    0
    Views:
    155
    Terry Reedy
    Mar 10, 2013
Loading...

Share This Page