<div class="gmail_quote">On 26 September 2012 13:09, deadalnix <span dir="ltr"><<a href="mailto:deadalnix@gmail.com" target="_blank">deadalnix@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Le 26/09/2012 10:14, Manu a écrit :<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
On 26 September 2012 02:35, Timon Gehr <<a href="mailto:timon.gehr@gmx.ch" target="_blank">timon.gehr@gmx.ch</a><br></div><div><div class="h5">
<mailto:<a href="mailto:timon.gehr@gmx.ch" target="_blank">timon.gehr@gmx.ch</a>>> wrote:<br>
<br>
    On 09/26/2012 01:29 AM, Timon Gehr wrote:<br>
<br>
        On 09/25/2012 01:53 PM, Manu wrote:<br>
<br>
            So I have this recurring pattern, it's really starting to<br>
            annoy me.<br>
            It stems from the fact that a function prototype and the<br>
            definition can<br>
            not appear in the same file in D (as it can in C/C++)<br>
            Eg,<br>
<br>
            void func(int x); // <-- declaration of function, informs<br>
            type and<br>
            associated names, args, ...<br>
<br>
            //later<br>
            void func(int x) // <-- may be generated with magic (and may<br>
            use the<br>
            prototype declaration for type information as declared by<br>
            the prototype<br>
            above)<br>
            {<br>
                ... do stuff<br>
            }<br>
<br>
            I really need this. Why is it illegal? Is there chance of<br>
            having this<br>
            supported? What are the problems?<br>
            ...<br>
<br>
<br>
        It is illegal because nobody has written code to support it. It<br>
        should be possible to support it. I don't think there are any<br>
        problems<br>
        with the concept.<br>
<br>
<br>
    (The implementation faces some challenges, the following is easy to<br>
    get wrong:<br>
<br>
    module module_;<br>
<br>
    void foo();<br>
<br>
    alias foo alias1;<br>
    static if(is(typeof(alias1))){<br>
         void foo(){}<br>
         alias foo alias2;<br>
    }<br>
<br>
    static assert(__traits(isSame, alias1, alias2));<br>
    static assert(__traits(allMembers, module_).length == 3); // 2<br>
    alias, 1 function definition<br>
    )<br>
<br>
<br></div></div><div class="im">
I'm not sure I understand the point being illustrated here. I don't see<br>
how the aliases are relevant?<br>
</div></blockquote>
<br>
>From a compiler perspective, the example above is hell. That was his point.<br>
<br>
In other terms, supporting such a feature add complexity to the compiler, and it should come with a sufficient benefice to make sense to implement.<br>
</blockquote><div><br></div><div>I can't imagine why the example above is hell, but I know nothing about the compiler.</div><div><br></div><div>I have no idea how the existing bug was implemented, but it needs to be fixed one way or another.</div>
<div>It sounds fairly trivial to me to promote a prototype to a definition if a definition is found later in the same module.</div></div>