++Phobos

rikki cattermole rikki at cattermole.co.nz
Sun Oct 20 01:47:48 UTC 2019


On 20/10/2019 2:32 PM, Meta wrote:
> 
>> There may also be other restricting factors like the ElementType. Now 
>> for very simple cases this can be done as part of a template 
>> parameter, and more complex ones can go into template constraints like 
>> we do now (since its a more advanced use case).
>>
>> Thing is, if all we want to do is to check if its an input range, we 
>> shouldn't need to use template constraints. They are a very advanced 
>> language feature involving CTFE and language based traits.
>>
>> So if we were to look into rewriting Phobos, shouldn't we make 
>> something that is common and fairly advanced, into something that is 
>> simple to understand? Because that is what I'm arguing for.
> 
> I agree, but the only comparable language that tried to solve this 
> problem is C++, and they ended up with a real monster of a feature. Rust 
> has `impl <trait>`, but it has the same problem as interfaces in that 
> it's not ad hoc.

Swift and Rust can be lumped together (trait + protocols) which I 
believe are loosely based upon ML's signatures. Except that you need to 
have a separate implementation type to join the interface to the 
original type.

In D we don't need to have the secondary implementation to join the two 
together because of our meta-programming capabilities along with CTFE.

Here is the best resource for it we have managed to come up with on 
Discord: https://www.cs.cmu.edu/~rwh/introsml/modules/sigstruct.htm

While we can take inspiration from other languages I do think that we 
are mostly on our own with this. Our idioms and usage of them are 
different enough that we can't just copy other programming languages 
designs for language features for what we are already doing poorly in 
library.


More information about the Digitalmars-d mailing list