Why is D unpopular, redux.
FeepingCreature
feepingcreature at gmail.com
Tue May 24 15:15:13 UTC 2022
On Tuesday, 24 May 2022 at 13:34:07 UTC, deadalnix wrote:
> On Tuesday, 24 May 2022 at 07:58:13 UTC, FeepingCreature wrote:
>> This is a bit of a controversial topic. Personally I agree
>> that there should be a closure allocated every loop pass, but
>> *every other language* allocates them for the whole
>> stackframe, so...
>
> That is patently false. Javascript? C#?
>
> It is true of some languages, such as python, but this is
> because in python, variable scope is always the top level in
> the function.
Javascript, yes:
```
function foo() {
var cb = null;
for (var i = 0; i < 10; i++) {
if (!cb) {
cb = function() { console.log("Hello World " + i); };
cb();
}
}
cb();
}
foo();
```
Hello World 0
Hello World 10
More information about the Digitalmars-d
mailing list