Why is D unpopular, redux.

Walter Bright newshound2 at digitalmars.com
Sat May 21 19:50:35 UTC 2022


On 5/21/2022 4:39 AM, Timon Gehr wrote:
> https://forum.dlang.org/post/sk4v9b$2apt$1@digitalmars.com

That's a good list, thank you!


> Yes, probably needs a DIP. Seems somewhat tricky to get just right. The 
> mechanism should be simple and should e.g. allow the wrapping of a built-in 
> slice within a templated struct with the same typing behavior.
> 
> A pretty simple feature that seems to do the job would be something like:
> 
> ```d
> @structuralSubtyping
> struct Slice(T){
>      T[] payload;
> }
> ```
> 
> Then whenever you need to evaluate a subtyping relationship between multiple 
> instantiations of the same @structural-annotated templated type, you check that 
> the field layout matches (including field names) and that all field types are 
> subtypes of their new type.
> 
> There should be a way to do custom introspection (subtype constraints).
> 
> ```d
> @structuralSubtyping!condition
> struct Slice(T){
>      T[] payload;
> }
> ```
> 
> Where "condition" is passed both instantiated types with full qualifiers and can 
> do additional checks to possibly maintain typing invariants that are not tracked 
> by D's type system alone.
> 
> There should also be an unsafe escape hatch to exclude certain members from the 
> automated field layout checks, but maybe void* and void[n] are good enough for 
> this.
> 
> Finally, the magic "strip qualifiers when passing a slice to a function" rule 
> should be applied to template types with `@structuralSubtyping`.

I'm afraid there's not enough here for me to understand it.


More information about the Digitalmars-d mailing list