View previous topic :: View next topic |
Author |
Message |
Q Guest
|
Posted: Thu Mar 25, 2004 9:55 pm Post subject: Tutorial upload |
|
|
Heya, I just added a tutorial example ( MI using templates ) , and d2html.d seems to choke on it , it times out. Could you erase or invesitagte ?
Preciate it |
|
Back to top |
|
|
jcc7
Joined: 22 Feb 2004 Posts: 657 Location: Muskogee, OK, USA
|
Posted: Thu Mar 25, 2004 11:56 pm Post subject: |
|
|
Hmmm. I guess d2html isn't foolproof. I'll look at the code. I'll resubmit it when I get it to work.
Don't take it personal. d2html isn't perfect. I've deleted it for now. |
|
Back to top |
|
|
jcc7
Joined: 22 Feb 2004 Posts: 657 Location: Muskogee, OK, USA
|
Posted: Fri Mar 26, 2004 12:19 am Post subject: |
|
|
Ummm. It's fixed now. I don't think I changed anything, but suddenly it works. Thanks for contributing. It looks like a great example. |
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Fri Mar 26, 2004 1:38 am Post subject: |
|
|
That tutorial was indeed interesting. But I have a question: where is the documentation for class template syntax of this form given ( class (T) : ... )?
I didn't know this was valid yet. In the D changelog, I found a reference to adding "class template syntax," (0.77) but that's about it. I've searched the newsgroup and the D wiki but couldn't find anything. The D manual doesn't seem to say anything about it either (I didn't find it under class or template).
That syntax is a really nice feature, but I'm at a loss at figuring out why it was introduced without any obvious references to it. Once again, I may have missed something. |
|
Back to top |
|
|
jcc7
Joined: 22 Feb 2004 Posts: 657 Location: Muskogee, OK, USA
|
Posted: Fri Mar 26, 2004 2:03 am Post subject: |
|
|
JJR wrote: | That tutorial was indeed interesting. But I have a question: where is the documentation for class template syntax of this form given ( class (T) : ... )? |
All I can do is refer you to my source.
Templates are very mysterious to me. I think I've written one example and the rest were posted to the newsgroup. I agree that the spec is insufficient to teach templates to a normal person.
Andy's apropos library also has some cool template stuff that might be helpful to study. |
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Fri Mar 26, 2004 2:24 am Post subject: |
|
|
Well... I've played with D templates before and have a general understanding of them, though I'm far from an expert.
The difference in this example was that I've never seen the use of "class(T)" before for class specific template format. Notice there's no use of "template" keyword in the sample even though template features (like instantiation) are being made use of. So I was wondering where the new syntax documentation is to be found?? More examples are interesting, but this won't explain where the syntax came from.
I'll have to try this out in D; I guess it must be valid. I was just suprised to see it. It's amazing to see what features some of these D gurus can come up with. The implementation of multiple inheritance by an almost "recursive" style template scheme really shows off the extent and power of D generics. |
|
Back to top |
|
|
jcc7
Joined: 22 Feb 2004 Posts: 657 Location: Muskogee, OK, USA
|
Posted: Fri Mar 26, 2004 3:14 am Post subject: |
|
|
JJR wrote: | The difference in this example was that I've never seen the use of "class(T)" before for class specific template format. Notice there's no use of "template" keyword in the sample even though template features (like instantiation) are being made use of. So I was wondering where the new syntax documentation is to be found?? More examples are interesting, but this won't explain where the syntax came from. |
This is the most authoritative newsgroup post I've found:
Walter wrote: | If there's only one declaration in a template, and its name matches the
template name, it is 'promoted' to the enclosing scope:
template Foo(T) { class Foo { T a,b; }}
...
void func()
{
Foo(int) x;
x.a = 3;
}
As a shortcut to the above, the template could have been written as:
class Foo(T) { T a,b; } |
|
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Fri Mar 26, 2004 3:41 am Post subject: |
|
|
There it is! Thanks! That explains it perfectly and straight from Walter too. The original method was the method I was familiar with using. I figured the example was using a shortcut of the first but wasn't positive. I just didn't know where it was mentioned. Thanks for digging it up. I'm sorry that you had to find it for me, but it's much appreciated. |
|
Back to top |
|
|
jcc7
Joined: 22 Feb 2004 Posts: 657 Location: Muskogee, OK, USA
|
Posted: Fri Mar 26, 2004 11:09 am Post subject: |
|
|
JJR wrote: | Thanks for digging it up. |
I've gotten pretty good at digging up stuff from the newsgroup. I'm glad I could help. |
|
Back to top |
|
|
jcc7
Joined: 22 Feb 2004 Posts: 657 Location: Muskogee, OK, USA
|
Posted: Sat Apr 17, 2004 5:01 pm Post subject: Problem posting examples |
|
|
As Q noticed with the first post in this topic, d2html can choke on some valid D code. I'm not certain what the specific bug is, but it seems to be related to tabs, CR's, or LF's. It's probably something stupidly easy, but I'm not sure what the problem is.
If someone has a problem viewing a sample that they (or someone else) has added, just let me know (PM me or post in this thread) and I'll work on fixing it. The problem doesn't always occur, but it's happened a few times to me, and I'm going to solve it one way or another. |
|
Back to top |
|
|
|