# Question about block parameter syntax

\$B!!\$5\$5\$@\$G\$9!%(B

1.times{
|
x,
y|
}

\$B\$ODL\$j\$^\$9\$,!\$(B

1.times{
|
x,
y
|
}

\$B\$ODL\$j\$^\$;\$s!%JD\$8\$k(B |
\$B\$,9TF,\$KMh\$k\$N\$,\$^\$:\$\$\$h\$&\$G\$9!%\$3\$l\$O!\$\$=\$&\$\$\$&(B
\$B\$b\$s\$G\$7\$g\$&\$+!%2<5-\$N\$h\$&\$K!\$%V%m%C%/%Q%i%a!<%?\$K%3%a%s%HF~\$l\$h\$&\$H;W\$C(B
\$B\$F5\$\$E\$-\$^\$7\$?!%(B

1.times{
|
x, # xxx
y # yyy
| # <- syntax error, unexpected ‘\n’, expecting ‘|’
}

\$B\$^\$D\$b\$H(B \$B\$f\$-\$R\$m\$G\$9(B

\$BE:IU\$N%Q%C%A\$GD>\$j\$=\$&!#\$@\$l\$+3NG’\$7\$F\$b\$i\$(\$^\$;\$s\$+!)(B

In message “Re: [ruby-dev:45290] Question about block parameter syntax”
on Sun, 26 Feb 2012 13:59:11 +0900, SASADA Koichi [email protected]
writes:
|
|\$B!!\$5\$5\$@\$G\$9!%(B
|
| 1.times{
| |
| x,
| y|
| }
|
|\$B\$ODL\$j\$^\$9\$,!\$(B
|
| 1.times{
| |
| x,
| y
| |
| }
|
|\$B\$ODL\$j\$^\$;\$s!%JD\$8\$k(B | \$B\$,9TF,\$KMh\$k\$N\$,\$^\$:\$\$\$h\$&\$G\$9!%\$3\$l\$O!\$\$=\$&\$\$\$&(B
|\$B\$b\$s\$G\$7\$g\$&\$+!%2<5-\$N\$h\$&\$K!\$%V%m%C%/%Q%i%a!<%?\$K%3%a%s%HF~\$l\$h\$&\$H;W\$C(B
|\$B\$F5\$\$E\$-\$^\$7\$?!%(B
|
| 1.times{
| |
| x, # xxx
| y # yyy
| | # ← syntax error, unexpected ‘\n’, expecting ‘|’
| }
|
|–
|// SASADA Koichi at atdot dot net

diff --git a/parse.y b/parse.y
index 3c4f4ce…bde683f 100644
— a/parse.y
+++ b/parse.y
@@ -3727,13 +3727,16 @@ block_param_def : ‘|’ opt_bv_decl ‘|’
;

-opt_bv_decl : none

• | ‘;’ bv_decls
+opt_bv_decl : opt_nl
• ``````   {
``````
• ``````     \$\$ = 0;
``````
• ``````   }
``````
• | opt_nl ‘;’ bv_decls opt_nl
{
/%%%/
\$\$ = 0;
/*%
• `````` \$\$ = \$2;
``````
• `````` \$\$ = \$3;
%*/
}
``````
;
@@ -3788,7 +3791,7 @@ lambda : {
}
;

-f_larglist : ‘(’ f_args opt_bv_decl rparen
+f_larglist : ‘(’ f_args opt_bv_decl ‘)’
{
/%%%/
\$\$ = \$2;

\$B\$J\$+\$@\$G\$9!#(B

(12/02/27 13:12), Yukihiro M. wrote:

\$BE:IU\$N%Q%C%A\$GD>\$j\$=\$&!#\$@\$l\$+3NG’\$7\$F\$b\$i\$(\$^\$;\$s\$+!)(B

\$B\$h\$5\$=\$&\$G\$9!#(Br34832\$B\$N%F%9%H\$ODL\$k\$3\$H\$r3NG’\$7\$^\$7\$?!#(B