Is this old style Ruby?

centrepins@gmail.com wrote:

So you would say use :: only for constant access, and use '.' for
method access be it in a class or module?

Certainly, IMO. I usually say Math.sin rather than Math::sin. Basically
I don't care in general whether it's a class or just a module. (There
might be times when I do care.)

As for module names and class names (replying to what someone else said),
remember that these are typically constants. In other words, if Foo::Bar
is a class, it's just a special case of Foo::Bar being a constant.

Hal

Oh now I'm confused....

Where's Matz??? :o)

Hi --

* centrepins@gmail.com (Feb 15, 2005 16:16):

So you would say use :: only for constant access, and use '.' for
method access be it in a class or module?

Well class-methods are constant as well in a sense, hence the use of
"::" in Why's book and it being the (at least old-school) idiom,

I disagree; I don't think class methods are constant in any sense, any
more than any other method definition. They're basically just
per-object/singleton method definitions:

   class C
     def C.x
     end
   end

like

   str = "abc"
   def str.x
   end

etc. They have a semi-special status in the language (e.g., the
existence of the #class_methods method), but when you call one, you're
just sending a message to an object for method-call-based response.
That's different from retrieving a constant, but it's not different
from calling a method on any other object.

David

···

On Wed, 16 Feb 2005, Nikolai Weibull wrote:

--
David A. Black
dblack@wobblini.net

* David A. Black (Feb 15, 2005 17:10):

> Well class-methods are constant as well in a sense, hence the use of
> "::" in Why's book and it being the (at least old-school) idiom,

I disagree; I don't think class methods are constant in any sense, any
more than any other method definition. They're basically just
per-object/singleton method definitions:

True. Still, there's a subtle difference. I agree, however, that
there's really no good reason to use "::" in this case; I certainly
write

File.open ...

rather than

File::open ...

which is one symbol longer and doesn't make it easier to read,
  nikolai

···

--
::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka :::
::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden :::
::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 :::
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}

Hi

···

In message "Re: Is this old style Ruby?" on Wed, 16 Feb 2005 00:54:53 +0900, centrepins@gmail.com writes:

Oh now I'm confused....

Where's Matz??? :o)

Here I am. :wink:

I allow '::' for method calls to denote class methods (with C++ style
appearance). David doesn't like it. I think _why liked it.

              matz.

Hi --

···

On Wed, 16 Feb 2005, Yukihiro Matsumoto wrote:

Hi

In message "Re: Is this old style Ruby?" > on Wed, 16 Feb 2005 00:54:53 +0900, centrepins@gmail.com writes:

>Oh now I'm confused....
>
>Where's Matz??? :o)

Here I am. :wink:

I allow '::' for method calls to denote class methods (with C++ style
appearance). David doesn't like it. I think _why liked it.

I never learned C++, so I can't experience the pleasure of being
reminded of its style :slight_smile:

David

--
David A. Black
dblack@wobblini.net

Yukihiro Matsumoto wrote:

I allow '::' for method calls to denote class methods (with C++ style
appearance). David doesn't like it. I think _why liked it.

I like it okay. Not with fervor.

@var is instance var. obj.meth is instance method.
@@var is class var. obj::meth is class method.

I guess I thought that the notion of single-character for any instance syntax and double-character for any class syntax might be simpler.

It's arbitrary, though. If it's confusing to most, I definitely want to change it's use in the (Poignant) Guide.

_why

I, however, am very familiar with C++, and I also cannot experience the
pleasure of being reminded of its style. :wink:

···

On Tuesday 15 February 2005 08:25 pm, David A. Black wrote:

On Wed, 16 Feb 2005, Yukihiro Matsumoto wrote:
> I allow '::' for method calls to denote class methods (with C++ style
> appearance). David doesn't like it. I think _why liked it.

I never learned C++, so I can't experience the pleasure of being
reminded of its style :slight_smile:

--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

why the lucky stiff wrote:

Yukihiro Matsumoto wrote:

I allow '::' for method calls to denote class methods (with C++ style
appearance). David doesn't like it. I think _why liked it.

I like it okay. Not with fervor.

@var is instance var. obj.meth is instance method.
@@var is class var. obj::meth is class method.

I guess I thought that the notion of single-character for any instance syntax and double-character for any class syntax might be simpler.

With such cases (I apply the same rule to constant naming, I don't see why I should use SHOUTING_CAPS for non-class constants) I always wonder about others doing an arbitrary distinction between classes and objects -- are classes after all not also objects?