Overloads not returning appropriate info. [Field reflunkory]

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Apr 9 21:00:55 UTC 2019


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.

(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.

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.


T

-- 
Life would be easier if I had the source code. -- YHL


More information about the Digitalmars-d-learn mailing list