Nested function declarations

Andrej Mitrovic andrej.mitrovich at gmail.com
Mon Jan 31 01:45:31 PST 2011


On 1/30/11, Dan Olson <zans.is.for.cans at yahoo.com> wrote:
> dennis luehring <dl.soluz at gmx.net> writes:
>
>>> They're useful for testing:
>>>
>>> unittest {
>>> 	int foo();
>>> 	static assert (is(ReturnType!foo == int));
>>> }
>>
>> and else? is it worth?
>
> Don't class function declarations have the same issue?  You can declare
> but all you'll get is a link error.  Unless there some way like C++ to
> provide a definition elsewhere.
>
> class C
> {
>    int foo();
> }
>
> void main()
> {
> }
>

I think we've forgotten about D header files. (*.di). If a company
doesn't want to share the source code but allows static linking to its
libraries, providing .di header files is the way to go. The above code
would be valid in a .di file AFAIK.


More information about the Digitalmars-d-learn mailing list