Pattern matching is-expressions

Bruce Carneal bcarneal at
Wed Aug 19 19:03:56 UTC 2020

On Wednesday, 19 August 2020 at 15:51:01 UTC, H. S. Teoh wrote:
> On Wed, Aug 19, 2020 at 01:37:54PM +0000, Dennis via 
> Digitalmars-d wrote: [...]
>> If D were to be rebuilt from the ground up with first-class 
>> types, things could definitely be simplified.
> [...]
> In an ideal world, types would be first class entities that you 
> can pass around and manipulate at will.  Inside templates / 
> CTFE, operations on types would operate directly on the 
> compiler's internal type representation.  If any of these types 
> end up in runtime code, they are replaced with runtime 
> equivalents (typeid, et al).  The same type-manipulating 
> function would be usable both at CTFE and at runtime, with the 
> same semantics.

Yes.  Were types first class citizens we'd have a lot of power 
but backing away from full mutability could be a good thing wrt 
comprehension and correctness.
Monadic forms perhaps.

> Of course, this idealistic scenario may not be very realistic, 
> but moving in its direction could unify quite a number of 
> currently divergent constructs, simplify the language, yet 
> increase expressivity.

Yes.  D language users and implementers are at the forefront of 
practical metaprogramming.  It's great, challenging but great.

Stefan's type functions could be a good addition.  I like the 
parsimonious naming and the move towards full reification.

More information about the Digitalmars-d mailing list