What are some use cases where struct opCall would be useful?
As far as I know, this capability is unique to D. Do any other languages support this?
Thread overview | ||||||
---|---|---|---|---|---|---|
|
6 days ago struct opCall - use cases | ||||
---|---|---|---|---|
| ||||
6 days ago Re: struct opCall - use cases | ||||
---|---|---|---|---|
| ||||
Posted in reply to Brother Bill | On Fri, Aug 08, 2025 at 02:11:48PM +0000, Brother Bill via Digitalmars-d-learn wrote: > What are some use cases where struct opCall would be useful? When the struct is intended to be a function object. I.e., a type that abstracts a function. > As far as I know, this capability is unique to D. Do any other languages support this? C++. Not that that's a good example of what a language should do. :-D T -- What did the epileptic have for lunch? Seizure salad. |
6 days ago Re: struct opCall - use cases | ||||
---|---|---|---|---|
| ||||
Posted in reply to Brother Bill | On Friday, 8 August 2025 at 14:11:48 UTC, Brother Bill wrote: >What are some use cases where struct opCall would be useful? Glue code, someone was fairly good about trying to hide all implementation details, contrary to popular belief, syntax sugar has syntactic meaning. 95% of the base cases of the fundamental syntax are "scary hidden control flow" escape hatches. In the most exterme cases you can nest structs with opDispatch, opCall is fairly mild mannered bit of meta programming hacking. |
6 days ago Re: struct opCall - use cases | ||||
---|---|---|---|---|
| ||||
Posted in reply to Brother Bill | On Friday, 8 August 2025 at 14:11:48 UTC, Brother Bill wrote: >What are some use cases where struct opCall would be useful? I've used it my Lua wrapper to give it a slightly more natural interface when calling Lua functions from D: https://github.com/BradleyChatha/lumars/blob/master/source/lumars/function_.d#L138 |