Porting std.typecons to Phobos 3

monkyyy crazymonkyyy at gmail.com
Sat Nov 9 13:47:22 UTC 2024


On Saturday, 9 November 2024 at 04:34:20 UTC, Adam Wilson wrote:
> ## Porting `std.typecons` to Phobos 3

To reiterate my position from the planning forums; v2 tuple and 
nullable are some of the worse code in phoboes.

Tuple belong in std.meta right next to aliasSeq, because it could 
be just a seq in a struct

```d
struct Tuple(T...){
   T expand; alias expand this;
}
auto tuple(T...)(T t)=>Tuple!T(t);
auto pair(T,S)(T t,S s)=>Tuple!(T,S)(t,s);
```
(really go try the syntax that falls out of this; it is just this 
simple)

Fundamentally, phoboes v2 works the same way, possibly its the 
only way it even could work in d expect it hides it under 10000 
lines of code.

Likewise nullable but its less exterme(you have to write the op 
overloads) but it should still be a simple struct with a bool 
attached, I think there should be two for the failsafe vs fail 
dangerous usecases.



More information about the Digitalmars-d mailing list