D isn't the only language with janky closure semantics

Paul Backus snarwin at gmail.com
Mon Sep 1 03:29:10 UTC 2025


On Saturday, 30 August 2025 at 17:20:18 UTC, Konstantin wrote:
> On Friday, 29 August 2025 at 22:28:17 UTC, H. S. Teoh wrote:
>>
>
> Why are delegates in D an aggregate of a context pointer and a 
> function pointer, not like C++'s lambdas (anonymous class with 
> `operator()`)?

Presumably because it allows `T delegate(U)` to be a single 
concrete type, and eliminates the need to use either templates or 
a wrapper like C++'s `std::function` to pass delegates around at 
runtime.


More information about the Digitalmars-d mailing list