Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
August 27, 2015 What is this function call operator? | ||||
---|---|---|---|---|
| ||||
If you visit this link: http://dlang.org/phobos/std_traits.html#isCallable There is this paragraph: "Detect whether T is a callable object, which can be called with the function call operator (...)." What is this function call operator? (...) Where can i learn more about it? |
August 27, 2015 Re: What is this function call operator? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Gary Willoughby | On Thursday, 27 August 2015 at 15:18:24 UTC, Gary Willoughby wrote:
> What is this function call operator? (...) Where can i learn more about it?
It is the () at the end of a thing. You can overload it in a struct by writing an opCall member.
|
August 27, 2015 Re: What is this function call operator? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Gary Willoughby | On Thu, 27 Aug 2015 15:18:22 +0000 "Gary Willoughby" <dev@nomad.so> wrote: > If you visit this link: > > http://dlang.org/phobos/std_traits.html#isCallable > > There is this paragraph: > > "Detect whether T is a callable object, which can be called with the function call operator (...)." > > What is this function call operator? (...) Where can i learn more about it? http://dlang.org/operatoroverloading.html#function-call |
August 27, 2015 Re: What is this function call operator? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Gary Willoughby | On Thursday 27 August 2015 17:18, Gary Willoughby wrote: > What is this function call operator? (...) Where can i learn more > about it? http://dlang.org/operatoroverloading.html#function-call http://ddili.org/ders/d.en/operator_overloading.html#ix_operator_overloading.opCall |
August 27, 2015 Re: What is this function call operator? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Thursday, 27 August 2015 at 15:19:15 UTC, Adam D. Ruppe wrote:
> On Thursday, 27 August 2015 at 15:18:24 UTC, Gary Willoughby wrote:
>> What is this function call operator? (...) Where can i learn more about it?
>
> It is the () at the end of a thing. You can overload it in a struct by writing an opCall member.
Sorry, I mean the three dots '...' that seems to be what the documentation is referring to. Also the `isCallable` template uses it.
|
August 27, 2015 Re: What is this function call operator? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Gary Willoughby | On Thursday, 27 August 2015 at 16:03:58 UTC, Gary Willoughby wrote:
> Sorry, I mean the three dots '...' that seems to be what the documentation is referring to. Also the `isCallable` template uses it.
That just means it can take whatever arguments. The documentation is just saying it is callable with anything; the ... is a placeholder. In the template itself, (T...) is a variadic argument list, again meaning it can take anything. (The reason isCallable does it though isn't to actually take multiple arguments, it is so it can take any *kind* of argument; a bit of a hack.)
|
August 27, 2015 Re: What is this function call operator? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Thursday, 27 August 2015 at 16:12:35 UTC, Adam D. Ruppe wrote:
> On Thursday, 27 August 2015 at 16:03:58 UTC, Gary Willoughby wrote:
>> Sorry, I mean the three dots '...' that seems to be what the documentation is referring to. Also the `isCallable` template uses it.
>
> That just means it can take whatever arguments. The documentation is just saying it is callable with anything; the ... is a placeholder. In the template itself, (T...) is a variadic argument list, again meaning it can take anything. (The reason isCallable does it though isn't to actually take multiple arguments, it is so it can take any *kind* of argument; a bit of a hack.)
Ah right, I get it. Thanks.
|
Copyright © 1999-2021 by the D Language Foundation