Porting std.typecons to Phobos 3
Adam Wilson
flyboynw at gmail.com
Sun Nov 10 01:16:40 UTC 2024
On Saturday, 9 November 2024 at 13:47:22 UTC, monkyyy wrote:
> 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.
I chatted with Timon a bit on Discord last night and he is in a
position to get language level tuples into the compiler before V3
ships. He has the implementation mostly done so all he really
needs to do is write up the DIP and get it approved.
One solution proposed was to add Tuple to V3 with a deprecation
warning and no docs to unblock range work, and then remove it
when language tuples land.
>
> 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.
I am intrigued by the concept of a fail-unsafe Option type, but
I'm not sure what the use case would be. When would you want to
explicitly do the unsafe thing? And could you not just achieve
the same result by putting `!` in front of the value presence
check?
More information about the Digitalmars-d
mailing list