News for hackers. Stuff that matters.
Re:Arrays of Arrays (2009) by jiggawatts on Sunday December 20, 2020 @12:56AM (#25484203)
Which reminds me of an insightful observation that the array indexing operator [] and the function call operator () are basically doing the same thing: evaluating a function and returning a value.

So what you've just described is basically Currying, or partial function evaluation. It's a bit like defining "al(i)" as array lookup for an index 'i' instead of "[i]". Then the following are equivalent:

    something[i][j]
    something.al(i).al(j)
What people also want are:

    something[i,j]
    something.al(i,j)
In languages like Haskell, every function can always be evaluated argument-by-argument, with no special effort by the programmer. The compiler takes care of generating the code for the various intermediate call forms. In languages like C++, it would be a significant hassle to create all of the various partially-evaluated wrapper types.
Re:Arrays of Arrays (2009) by gpderetta on Sunday December 20, 2020 @02:30PM (#25488858)
In C++ you can create a simple generic reusable currying wrapper. Boost as a few. The reality is that the vast majority of C++ programmers don't see the need.
Re:Arrays of Arrays (2009) by Animats on Sunday December 20, 2020 @06:25PM (#25490590)
Trying to do this this through Currying turns a simple 2D array access into a quite complicated operation. One that a compiler has to be really smart to turn into a gheap 2D array indexing operation again. This really matters in number-crunching code, where it seems that almost everything is about multiplying arrays.
Re:Arrays of Arrays (2009) by gpderetta on Tuesday December 22, 2020 @09:39AM (#25506630)
Of course it wouldn't make much sense to do it for indexing. I was discussing currying as a generally useful tool.