Proposal: First class types (at compiletime)

Commander Zot no at no.no
Fri Jul 21 15:08:02 UTC 2023


On Friday, 21 July 2023 at 13:51:55 UTC, Paul Backus wrote:
> On Friday, 21 July 2023 at 11:53:23 UTC, Commander Zot wrote:
>> but without having them, we still have to write recursive 
>> template metaprogramming for things that would be expressed 
>> better with normal functions.
>> yes, it wouldn't remove old code, but it would be a huge win 
>> for any new code in my opinion.
>
> Following this design philosophy is how you end up with C++.
>
> What happens if you want to use "old code" and "new code" in 
> the same project? Not only do you have to deal with both 
> approaches, you have to write extra glue code to make them work 
> together.

I'm sorry, but I don't see how you'd have to write any glue code. 
in fact, they work together perfectly fine in my example code. 
but maybe I'm missing something, could you write an example where 
the two would actually clash?

and also: you could say the same thing about CTFE (for value 
types) vs templates to do metaprogramming, yet no one complains 
about that, quite the opposite.

I'm also not suggesting adding type functions or new types to D, 
but automatically lowering the use of a type in an expression 
into typeid(type), and if a TypeInfo is assigned to an alias, 
turn it into it's type again. as I've demonstrated you can do 
this per hand with templates in existing D code without any 
problems (except I couldn't get it to work with the builtin 
TypeInfo, so I've created type_t instead).


More information about the Digitalmars-d mailing list