Search the web
Sign In
New User? Sign Up
arctan · Austin Ruby Coders
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Double Meta   Message List  
Reply | Forward Message #1877 of 1899 |
Re: [arctan] Double Meta

On Thu, Nov 20, 2008 at 4:37 PM, Eric Mahurin <eric_mahurin@...> wrote:
> Wondering the same thing myself. Jim, do you have an application?

Not really. I was really just exploring the language. Besides, this
type of things already
exists with #dup and #clone. I suppose if you wanted to add methods to
an object that
were stripped away even with a #clone, this would be the way to do it.

> Sorry I didn't make it. I wanted to come, but something came up.
> While on the topic of singletons, this is how I make my singleton *objects*:
>
> singletonObject = Class.new(base_class) { # base_class defaults to Object
> def foo ... # or define_method
> ...
> }.new
>
> All this does is create an anonymous class and call new on the class to
> create the singleton object (for that class). I find this more intuitive and
> readable than dealing with meta classes.

And once you have that object, what are it's uses?



--
Jim Freeze



Fri Nov 21, 2008 2:05 pm

drjimfreeze
Offline Offline
Send Email Send Email

Forward
Message #1877 of 1899 |
Expand Messages Author Sort by Date

For those that attended the meeting, here is my code where I introduce a singleton class in a singleton class. class C class << self class << self def foo ...
Jim Freeze
drjimfreeze
Offline Send Email
Nov 20, 2008
6:46 am

Completely work safe, realted to Jim's double singleton class. http://tinyurl.com/6crlx9 http://tinyurl.com/5z35ln Wayne...
Wayne Walker
wwalker_bybent
Offline Send Email
Nov 20, 2008
2:01 pm

For those of us not in attendance to the meeting: Is this useful, or purely experimental Ruby? *Mars ... ( <> .. <> )...
MarsHall
mars_of_earth
Offline Send Email
Nov 20, 2008
5:46 pm

... We were talking about ghost (aka singleton, meta-, eigen- classes) and I was wondering if I could put a meta class on a meta class. And, if I did, would a...
Jim Freeze
drjimfreeze
Offline Send Email
Nov 20, 2008
9:03 pm

Wondering the same thing myself. Jim, do you have an application? Sorry I didn't make it. I wanted to come, but something came up. While on the topic of...
Eric Mahurin
eric_mahurin
Offline Send Email
Nov 20, 2008
10:37 pm

... Not really. I was really just exploring the language. Besides, this type of things already exists with #dup and #clone. I suppose if you wanted to add...
Jim Freeze
drjimfreeze
Offline Send Email
Nov 21, 2008
2:06 pm

... http://en.wikipedia.org/wiki/Singleton_pattern I'm not sure my instance of an anonymous class actually matches the "singleton pattern", but I believe it is...
Eric Mahurin
eric_mahurin
Offline Send Email
Nov 22, 2008
7:53 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help