Standardize base types for metaprogramming
Walter Bright
newshound2 at digitalmars.com
Sat Mar 9 20:13:42 UTC 2024
On 2/29/2024 1:16 PM, monkyyy wrote:
> I suggest extending all base types with at least 5 values(with example
> int,float,string):
>
> 1. zero: 0, 0.0., ""
> 2. invalid: max-1, nan, "ERROR"
> 3. onevalue: 1, 1.0, "1"
> 4. negative_value: -1 (signed) max (unsigned), -1, "WARNING"
> 5. min: .min, .min_normal, ""
>
> And then define element op overloads(such as opCmp), toString, toHash for each
> base type
I'm not so sure about this. Is "" really a zero? max-1 are not invalid values
for ints.
As for the op overloads, CTFE to the rescue!
```
hash_t toHash(int); hash_t toHash(float);
```
etc. when you need them.
More information about the dip.ideas
mailing list