Overloads not returning appropriate info. [Field reflunkory]

Alex AJ at gmail.com
Wed Apr 10 19:30:15 UTC 2019


On Tuesday, 9 April 2019 at 21:00:55 UTC, H. S. Teoh wrote:
> On Tue, Apr 09, 2019 at 08:49:17PM +0000, Alex via 
> Digitalmars-d-learn wrote:
>> On Tuesday, 9 April 2019 at 18:56:58 UTC, H. S. Teoh wrote:
> [...]
>> My point has been and is that there is a better way that is 
>> more natural.  I make no claims about anything else. It may be 
>> a cop out to say something that is a tautology but I make the 
>> claim as an emphasis that I believe that it is more true in 
>> this case than others. i.e., D's traits are PITA. Ok, they are 
>> not as bad as some things but I know they can be better since 
>> I have used other languages that have far more logical 
>> reflection(such as C#) than D.
>
> As I said, __traits was never designed to be user-friendly, or 
> even "logical".  It was supposed to be a quick-and-easy way to 
> tap into compiler internals, and std.traits was supposed to be 
> the proper API to introspection.  But std.traits, as it stands, 
> is far, far from what it ought to be, and so we have today's 
> sorry situation.

That's unfortunate... but at least they are generally pretty 
functional. I remember trying to do basic type comparisons in 
C#'s reflection and didn't have the capability(I think it got it 
later but I believe that was the time I left for D).

I can understanding adding traits int he way it was, but at some 
point it has to be brought to the same standard as the rest of 
the language. It's just far too important to neglect. After all, 
Even most of phobos is using meta programming.

> (And on a side note: don't even get me started on is(...) 
> expressions.)
>
> Anyway, since you seem to be passionate about this, this could 
> be your chance of making std.traits what it ought to have been 
> all along, or making a sensible reflection library that can for 
> all practical purposes replace std.traits.
>

The problem is, I believe to do it right, it should be done in 
the compiler(at least some changes) and I know virtually nothing 
about the design and internals, so it would be much more time 
consuming than I'd like). I feel if I were going to go down that 
route I'd rather spend time writing a compiler or getting better 
as functional programming.

> I, for one thing, would appreciate a nicer API to introspection 
> than what we currently have.  One of the main things that drew 
> me to D was its metaprogramming capabilities, and while overall 
> it has been a positive experience, there *are* flies in the 
> ointment like __traits, is(...) expressions, etc..  If you or 
> somebody else could come up with a saner way to do 
> introspection in D, it'd be very much appreciated.

Basically same here. D is one of those love/hate relationships ;/ 
Meta programming is the next stage of evolution of programming. 
It is necessary for simplifying the complex problems of the 
modern computing world. D does have quite a nice syntax for most 
of this and does reasonably well(Although I believe functional 
programming blows D's type system out the water since it deals 
with structural mapping directly without "special cases").







More information about the Digitalmars-d-learn mailing list