On 2012-08-24 12:03 , Gabriel Dos Reis wrote:
I would just use C++ standard function `at()' (e.g. as found in vector<T>) for this.
Sure. For regular functions, using default-valued arguments would be fine. But I think the mechanism would be much more transparent if the compiler did the heavy lifting.
1- Add a class/function attribute that makes the compiler add 3 hidden args for the caller location. 2- During code generation, the compiler fills in these values at call sites. 3- The callee accesses these values by referencing specially named arguments (much like 'this') or via __builtin_* accessors. I think I prefer using __builtin_*. Diego.