Topic: template abuse (was: mandate virtual)
Author: Dennis Yelle <dennis51@jps.net>
Date: 2000/11/15 Raw View
Ken Hagan wrote:
[...]
> Is the idiom useful? I think so, particularly in the presence of
> other metaprogramming templates like IF<>. However, I must confess
> that I felt a little disappointed when I first read about it. It
> seemed a shame that someone had found a good use for something
> I'd always considered a defect in the language.
The "defect in the C++ language", if you want to call it that,
is the amazing power of templates. I believe that templates
are much more powerful than Dr. Stroustrup thought they were
when he invented them. This power, combined with the lack
of compile time loops and conditionals in the rest of the language,
leads some people to "abuse" (if you want to call it that) templates
in order to get compile time loops and conditionals. The problem
is that to get compile time loops and conditionals with templates
one must resort to rather complicated and confusing code.
And when a mistake is made, one get very complicated and confusing
error messages.
The proper fix is to put compile time loops and conditionals
directly into the language.
Dennis Yelle
--
I am a computer programmer and I am looking for a job.
There is a link to my resume here:
http://table.jps.net/~vert/
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]
Author: "Ken Hagan" <K.Hagan@thermoteknix.co.uk>
Date: 2000/11/16 Raw View
"Dennis Yelle" <dennis51@jps.net> wrote...
>
> The problem is that to get compile time loops and conditionals with
> templates one must resort to rather complicated and confusing code.
> And when a mistake is made, one get very complicated and confusing
> error messages.
>
> The proper fix is to put compile time loops and conditionals
> directly into the language.
Mmm, yes, but...
Part of the power of abusing templates is that the identifiers for
compile time loops and conditionals live in the same namespaces as
those of the "runtime" code. A dedicated compile-time language would
either be less powerful or would be beset with complicated rules
governing the relationships between names in the two flavours of source
code. With these rules in place, I'm not sure the resulting language
would be any simpler.
However, you can easily prove me wrong by drawing up a formal
proposal. :-)
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]