[prev in list] [next in list] [prev in thread] [next in thread]
List: ruby-talk
Subject: Re: capital method names
From: "Jason Voegele" <jason () jvoegele ! com>
Date: 2002-04-09 14:47:05
[Download RAW message or body]
> When I write:
> a = 1
> or
> def a; return 1; end
>
> I can access the variable or method the same:
> puts a
>
> but if I write:
> A = 1
> or
> def A; return 1; end
>
> then I must write:
> puts A
> to access the variable, or
> puts A()
>
> to access the method. This is a little bit inconvenient, since it
> means I can't transparently replace constants with methods (it recently
> came up when I had been using a constant to represent the number of
> seconds since receiving data before I would sound an alarm, but later
> wanted to make that number of seconds dependant on the time of the day,
> since more data comes in at certain times of the day than others).
>
> Is this a feature or an oversight?
It certainly flies in the face of the Uniform Access Principle, which Ruby
otherwise supports. I would think that, given Ruby's policy of capitalized
constants, it could first assume a capitalized name was a constant, then if
no such constant was defined search for a method with that name.
I'd say it's an oversight.
Jason Voegele
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic