terminology: "class method" = "singleton method"?

Discussion in 'Ruby' started by petermichaux@yahoo.com, Nov 7, 2005.

  1. Guest

    I've seen references to singleton methods and class methods. They seem
    to mean the same thing. True?

    Thanks,
    Peter
     
    , Nov 7, 2005
    #1
    1. Advertising

  2. wrote:
    > I've seen references to singleton methods and class methods. They seem
    > to mean the same thing. True?


    Not entirely the same: a class method is a singleton method but a singleton
    method is not always a class method in the traditional sense :)

    A singleton method is just a method defined on a single object rather than
    an entire class of objects. Because it so happens that classes are objects
    too (class Class), methods can be defined on a Class object and since those
    methods are invoked on the Class object itself they look like 'class methods'.

    The syntax 'def self.class_method()' is in fact the exact same as the singleton
    method syntax:

    class Foo
    end

    f = Foo.new

    def f.foo()
    puts 'foo!'
    end

    f.foo

    With class methods the receiving object is 'self', the class itself, rather than
    some more conventional object like 'f' in the above example.

    It might be useful to think of class instance methods (or class methods for
    short) using this mental model:

    f = Foo.new; f.instance_method

    Versus

    Foo = Class.new; Foo.class_method

    > Thanks,
    > Peter


    E
     
    Eero Saynatkari, Nov 7, 2005
    #2
    1. Advertising

  3. Trans Guest

    Speaking of terminology and singleton class, I came across a new word
    today, a word I had thought I knew but did'nt truly. And it fits the
    definition of these classes perfectly. We all enjoy eigenclass, but
    quite clearly these classes are *adhoc*.

    T.
     
    Trans, Nov 7, 2005
    #3
  4. Selon Trans <>:

    > Speaking of terminology and singleton class, I came across a new word
    > today, a word I had thought I knew but did'nt truly. And it fits the
    > definition of these classes perfectly. We all enjoy eigenclass, but
    > quite clearly these classes are *adhoc*.
    >


    Why would one want haddock classes when we have chunky bacon? ;)
    --
    Christophe Grandsire.

    http://rainbow.conlang.free.fr

    It takes a straight mind to create a twisted conlang.
     
    Christophe Grandsire, Nov 7, 2005
    #4
  5. Ad Hoc Class [was Re: terminology: "class method" = "singleton method"?]

    On Nov 6, 2005, at 9:42 PM, Trans wrote:
    > Speaking of terminology and singleton class, I came across a new word
    > today, a word I had thought I knew but did'nt truly. And it fits the
    > definition of these classes perfectly. We all enjoy eigenclass, but
    > quite clearly these classes are *adhoc*.


    To be pedantic, it's "ad hoc", not "adhoc".

    But...this is by far my favorite term for the class. :)
    It describes that it's created on the fly.
    It rather describes that it's specific to a certain item.
    It has no geeky confusion of 'eigenclass'.
    It has no conflict with existing programming terms like 'singleton'.

    http://www.google.com/search?q=define:ad hoc
     
    Gavin Kistner, Nov 7, 2005
    #5
  6. Re: Ad Hoc Class [was Re: terminology: "class method" = "singleton method"?]

    Gavin Kistner <> wrote:

    > It has no geeky confusion of 'eigenclass'.


    'Tis a sad day when *programmers* shy away from geekiness :)

    martin
     
    Martin DeMello, Nov 7, 2005
    #6
  7. Trans Guest

    Re: Ad Hoc Class [was Re: terminology: "class method" = "singleton method"?]

    Actally it's just old-school geek --it's Latin ;-)

    T.
     
    Trans, Nov 7, 2005
    #7
    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. anon
    Replies:
    6
    Views:
    525
  2. Roedy Green

    ResourceBundle Terminology

    Roedy Green, Dec 28, 2005, in forum: Java
    Replies:
    1
    Views:
    462
    Roedy Green
    Dec 28, 2005
  3. TheFerryman

    Help with terminology

    TheFerryman, Aug 14, 2003, in forum: C++
    Replies:
    3
    Views:
    357
    Mike Wahler
    Aug 19, 2003
  4. CuriousFellow

    Terminology Question

    CuriousFellow, Apr 27, 2004, in forum: C++
    Replies:
    5
    Views:
    391
    CuriousFellow
    Apr 29, 2004
  5. Paul
    Replies:
    63
    Views:
    1,285
Loading...

Share This Page