On Dec 10, 2007 8:50 PM, Just Another Victim of the Ambient Morality
<ihatespam / hotmail.com> wrote:
> > With Ruby, this is just an initialization - "variable = nil".  With
> > Perl it's "my variable" - alas, that variable is the shadowed by the
> > other my declaration I wrote later in the code and earlier in time.
> >
> > I had this bug just last week.
> >
> > In my opinion, the noise of repeated "var <stuff>"-declarations (or
> > "my <stuff>" declarations) makes the code less readable, with the
> > corresponding increase in correctness checking being a benefit of less
> > worth than the cost.  This is the same as my view of (other) type
> > declarations in most cases: Their cost in terms of being in the way of
> > code readability/transformability exceeds their benefits.
>
>     As I've mentioned, above, there should be no cost except that of
> actually having to type it out.

I think maybe we would communicate better if you read what you were replying to?

One strength of Ruby - an important one - is that it is succinct.
There is very little extra noise compared to what is strictly
necessary to say what the program is doing.  Your proposal introduce
extra noise.  This noise has a cost for readability in some cases.  My
opinion is that this cost is higher than the utility of the construct,
as the construct guard against an error that is easy to guard against
in other ways,  other ways that are generally better, like unit
testing or string completion.

>  My guess is that declarations are far less common than variable use,

This depends on code style.  Those that use a lot of short methods
also have more variable declarations compared to variable assignments,
in my experience.

Eivind.