Get constructor for a class

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Sep 13 08:15:07 PDT 2013


On Fri, Sep 13, 2013 at 04:16:30PM +0200, simendsjo wrote:
> On Friday, 13 September 2013 at 14:02:15 UTC, Gary Willoughby wrote:
[...]
> >A lot of the traits stuff is very confusing, i think a lot of it
> >is still being finalised and in development. I'm working on a
> >project using a lot of traits stuff and it's doing my head in. I
> >wish there was better documentation. e.g. what is 'func' in the
> >code above? i'm using it successfully but i've no idea what it is.
> 
> I know what you mean. Have been using quite some __traits and is(),
> and I still have to look up the syntax for is() all the time, and
> experiment with both trying to find the edge-cases.
[...]

The syntax for is() is one gigantic mess. It does work, but it's not
pretty. IIRC Walter admitted that it could do with some cleanup, but
it's a bit too late now since too much code relies on its quirks.

As for __traits, I believe the intention was that it wasn't meant for
end-user consumption, but for Phobos to be able to access compiler
internals. As such, it only provides the bare minimum for Phobos to be
able to work, so there are a lot of quirks and edge cases. I was quite
dismayed yesterday to discover that "parameter type tuples" are actually
different from the usual "type tuples", and don't even behave
consistently with foreach (they masquerade as type tuples w.r.t.
foreach, and there's weird special-casing for 1-element slices of them,
e.g. for __traits(identifier...)). I don't know what's the rationale for
this strange design, but it sure looks like it was just a quick hack to
make Phobos work rather than anything carefully thought out.

Personally, I would just stick with the Phobos interfaces, and file bugs
(or pull requests) if the existing interfaces aren't sufficient for your
needs.


T

-- 
Let X be the set not defined by this sentence...


More information about the Digitalmars-d-learn mailing list