On Monday, 27 August 2012 at 13:44:43 UTC, Manu wrote:
On 27 August 2012 15:48, Robert Clipsham <[email protected]> wrote:

I seem to recall I looked at this issue myself at one point. It goes
something like:
----

auto foo = (int a = 1) { return a; };
auto bar = (int a) { return a; };
----
int function(int) is mangled exactly the same as int function(int = 1) as default args aren't used for mangling. dmd does semantic analysis on the type of foo, which returns int function(int = 1), which is mangled as int function(int) and stored in dmd's hashmap of types (default args aren't mangled). When the semantic analysis of bar is done it checks the hashmap, sees that the type is already there (has the same name mangling) and does not repeat semantic analysis. If you switch the order of declarations then
the opposite happens - the default arg is ignored.


Cached in a hashmap! precisely what I suspected (without knowing anything
about it) ;)
That explains why Walter keeps going on about the name mangling. It's all
clear.

This discussion is all sorts of wrong. Whoever said that defargs are metadata (Manu?) was right. Therefore it would make sense to implement a general metadata facility for D and use *that* for defargs. C++11 has annotations, so that's the place to start looking at. D has already enough of those pesky special case features, let's not add yet another one at the expense of a more general metadata/annotation mechanism which eventually would be added anyway due to popular demand.

Reply via email to