News for hackers. Stuff that matters.
Re:Let the Type System do the Work by jasode on Monday April 21, 2014 @03:14PM (#7623034)
Named arguments by themselves do not fundamentally prevent data type errors when the underlying types are identical. Short variable names (v1, v2) or some other cosmetic ambiguity will deceptively compile with named arguments as the only defense.

Both of the following would compile successfully using named arguments but one of them is semantically wrong:

Player(pos = v1, size = v2);

Player(pos = v2, size = v1);

Using a compiler's static type checking enforces correct semantics more than named arguments. Of course, this only works if the programmer creates new differentiated types so that they are no longer identical (which was the crux of the article.)

There are no comments on this comment yet.