Wednesday 1 May 2019

Case sensitivity

Found this piece of code in a message (now deleted) on Stack Overflow, for the language Go:

func addGmp(a, b, c, d, e, f, x, y, X, Y, P *big.Int) (*big.Int, *big.Int) {
    // a,b,c,d,e,f this var (fast in func)
    a.Sub(Y, y)
    b.Sub(X, x)
    ...

The problem is not only that all the parameters have single-letter names that don't say anything about them, the much bigger problem is that there are parameters named x and y as well as X and Y. This is, IMO even worse than something like (in C):

int SomeApi(HWND hwnd, HDC hdc);

Let me reiterate that I am so happy that Delphi (and Pascal) are case-insensitive, and that such abominable parameter names are not possible.

2 comments:

  1. I agree, case sensitivity is a bad enough in itself, even worse using it to make subtle different names like your examples leads to errors that are difficult to track down and debug.

    ReplyDelete
  2. I would like to see the option to activate case sensitivity in Pascal (Delphi) since using this rule makes the code much better readable. But the example with HWND hwnd is terrible indeed.

    ReplyDelete