Hi,

In message "[ruby-talk:12553] Re: FEATURE REQUEST: 'my' local variables"
    on 01/03/13, Dave Thomas <Dave / PragmaticProgrammer.com> writes:

|OK, I don't want to beat a dead horse, but from a user's perspective,
|in what way is this more complex than
|
|   { <a,b;c,d>
|     e = 1
|   }
|
|In this case, the user still has no idea of the meaning of 'e' unless
|they examine the entire outer scope. In
|
|  {{ |a,b|
|     e = 1
|  }}
|
|they know that _every_ variable is local to the block.

Well, some might feel that the latter is simpler.  But in reallity,
you may want some variables update, and rest of them remain isolated
from outer namespace, at the same time.  So I feel <> paremeters are
better, since we can explicitly choose.  But I hate the fact that the
user has to examine out scope to tell the scope of a variable.  I
really want to fix this.

I have two ideas, still not knowing which is better to solve this
problem.

The one is allowing explicit declaration of block local variables.
<a,b|c,d> is one choice of notations.  The other notation candidates
may be special block form({{}}), and special declarative assignment.
Special declarative assignment is something like:

  {
    e = 1    # e may or may not be local to the block
    f := 2   # f is always local to this block
  }

The other idea is implicit propagation of variable scope, that is

  foo {
    v = 25  # v used here for the first time
            # so normally v should be local to the block.
  }
  p v       # but since v is used here, so the scope of v would be
            # propagated to the outer level.

The latter idea requires no special syntax addition, works for most of
the cases.  The problem of this one is it might easily screwed up by
the misspelled names.

|I understand that this may be complex in terms of implementation, but
|it seems fairly simple from the outside.

I don't care about implementation (yet).

							matz.