<div class="gmail_quote">On 26 September 2012 02:35, Timon Gehr <span dir="ltr"><<a href="mailto:timon.gehr@gmx.ch" target="_blank">timon.gehr@gmx.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On 09/26/2012 01:29 AM, Timon Gehr wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 09/25/2012 01:53 PM, Manu wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
So I have this recurring pattern, it's really starting to annoy me.<br>
It stems from the fact that a function prototype and the 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 type and<br>
associated names, args, ...<br>
<br>
//later<br>
void func(int x) // <-- may be generated with magic (and may use the<br>
prototype declaration for type information as declared by the prototype<br>
above)<br>
{<br>
   ... do stuff<br>
}<br>
<br>
I really need this. Why is it illegal? Is there chance of having this<br>
supported? What are the problems?<br>
...<br>
</blockquote>
<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 problems<br>
with the concept.<br>
</blockquote>
<br></div></div>
(The implementation faces some challenges, the following is easy to 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 alias, 1 function definition<br>
)<br>
</blockquote></div><br><div>I'm not sure I understand the point being illustrated here. I don't see how the aliases are relevant?</div><div>Is an alias to a prototype somehow different than an alias to a definition?</div>
<div><br></div><div>Shouldn't the discovery of a function definition within the same file as a pre-declared prototype just promote the prototype to a full definition? They are the same symbol, just that one instance adds the definition.</div>