From: Logan Capaldo Date: 2005-12-08T11:29:33+09:00 Subject: Re: injecting dynamic methods into a class On Dec 7, 2005, at 9:22 PM, jonathan wrote: > jonathan wrote: >> transfire wrote: >>>> 'Ad hoc' has too many negative connotations and singleton has a >>>> fairly >>>> unambiguous meaning. >>> >>> I felt the same way at first, until I started using it, keeping >>> in mind >>> the strict definition --even the Latin definition: *for this*. >>> >> >> That's really interesting. It's unfortunate that the most common >> use of >> the term is a secondary meaning. I guess using it will motivate >> people >> to find out primary meaning. I'm all for it. :) > > Just to clarify (I hadn't finished reading all the posts when I > made the > above comment). I don't mean to make my vote 'for' this term, but, I > meant that I was for using a term in a way that educates. Most of us > are people that like to learn anyway. :) > > Having many terms for the same thing isn't necessarily a bad > thing. It > happens in every other aspect of programming as well (class methods > are > called 'member functions', 'methods', 'member methods', etc.). > > How do you all think the term 'static class' fits? > > Also, one more thing: > > How do you actually implement the singleton pattern in Ruby? Not > being > able to return a self ptr from initialize seems to stump me. > > --Jonathan > > -- > Posted via http://www.ruby-forum.com/. > Well the easy way is require 'singleton' class IWantToBeASingleton include Singleton end And the slighlty harder way class IAlsoAmASingleton class << self private :new end def self.instance @inst ||= new end end