I have an Image trait that represents a 2D ARGB image. Image has a map method which takes a mapping function and transforms the image using said function. The mapping function has 3 parameters: the X and Y coordinates and the color of the image at that coordinate. The color is represented as a 32-bit ARGB value packed into an Int.
trait Image {
def map(f: (Int, Int, Int) => Int)
}
However, without a comment, it's impossible to tell which parameter of f is which.
In C#, I would create a delegate for this, which allows me to name the parameters of the mapping function:
delegate int MapImage(int x, int y, int color);
Is there anything of this sort in Scala? Is it being considered for addition to the language? Without it, I cannot write an interface that is readable without explicit documentation.
(Note: I know I should wrap the Int in a case class for the purposes of representing a color, but this is just an illustrative example.)