On Monday, 19 January 2026 at 20:03:28 UTC, monkyyy wrote:
On Monday, 19 January 2026 at 15:53:45 UTC, DLearner wrote:
Hi
Is there some reason why tuples are not part of the core language (like, say, struct, which to me is v.similar) but has to be pulled in via ```import std.typecons;```?

its a 30 year old code base, whats in there isnt cleanly mapped to theory

OCaml also has a 30-year-old code base and has had tuples for that long, but it's a different language with different goals, design constraints, and inspirations. Which is the answer to the original question: tuples are provided by a library because D isn't of a language family that cares much about tuples. The usual syntax would also conflict with C's comma operator, although D now mostly treats it as an error:

```d
writeln(1), writeln(2); // ok
writeln((1, 2)); // using the result of a comma expression is not allowed
1, writeln(2); // `1` has no effect
```

OCaml:

```ocaml
# #require "fmt";;
# Format.printf "%a\n" Fmt.int 1, Format.printf "%a\n" Fmt.int 2;;
2
1
- : unit * unit = ((), ())
# Format.printf "%a\n" (Fmt.Dump.pair Fmt.int Fmt.int) (1, 2);;
(1, 2)
- : unit = ()
# 1, Format.printf "%a\n" Fmt.int 1;;
1
- : int * unit = (1, ())
```

For 30 years D has had function overloading that lets it use just `writeln()` with whatever types you give it, whereas to get even this close to a similar example OCaml needs two high-powered libraries and this verbose reconstruction of the provided type. Can this be explained as "its a 30 year old code base, whats in there isnt cleanly mapped to practice"?

Reply via email to