--- Comment #2 from SHOO <> 2012-01-16 03:48:12 PST ---
(In reply to comment #1)
> This is a case of outdated documentation.
> From TDPL, p150:
> "If both function and delegate are absent from the literal, the compiler
> automatically detects which one is necessary".

It is an example unlike the specifications(TDPL, p150).

The case is the following situation:

import std.stdio, std.traits;

void main()
    void function() fn = { writeln("function"); };
    static assert(isFunctionPointer!(typeof(fn)));

    void delegate() dg = { writeln("delegate"); };
    static assert(isDelegate!(typeof(dg)));

As noted above, the specifications are applied only when there is a necessary
When there is not a required type, in the case like this time, it should infer
the type of the default.

This resembles the following examples:
import std.traits;

void main()
    byte a = 1; // typeof(a) is byte
    auto b = 1; // typeof(b) is int

    // int cannot implicitly cast to byte.
    static assert (isImplicitlyConvertible!(typeof(b), typeof(a))); // false.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to