Closed anatoliykmetyuk closed 8 years ago
Should a ~~> b ~~> c
be a ~~> [b ~~> c]
or [a ~~> b] ~~> c
?
[a ~~> b] ~~> c
is most natural; see 10 - 1 - 2
.
A special case is when the last arrow is an exception flow. What would we expect of:
a ~~> b ~/~> c
IMO indeed the left-association would be convenient.
What's 10-1-2
? Just thought about it: rhs associativity grants the best visibility for the leftmost operator. Use case:
{!getCurrentUser!} ~~(currentUser: String)~~> [
[repositories.score.last: currentUser ~~(Some((right: Double, left: Double, _)))~~> (new Test(currentUser, right, left, 5))
+~~(None )~~> (new Test(currentUser, 20 , 20 , 5))]
~~((right: Double, left: Double))~~> [
repositories.score.write: currentUser, (right, left)
(new Result(right, left))
]
]
Three dataflows here, all right-associative, so that currentUser
from the first dataflow can be used even in the last dataflow.
a ~~> b ~/~> c
will be parsed as one dataflow, c
belongs to a
's failure, because the longest match is parsed.
Edit: Second dataflow of the example is left associative though.
10 - 1 - 2 = 7, not 11.
Dataflow is a special case IMO.
scala> classOf[Int => Int => Int]
res0: Class[Int => (Int => Int)] = interface scala.Function1
Yes, I am convinced now that right-associativity is the best choice. The use case is great. I recall that about a half year ago I had the same visibility argument in mind, but I forgot it.
So far, expressions like
a ~~(x: T)~~> b ~~(y: T)~~> c
are not possible. Parsing fails at second dataflow.