On Mon, 27 Mar 2006 [email protected] wrote:
I honestly don’t see any connection between the two techniques (:: and
suggestive variable names). c::meth doesn’t communicate anything to me
it does though - you know c must be a module (classes being
Even if it did, I’m not sold on the idea that it’s necessary to have a
different message-sending operator for a particular class of objects. It
doesn’t scale: you can come up with lots of variable names (my_class, etc.),
but you can’t keep adding operators to make distinctions among receivers.
Nor is it necessarily vital in very many cases to make such distinctions.
i can see that point of view. still, i like this:
harp:~ > cat a.rb
class D; end
E = 42
def self::foo() 42 end
namespace = A::B::C
harp:~ > ruby a.rb
and i think it’s why ‘::’ can call methods - though this is a w.a.g.
And when it’s a matter of String.new vs. String::new, you already know it’s
a class anyway
only sometimes though:
def C(*a, &b) ::C::new(*a, &b) end
this is contrived, but String is a perfect example of this: both
String exist and certainly many libs export ‘const methods’.
all you really when a variable starts with [A-Z] is that it’s a const.
happends quite a bit in my code because i always wrap up code into
modules so i
end up with things like this:
def self::new *a, &b
C::new *a, &b
where ‘C’ is sort of the ‘default’ or ‘main’ class in this set - so i
a convenience method for the common ctor case. of course you can use
here… i’m just pointing out that a lefthand side const may not be a