From: "Mauricio FernŠŌdez" <batsman.geo / yahoo.com>


> > Thus, if 'a' and 'c' are regular parameters and 'b' is an external
variable,
> > then one could write
> >
> >   collection.each do |a,:b,c|
> >     ...
> >   end
>
> I hereby claim authorship of any syntax derived from the use of
> the ':' prefix to indicate the scope of block parameters, based on
> [ruby-talk:52401]. All rights reserved.
>
> :-)

Fair enough.  Your royalty cheque is in the mail.

> > or
> >
> >   collection.each do |a,b,c|
> >     external b
> >     ...
> >   end
> >
> > I'm not sure which of the above I prefer.  One should optimise for the
common
> > case.
>
> I'd head towards ':'. Reason: less typing.
> Plus we're used to having '@' and '@@' to indicate scope (kinda), so it
> just makes sense for me.

Exactly.

> Local params would surely be more common, but marking them with ':'
> instead of the external ones has the additional advantage of not
> breaking any code out there.

I disagree.  Marking the external ones rather than internal ones is SO much
more sensible.  Seeing a.each do |:x| everywhere is too ugly.  Changes have
been made that break code before.  How much code would it really break anyway?

> The transition could be made very easy if
> the current scoping rules are mixed with ':' for a while.
>
> So in
>    blabla.aaaa do |a,:b|
>
>    end
>
> a is local if there's no variable named 'a' previously defined,
> otherwise external

This sort of confusion is exactly what we want to get away from.

> b is local even if there's already 'b' in the external scope
>
> bottom line: nothing breaks, ':' forces local
>
> Ruby can issue a warning iff there was no 'a' variable before, as this
> code would break once the old scoping rules are thrown away and only the
> presence or absence of ':' is significant.

Gavin