D dropped in favour of C# for PSP emulator

H. S. Teoh hsteoh at quickfur.ath.cx
Fri May 11 12:28:42 PDT 2012


On Fri, May 11, 2012 at 09:02:52PM +0200, Mehrdad wrote:
> On Friday, 11 May 2012 at 18:53:57 UTC, H. S. Teoh wrote:
> >On Fri, May 11, 2012 at 08:38:41PM +0200, Mehrdad wrote:
> >>On Friday, 11 May 2012 at 18:21:24 UTC, H. S. Teoh wrote:
> >>>Templates are stencils for generating code. There's nothing
> >>>confusing about that.
> >>
> >>
> >>"Stencils for generating code"? _This_??! :O
> >>
> >>  template hasMember(T, string name)
> >>  { enum hasMember = __traits(hasMember, T, name); }
> >>
> >>
> >>Imagine a new user's confusion when seeing something like this.
> >>(Not sure I got it exactly right, but my point is there.)
> >
> >Yes, that's exactly how stencils work. You're essentially
> >generating a declaration of the form:
> >
> >	enum hasMember = ...;
> >
> ><snip>
> 
> 
> That's not how you see it when you're learning though.

Well, it *should* be seen that way. The fact that it isn't means that
the user didn't get a proper introduction to the concept.


> It's more like, I can imagine someone asking these:
> 
> 1. Why the heck do I see "hasMember" twice?

It should be more like, "there's a template keyword, I wonder what it
means -- <look up docs, which has a proper intro to the concept> -- ohhh
so that's what it means.

The fact that this first step failed means the documentation has failed.


> 2. What does this have to do with enums?
> 3. Where is anything getting "returned"???

Return? Why should templates return anything?


> 4. So you mean templates are THINGS?? I thought you needed a
> template SOMETHING, like a template struct, template function,
> etc...

A stencil is a thing. What you stamp out depends on what's in it.


> 5. What the heck is TypeTuple!()? Where's the blueprint?
[...]

Now, TypeTuples are a completely different kettle o' fish. They need
their own proper introduction. :-) Trying to understand TypeTuple before
you understand templates is like trying to run before you can stand.


T

-- 
"A man's wife has more power over him than the state has." -- Ralph Emerson


More information about the Digitalmars-d mailing list