- Current code:
foo(KeyAddr(2, 3)), or
foo(key_address)if we got the address ourselves from someplace else.
- With indexes:
foo(key_address). In this case we need helpers to convert to- and from between coordinates and index.
- With index + helpers:
In all three cases, the current syntax would still work, because we’ll make sure to have backward compatibility.
So the look of the code is pretty much exactly the same. But in the index + helpers case, the code that implements this is much, much simpler. And that simplicity is what I campaign for.
There are some subtle differences, like when iterating, we currently use
COLS * ROWS as maximum, while with
KeyAddr… I’m not sure what we’d use there, but we can provide a constant for that too, without having to use a complicated class.
From the user point of view, there is very little difference between what @noseglasses proposed, and mine. The one major difference I can see is that with
KeyAddr, you can do both
foo(KeyAddr(1, 1)) and
foo(KeyAddr(9)), and both mean the same thing (assuming a 8-column keyboard, and an
index = row * 8 + col transformation). With mine, you’d write this as
foo(KeyIndex(1, 1)) and
foo(9). In both cases,
foo(1, 1) would still work.
The major difference is that his code provides more info to the compiler, which can then use that information to error out or warn about wrong use. That’s a good thing, but not worth the complexity, in my opinion.