OpenStruct#update?

also don't forget this strange T_SINGLETON that sometimes I see in the

                                   ^^^^^^^^^^^

it's FL_SINGLETON (je suis fatigue :-()

doc.

Guy Decoux

Hi --

···

On Mon, 15 Nov 2004, ts wrote:

> obj.class
> obj.own_class

You can rename it, but don't forget to rename

   rb_define_singleton_methods()
   rb_singleton_class_clone()
   etc,

also don't forget this strange T_SINGLETON that sometimes I see in the
doc.

I'm not planning to rename it myself -- just discussing possible
names. I think it's true that Matz has said he is at least
considering changing it from singleton class to something else. (I
assume he'll search-and-replace if he does so :slight_smile:

David

--
David A. Black
dblack@wobblini.net

ts wrote:

"D" == David A Black <dblack@wobblini.net> writes:

> obj.class
> obj.own_class

You can rename it, but don't forget to rename

   rb_define_singleton_methods()
   rb_singleton_class_clone()
   etc,

also don't forget this strange T_SINGLETON that sometimes I see in the
doc.

But what about this?

irb(main):001:0> class << 1; end
TypeError: no virtual class for Fixnum

Ruby itself isn't consistent in the terminology it uses. Maybe that is the bigger problem.

dedicated_class
owned_class
private_class
individual_class
individualized_class
personal_class
personalized_class

···

"Florian Gross" <flgr@ccan.de> wrote

Objection to the objection: The singleton pattern is not widely used in
Ruby. Couldn't we rename the implementation of it? Maybe something like
"SingleInstanceClass"?

Interesting. I didn't know that. I wouldn't normally object but I've seen
discussion confusion over this more times than I can count. As for something
meaningful, the word 'special', as in specialized, again comes to mind.

Merriam-Webster Entry
Entry Word: special
Function: adjective
Text: 1 of or relating to one thing or class

-T.

···

On Monday 15 November 2004 01:18 pm, Yukihiro Matsumoto wrote:

Hi,

In message "Re: Kernel#singleton_class" > > on Tue, 16 Nov 2004 02:54:13 +0900, "trans. (T. Onoma)" <transami@runbox.com> writes:
>> I'd call them singleton classes. Any objection?
>
>Yes, cause of singleton pattern.

Hmm, any other alternative?

I don't prefer the terms "instance class" and "object class", just
because it's meaningless. Classes are naturally corresponding to
objects (or instances) in OOP. Besides, the word singleton used from
Lisp era, way older than design patterns, IIRC.

Well, I just used it. And the rest of the OOP world knows Singleton, yes?

T.

···

On Monday 15 November 2004 01:23 pm, Florian Gross wrote:

trans. (T. Onoma) wrote:
> On Monday 15 November 2004 12:28 pm, Yukihiro Matsumoto wrote:
> > I'd call them singleton classes. Any objection?
> >
> > matz.
>
> Yes, cause of singleton pattern.

Objection to the objection: The singleton pattern is not widely used in
Ruby. Couldn't we rename the implementation of it? Maybe something like
"SingleInstanceClass"?

Gavin Sinclair wrote:

(Besides, the Singleton Pattern has fallen foul of OO purists.)

Got any URLs? I think I agree with them, but they might have better reasons than me so I would be interested in reading about them. Thanks!

Hi --

> > Hi,
> >
> >>> I guess it's probably best to let matz decide the name.
> > >
> > >Yeah, as long as he doesn't choose 'virtual' :slight_smile:
> >
> > I'd call them singleton classes. Any objection?
> >
> > matz.

> Yes, cause of singleton pattern.

No, because of historical reasons, and the ability to distinguish
between two different uses of "singleton". (Besides, the Singleton
Pattern has fallen foul of OO purists.)

If there's a conflict, though, it's got to do with the existence of
the Singleton module in Ruby, popular or not :slight_smile: I do find myself
sometimes starting to write "singleton class", and then realizing that
that could be this:

  class << obj; self; end

or this:

  class C
    include 'singleton'
  end

I don't think this should be the deciding factor, but I do think that
we'll have lots of "not to be confused with..." explanations as long
as they both have this name.

David

···

On Tue, 16 Nov 2004, Gavin Sinclair wrote:

On Tuesday, November 16, 2004, 4:54:13 AM, trans. wrote:
> On Monday 15 November 2004 12:28 pm, Yukihiro Matsumoto wrote:
> > In message "Re: Kernel#singleton_class" > > > > > > on Mon, 15 Nov 2004 22:45:31 +0900, "David A. Black" > > <dblack@wobblini.net> writes:

--
David A. Black
dblack@wobblini.net

I have an idea. How about a compromise. Rather then use the term 'singleton
class' (the per object kind), lets use the slightly different term,
'singular-class'. That's quite nearly the same, but is just different enough
to prevent confusion.

Would that be alright with everyone? Matz?

T.

···

On Monday 15 November 2004 06:52 pm, Gavin Sinclair wrote:

No, because of historical reasons, and the ability to distinguish
between two different uses of "singleton". (Besides, the Singleton
Pattern has fallen foul of OO purists.)

I say go for it, Matz.

"Florian Gross" <flgr@ccan.de> schrieb im Newsbeitrag
news:2vsa7rF2ot432U1@uni-berlin.de...

trans. (T. Onoma) wrote:

> > I'd call them singleton classes. Any objection?
> >
> > matz.
>
> Yes, cause of singleton pattern.

Objection to the objection: The singleton pattern is not widely used in
Ruby. Couldn't we rename the implementation of it? Maybe something like
"SingleInstanceClass"?

But this will have more impact on existing code. I vote for conservative
behavior here: leave Singleton as it is and invent a good name for the
method that returns TCFKASC (who will guess this? Ruby quiz #13.5... :-))

Kind regards

    robert

···

> On Monday 15 November 2004 12:28 pm, Yukihiro Matsumoto wrote:

I think I've heard them called "metaclasses"; is that the same thing or
just a bad application of the word metaclass?

I think in an ideal world (one which revolves around me) I would
continue to call them singleton classes, and completely eradicate the
singleton antipattern from the standard library.

Paul

···

On Tue, Nov 16, 2004 at 03:18:32AM +0900, Yukihiro Matsumoto wrote:

In message "Re: Kernel#singleton_class" > on Tue, 16 Nov 2004 02:54:13 +0900, "trans. (T. Onoma)" <transami@runbox.com> writes:

>> I'd call them singleton classes. Any objection?

>Yes, cause of singleton pattern.

Hmm, any other alternative?

But what about this?

Why do you think that, one day, I've said to someone that he must be
carefull with "singleton class" if he want to document ruby ?

Guy Decoux

Hi,

But what about this?

irb(main):001:0> class << 1; end
TypeError: no virtual class for Fixnum

It was an old message reflected the model (once in my brain) in which
"class <<obj; end" actually generated the "virtual class" to hold
singleton methods etc. temporarily, then update the internal singleton
data structure. I will fix the message.

Ruby itself isn't consistent in the terminology it uses. Maybe that is
the bigger problem.

Indeed.

              matz.

···

In message "Re: Kernel#singleton_class" on Mon, 15 Nov 2004 23:38:19 +0900, Florian Gross <flgr@ccan.de> writes:

itsme213 wrote:

···

"Florian Gross" <flgr@ccan.de> wrote

Objection to the objection: The singleton pattern is not widely used in
Ruby. Couldn't we rename the implementation of it? Maybe something like
"SingleInstanceClass"?

dedicated_class
owned_class
private_class
individual_class
individualized_class
personal_class
personalized_class

Sorry, I was talking about the pattern that lets you only create a single instance of a class. See singleton.rb in Ruby's standard library.

Heh, I just did a quick Google search for "singleton.rb" to see where it is being used and found that there's already an RCR for renaming it on RCR 246: Rename singleton.rb

trans. (T. Onoma) wrote:

···

On Monday 15 November 2004 01:23 pm, Florian Gross wrote:
> trans. (T. Onoma) wrote:
> > On Monday 15 November 2004 12:28 pm, Yukihiro Matsumoto wrote:
> > > I'd call them singleton classes. Any objection?
> > >
> > > matz.
> >
> > Yes, cause of singleton pattern.
>
> Objection to the objection: The singleton pattern is not widely used in
> Ruby. Couldn't we rename the implementation of it? Maybe something like
> "SingleInstanceClass"?

Well, I just used it. And the rest of the OOP world knows Singleton, yes?

What did you use it for and why would another name be a problem in your case?

I'm NOT an expert, but my opinion is that the pattern is overused. There are cases where you must ensure restricted creation, but often it's an artificial limitation. It closes down options, so I feel it should only be used when you really need some significant protection it provides. I'm a keep my options open kind of guy.

Again, that's 100% my opinion. Take it or leave it.

James Edward Gray II

···

On Nov 15, 2004, at 6:48 PM, Florian Gross wrote:

Gavin Sinclair wrote:

(Besides, the Singleton Pattern has fallen foul of OO purists.)

Got any URLs? I think I agree with them, but they might have better reasons than me so I would be interested in reading about them. Thanks!

I am curious how I can capture a block that was passed. Here's what I'm trying to do:

class BaseClass
  def initialize( arg1 )
    puts "got a block" if block_given?
  end
end

class SubBaseClass < BaseClass
  def initialize( arg1 , arg2 )
    super( arg1 )
  end
end

sbc = SubBaseClass.new( "aarg1" , "arg2" ) { puts "my block" }

I would like BaseClass to receive the block I passed to the SubBaseClass constructor. I have tried a few variations, but nothing went.

Zach

The Class Formerly Known As Singleton Class. What do I win? :slight_smile:

David

···

On Tue, 16 Nov 2004, Robert Klemme wrote:

"Florian Gross" <flgr@ccan.de> schrieb im Newsbeitrag
news:2vsa7rF2ot432U1@uni-berlin.de...
> trans. (T. Onoma) wrote:
>
> > On Monday 15 November 2004 12:28 pm, Yukihiro Matsumoto wrote:
> > > I'd call them singleton classes. Any objection?
> > >
> > > matz.
> >
> > Yes, cause of singleton pattern.
>
> Objection to the objection: The singleton pattern is not widely used in
> Ruby. Couldn't we rename the implementation of it? Maybe something like
> "SingleInstanceClass"?

But this will have more impact on existing code. I vote for conservative
behavior here: leave Singleton as it is and invent a good name for the
method that returns TCFKASC (who will guess this? Ruby quiz #13.5... :-))

--
David A. Black
dblack@wobblini.net

http://c2.com/cgi-bin/wiki?SingletonGlobalProblems highlights some of
the issues with Singletons.

Regards,
Jason

···

On Tue, 16 Nov 2004 09:48:19 +0900, Florian Gross <flgr@ccan.de> wrote:

Gavin Sinclair wrote:

> (Besides, the Singleton Pattern has fallen foul of OO purists.)

Got any URLs? I think I agree with them, but they might have better
reasons than me so I would be interested in reading about them. Thanks!

--
http://blog.casey-sweat.us/

James Edward Gray II wrote:

···

On Nov 15, 2004, at 6:48 PM, Florian Gross wrote:

Gavin Sinclair wrote:

(Besides, the Singleton Pattern has fallen foul of OO purists.)

Got any URLs? I think I agree with them, but they might have better reasons than me so I would be interested in reading about them. Thanks!

I'm NOT an expert, but my opinion is that the pattern is overused. There are cases where you must ensure restricted creation, but often it's an artificial limitation. It closes down options, so I feel it should only be used when you really need some significant protection it provides. I'm a keep my options open kind of guy.

Again, that's 100% my opinion. Take it or leave it.

Thanks for it, it is of help.