Do C++ Programmers Overuse Templates?

M

Matthias Buelow

Is your approach usable for a different language?

This is a bit off-topic but I've done such a thing for a small query
language in a simple embedded Lisp dialect (which I wrote for a C++ app)
-- the query expression is constructed as a (Lisp-)tree by the
application, then massaged and pruned and reordered a bit, and then
evaluated (the nodes are actually function calls, which generate the
appropriate query code or SQL strings, depending on what database type
it is used with.) In case of code output, this is evaluated against
in-memory data of some sorts. In case of SQL text, it's handed off to
the database. The whole thing, including various query exprs, is a bit
over 200 lines (of Lisp). The interesting thing is that it's extensible
to other database schemes by simply augmenting a few primitives.

I can't see how to emulate that with templates; it's obvious it can't be
done as soon as queries need to be constructed at runtime (the
interesting case). Probably the best thing would be to generate trees in
C++ and then simulate the evaluation manually.
 
N

Noah Roberts

What is 'select_command'?
Is it something that can be checked at compile time or is it some
string that the database checks at runtime?

Well, with SQL I don't see how anything can be checked before runtime as
far as whether the types fit. This information has to be checked as the
query is run for it's not until then that you know what type information
the table has. The template stuff constructs the code that attempts the
conversion and throws an exception when a conversion fails.

The real point I was trying to make here is that tuple has uses in
creating interfaces like this. It's not something you use all the time
but it is a generic way of returning or accepting information of
arbitrary quantity and arbitrary types, allowing for some really
powerful devices.
 
A

Andreas Dehmel

Not really -- it all depends on the compiler you're using. The original
post sounded like g++ was the compiler being used -- and I don't know of
a debugger I'd consider very good that works with it (regardless of
whether templates are involved or not). The debugger in Visual Studio
works pretty reasonably on templated code.

If you mean the standard STL containers, then these are well supported
from VS 2005. In earlier versions even that was extremely poor, though,
and that's pretty much the simplest and most obvious case to cater for.
I'm not holding my breath for even extremely basic cases of TMP like
std::foreach ever being halfway supported on debugger level where
they're a royal PITA.



Andreas
 
J

Jerry Coffin

(e-mail address removed)>, (e-mail address removed)
says...

[ ... ]
Which means that trade secret law varies from state to state?
Yes.

(Maybe if you want to sell trade secrets, you have to go to
Nevada, like for a divorce.)

I haven't checked their trade secret law in particular, but I'd guess
exactly the opposite. Given the degree to which the gaming industry
depends on secrecy, they're probably the only state MORE likely than
Texas to institute the death penalty for trade secret violations! :)

[ ... ]
OK. Somehow I'd thought that trademarks were more general. I
presume you're only talking about the part of trademark law
which might conceivably be applied here. A name can certainly
be trademarked, without a drawing.

I'm not certain, but I believe in that case, the "drawing" is some text
that happens to contain the name.

[ ... ]
Hmmm. I didn't know about design patents. In other words, you
can patent other things than just processes and machines.

Yes -- design patents are typically applied to things like the body
style of a car, the designs of shoes, and so on. The protection is much
more limited than for a utility patent though. The term is shorter and
the courts tend to treat them pretty literally, so about all it covers
is exactly what's in the picture(s).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
VetaMcRae
Top