January 29, 2011 Re: Nested function declarations | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | Well, I've never used this actually. If I have some external C functions I either put them in a separate module and then import them in when necessary, or wrap them in a struct/class. Whether or not they're of any use in scoped declarations is beyond me. :) |
January 30, 2011 Re: Nested function declarations | ||||
---|---|---|---|---|
| ||||
Posted in reply to dennis luehring | dennis luehring <dl.soluz@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() { } superarray_error.obj(superarray_error) Error 42: Symbol Undefined _D16superarray_error1C3fooMFZi --- errorlevel 1 |
January 31, 2011 Re: Nested function declarations | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dan Olson | On 1/30/11, Dan Olson <zans.is.for.cans@yahoo.com> wrote:
> dennis luehring <dl.soluz@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.
|
Copyright © 1999-2021 by the D Language Foundation