From: Kero van Gelder Date: 2001-06-27T02:58:56+09:00 Subject: [ruby-talk:16918] Re: rb_define_class() vs Class.new() Guy, What would be the semantics of a = Class.new() A, B = a, a p a.name ? (without giving any implementation detail, pls) > K> All of this does not appear to be any argument against having > K> Class.new(nameOrSymbol=nil, superClass=Object) > K> as far as I can tell, even if you demand that a classname starts with > K> a capital. > > Because you don't really need it. Sure, attr_reader is not really needed either. Perhaps you mean ``you don't really want it'', which is subtly different. It may not be true, but I can not find an example atm for which I really want it. Note: I redesigned my original stuff because users defining names of classes is bad, even though users defining names is usually good. [snip] > to create a Class from a String you use #const_set > > pigeon% ruby -e 'Object.const_set("A", Class.new); p A.type' > Class > pigeon% Let's make a poll on rubygarden :-) What looks nicer: - Object.const_set("A", Class.new) - eval("class A; end") - Class.new("A") - I don't use classes Bye, Kero. PS: I have the feeling I do not get the answers that I am looking for, but may be I should phrase my questions better. Or may be I can not see the answers on my screen in Ruby code because I am not familiar enough with Ruby, yet. Or may be it is because two discussions are in one chain: - the original, to which I gave some answer myself, - the derived discussion about A = Class.new() that sets the name of the class, which I decided I hate. I try to find a reason for it, but so far heard none (and try to find examples for, that show it is really, really bad :) Oh, well, I can probably live with this deficit, since I found so many benefits in Ruby already. +--- Kero ------------------------------ kero@chello.nl ---+ | Don't split your mentality without thinking twice | | Proud like a God -- Guano Apes | +--- M38c ------------------ http://huizen.dds.nl/~kero ---+