3 ms·
> the RHS of the binding is defining an 'int' rather than a function value But what's the difference between an `int` value and a function value? It's only the
by still_grokking 4y ago
> the RHS of the binding is defining an 'int' rather than a function value
But what's the difference between an `int` value and a function value? It's only the type!
I don't know Cpp2, need to have a closer look, but treating everything as a value makes perfect sense, imho, as everything is just a value in the end.
Any definition will become some structure in memory eventually. A "program", and a function is nothing else than a "small program", is data. Only the interpretation of said data makes the difference.
Types hint at how some data is meant to be interpreted. You could say they determine the interpreter to use, later on.
A syntax that makes those basic ideas very clear seems therefore very convincing to me. It's imho less confusing than something that does treat some "special" types of data, namely function values, very differently even on the syntax level, although the only difference is the type (which is the hint at how this data should be interpreted and nothing more).
Even an `int` value can be "executed", so there is no fundamental difference to the idea of a "function". Just interpret the `int` as a pointer to memory. The machine doesn't care as it allows arbitrary interpretations of arbitrary data structures. That's the whole point of a programmable computer in fact. (And also the constant source of the security issues with them).