Function prototype + definition in the same file
Steven Schveighoffer
schveiguy at yahoo.com
Tue Sep 25 12:48:11 PDT 2012
On Tue, 25 Sep 2012 15:23:50 -0400, deadalnix <deadalnix at gmail.com> wrote:
> Le 25/09/2012 20:57, Maxim Fomin a écrit :
>> On Tuesday, 25 September 2012 at 17:48:46 UTC, deadalnix wrote:
>>> This is code duplication and is generally considered as a bad
>>> practice. I'm not convinced that the language should be modified to
>>> allow something that is known as bad practice.
>>>
>>> What you need here is a more robust di generator IMO.
>>
>> This is neither a code duplication (there is certain distinction between
>> prototype and body) nor a bad practice - this is a common pattern in C
>> and C++. It is surprising that D cannot do such a simple thing which in
>> addition is not harmless, so there is no sense in depreciating it.
>
> This is code duplication. And this has been considered a problem in
> C/C++ for a while now.
No, it's a prototype.
Note that it's *required* if you want to hide implementation using .di
files.
There is no code involved, it's just generating a symbol reference in the
object file.
-Steve
More information about the Digitalmars-d
mailing list