10000 Create 2015-6-18-repeated-byname · akkomar/scala.github.com@ad9514d · GitHub
[go: up one dir, main page]

Skip to content

Commit ad9514d

Browse files
committed
Create 2015-6-18-repeated-byname
1 parent db7a6f0 commit ad9514d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## Motivation
2+
3+
Scala so far does not allow by-name repeated parameters. But I can't see a good reason why this combination should be disallowed. Also, the combination is necessary to allow vararg parameters that are passed as expressions to inline methods (instead of being lifted out).
4+
5+
## Syntax
6+
7< 88B3 /code>+
The syntax for `ParamType` becomes
8+
9+
ParamType ::= [`=>'] ParamValueType
10+
ParamValueType ::= Type [`*']
11+
12+
The syntax implies that a type such as `=> T*`, which is both by-name and repeated is interpreted as `=> (T*)`, that is, as a by-name type of a repeated type.
13+
14+
## Translation Rules
15+
16+
If a parameter has a by-name repeated type `=> T*` it matches an arbitrary number of actual arguments of type `T`. As usual for by-name parameters, the arguments are not evaluated at the point of call. Instead, all arguments are evaluated each time the parameter is referenced in the called method.
17+
18+
The same holds for an vararg argument of the form `e: _*`. The argument expression `e` is evaluated each time the parameter is referenced in the called method.
19+
20+
## See also
21+
22+
https://github.com/lampepfl/dotty/issues/499

0 commit comments

Comments
 (0)
0