On 27 August 2012 15:48, Robert Clipsham <rob...@octarineparrot.com> 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.

Reply via email to