Yukihiro Matsumoto wrote:
...
>      From my observation, block parameters has two major roles,
>      iteration variables and Proc's formal arguments.  Current
>      behavior focuses too much on the former.  We'd better rescue the
>      latter too.  That's why I'm thinking of "<...>", which gives
>      distinct notation for each major role.  Ithink we don't need to
>      mix these two roles.

It seems to me that this sheds new light on the problem, and
shows us the direction this will ultimately take.  If this is
the way it has to be -- giving a distinct place for each role,
then I see the "<...>" making a lot more sense. But, I have
two alternate ideas for depicting them

I) "(....)" notation (already mentioned)
   This is 'soft' and looks like a method parameter list.
   Downside is context complications.

II) "...|...|" notation (has this been mentioned?)
   This utilizes smalltalk's [x,y| .... ] notation, where such
   vars are private to the block.
   This would allow familiar |a,b,c| iterator notation.
   I think this will be the most flexible, concise, and familiar.

ex. for II

1)  proc{x,y|a,b,c| ..... }

  - x and y block-local
  - a,b,c are as usual (probably with new auto-export feature by then)

2)  proc{x,y| .... }
  
  - x and y block-local
   
3)  proc{|a,b,c| .... }

  - a,b,c as usual, etc.

These would allow multi-line versions:
proc{x,y
  |a,b,c|
  ....
}

proc{
  x,y|a,b,c|
  ....
}

proc{
  x,y
  |a,b,c|
  ....
}

proc{ 
  x,y|
  ....
}

proc{
  x,y
  ||
  .... 
}

etc.

And we can always say it was inspired by smalltalk ;-)


The only question remaining in my mind is whether this distinction
means that the assignments will act separately or not.  For example,
will #call use the formal block-local vars while #yield uses the
flat-scoped iterator parameters?

And should we allow this:

proc{ x|x| .... }

which could make a block-local variable available also as
an iterator parameter. Or should it raise an exception?


Guy N. Hurst


-- 
HurstLinks Web Development    http://www.hurstlinks.com/
Norfolk, VA  23510            (757)623-9688 FAX 623-0433
PHP/MySQL - Ruby/Perl - HTML/Javascript