Object.toString, toHash, opCmp, opEquals
Walter Bright
newshound2 at digitalmars.com
Fri Apr 26 20:23:16 UTC 2024
On 4/26/2024 7:00 AM, Timon Gehr wrote:
> This is not a theoretical problem either. This kind of introspection would be
> the proper fix for the following issue with std.typecons.Tuple.toString:
>
> ```d
> import std.stdio, std.typecons;
> class C{
> override string toString()=>"correct";
> }
>
> void main(){
> writeln(new C()); // "correct"
> writeln(tuple(new C())); // "Tuple!(C)(const(tt.C))"
> }
> ```
>
> This is also the same issue that prevents tuples with range members from being
> printed properly.
I would like to see "new C()" and "tuple(new C())" mean exactly the same thing.
After all, with the builtin-tuples (not the struct library version) they are the
same thing.
More information about the Digitalmars-d
mailing list