On Sunday, 21 January 2024 at 20:13:38 UTC, An Pham wrote:
On Saturday, 20 January 2024 at 15:59:59 UTC, Anonymouse wrote:
I remember reading this was an issue and now I ran into it
myself.
```d
import std.stdio;
void main()
{
auto names = [ "foo", "bar", "baz" ];
void delegate()[]
In Ocaml this would look as:
```d
let names =["foo";"bar";"baz"] in
let funmap = List.map ( fun name -> ( fun () -> print_endline
name)) names in
List.iter ( fun f -> f () ) funmap
;;
~
```
I think in the D-example it is basically one function and not 3.
On Sunday, 21 January 2024 at 20:13:38 UTC, An Pham wrote:
On Saturday, 20 January 2024 at 15:59:59 UTC, Anonymouse wrote:
I remember reading this was an issue and now I ran into it
myself.
```d
import std.stdio;
void main()
{
auto names = [ "foo", "bar", "baz" ];
void delegate()[]
On Saturday, 20 January 2024 at 15:59:59 UTC, Anonymouse wrote:
I remember reading this was an issue and now I ran into it
myself.
```d
import std.stdio;
void main()
{
auto names = [ "foo", "bar", "baz" ];
void delegate()[] dgs;
foreach (name; names)
{
dgs ~= () =>
On Sunday, 21 January 2024 at 14:52:45 UTC, Renato wrote:
On Saturday, 20 January 2024 at 16:53:12 UTC, ryuukk_ wrote:
This is the workaround according to:
https://issues.dlang.org/show_bug.cgi?id=21929#c9
Go used to have the same issue [but they fixed
On Saturday, 20 January 2024 at 16:32:42 UTC, FeepingCreature
wrote:
```
foreach (name; names)
{
dgs ~= ((name) => () => writeln(name))(name);
}
```
lol
Thanks, I'll try that.
On Saturday, 20 January 2024 at 15:59:59 UTC, Anonymouse wrote:
I remember reading this was an issue and now I ran into it
myself.
```d
import std.stdio;
void main()
{
auto names = [ "foo", "bar", "baz" ];
void delegate()[] dgs;
foreach (name; names)
{
dgs ~= () =>
On Saturday, 20 January 2024 at 15:59:59 UTC, Anonymouse wrote:
I remember reading this was an issue and now I ran into it
myself.
```d
import std.stdio;
void main()
{
auto names = [ "foo", "bar", "baz" ];
void delegate()[] dgs;
foreach (name; names)
{
dgs ~= () =>
On Saturday, 20 January 2024 at 15:59:59 UTC, Anonymouse wrote:
I remember reading this was an issue and now I ran into it
myself.
```d
import std.stdio;
void main()
{
auto names = [ "foo", "bar", "baz" ];
void delegate()[] dgs;
foreach (name; names)
{
dgs ~= () =>