It does look elegant. Take a look at this article, where "with" is used in a similar manner to simulate "private static" members: http://www.litotes.demon.co.uk/js_info/private_static.html
Best, kangax On May 22, 10:09 am, Frederick Polgardy <[EMAIL PROTECTED]> wrote: > I might get in trouble with the with-Nazis for this, but I came up > with what I think is a cool class definition pattern for Prototype, > that gives you visibility over Class attributes, similar to what you > would experience in more static languages: > > var Foo = Class.create(); > Object.extend(Foo, { > A_CLASS_CONSTANT: 42, > a_class_method: function() { > }}); > > with (Foo) addMethods({ > an_instance_method: function() { > alert(A_CLASS_CONSTANT); > a_class_method(); > } > > }); > > Apart from the usual 'with' pitfalls, it's pretty clean. > > Any thoughts? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---