Re:How to interpret complex C/C++ declarations (2004)
by bjz_ on Thursday August 01, 2013 @03:16AM
(#6139075)
What does the tildes do in `(~[~[~[~[A, B], C], D], E])`?
Re:How to interpret complex C/C++ declarations (2004)
by terhechte on Thursday August 01, 2013 @03:56AM
(#6139146)
It's a wrapper over a sequence of matches:
http://www.scala-lang.org/api/current/#scala.util.parsing.co...
Given p1: Parser[A] and p2: Parser[B], a parser composed with p1 ~ p2 will have type Parser[~[A, B]]. The successful result of the parser can be extracted from this case class.
In this case it will use the [[[[A,B] C] D] E] sequence to compose A,B,C,D,E together in order to produce F (A-F are types). At least if I understand things correctly, I've never used flatten5.
def scanLeft[B, That](z: B)(op: (B, A) ⇒ B)(implicit bf: CanBuildFrom[Iterable[A], B, That]): That
implicit def flatten5[A, B, C, D, E, F](f: (A, B, C, D, E) ⇒ F): ((ImplicitConversions.this)#~[(ImplicitConversions.this)#~[(ImplicitConversions.this)#~[(ImplicitConversions.this)#~[A, B], C], D], E]) ⇒ F
implicit def flatten5[A, B, C, D, E, F](f: (A, B, C, D, E) ⇒ F): (~[~[~[~[A, B], C], D], E]) ⇒ F
These are, thankfully, exceptions and most declarations are easier to read, nevertheless, as a Scala beginner, it takes me quite some time parsing such a declaration when I intend to utilize the function in question. But that's probably the price to pay for complex static typing.