nddrylliog/rock — Issue #349: => operator: Thoughts, problems and solutions
Author: shamanas
Created: 2011-12-03 17:37:05+00:00
State: open

Recently it has been suggested that an => operator be added for further DSL-ing potential. I have had some attempts to make this happen. Here are the results of said attempts.

Thoughts
-------------

An => operator would be awesome

Problems
-------------

Conflict with case keyword causing wrong evaluation of match statements.
Also, apart from the wrong evaluation, what IS the right behaviour in the following code?

pair := 2 => 3 // Assuming => has been overloaded to make Pair's
match(pair) {
case 2 => 3 => "OYEAH!" println() // <---------- HERE, HERE
case => "OHNOES :(" println()
}

Solutions
-------------

In my opininon, the solution to the behavioral problem above is that the rightermost => should be accounted to be case's, while the rest of the => are operators. That or implement some other operator (-> ?) instead of it.
Of course, being a PREG grammar novice, I am not wise enough to implement this n nagaqueen :<