473,503 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Are C++ templates a precompiler thing?

Well apparently not since one can step thru template code with a debugger.
But if I was willing to make the concession on debugging, templates would be
strictly a precompiler thing? I have a feeling the answer I'm going to get
back will be "no, because templates have taken on a life of their own since
their original conception and now also affect compiler implementation"
(read: not good, IMO.

John
Jun 11 '07
104 4447
On Jun 12, 1:40 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"James Kanze" <james.ka...@gmail.comwrote in message
Certainly others are using OE. What's up with mine, if so
then, I have no idea.
You don't know how to configure it? Microsoft is generally
pretty good for internationalization issues.
I do think news should be 7-bit ASCII though when the posts
are in English.
What you think and what things actually are are two different
things. The general tendancy is for everything on the Internet
to be in UTF-8 (although we still have a long way to go). Are
you suggesting that people born in other countries should be
required to change their name in order to participate here? Or
their address?

And the problem doesn't seem to be the characters themselves,
because I modified my .sig in one posting, to remove them. The
problem is, I think, one of the headers, probably inserted by
Google.

--
James Kanze (GABI Software) mailto:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Jun 12 '07 #51
On Jun 13, 12:16 am, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
(I can then make a conforming implementation using preprocessor-based
templates?).
Well I'm not really sure what you mean by 'preprocessor-based
templates'.

By "preprocessor-based templates", in this post's context, I
mean "implementing templates (not the conforming kind) via
modification of a preprocessor.
Well, if they're not conforming, then it's a moot
point as to what the standard says about it :)

Jun 12 '07 #52
On Jun 12, 2:06 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
I know what information I am seeking. And that is the plausibility of
implementing templates (not the C++ kind) via modification of the
preprocessor (as a modest improvement over the "macro-ised" implementation
technique).
If you don't mean C++ templates, when talking about C++, you
really have to find a different word. And describe exactly what
you mean. All I can say is that in the past, there was an
effort to do something similar, using <generic.h>; anyone who
has actually used it understands why C++ decided to add
templates. The concept really only works well if it is
integrated into the language.

--
James Kanze (GABI Software) mailto:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Jun 12 '07 #53
On Jun 12, 1:40 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"James Kanze" <james.ka...@gmail.comwrote in message
news:11********************@a26g2000pre.googlegrou ps.com...
On Jun 12, 2:06 am, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"Gianni Mariani" <gi3nos...@mariani.wswrote in message
[...]
If you refer to cfront then that's not true. The output from cfront
just
used C as the "assembler".
HP hacked a preprocessor (PCC) to provide probably the earliest template
implementation for C++.
"HP never hacked the C++ preprocessor to provide templates. Get
your facts straight."
Texas Instruments. Decus C preprocessor. 1990. My bad. The
fact that someone did it though is the important thought.
Did what? <generic.hpredates that by a lot. It proved to be
unusable. Real templates (albeit very buggy) first appeared in
CFront 3.0 (from AT&T), in 1989, I think.
Can you create a macro to tell you if a type converts to
another type or if a type has a particular member or change
behaviour of a function template for a specific type (I call
this the C++ come-from).
If I just need to create containers and that is my only
interest in using templates, the specialized stuff you're
doing is, well specialized!
"I've actually used <generic.hin production code. For
containers and smart pointers. It doesn't work. That's why
templates were invented, because a pre-processor based solution
doesn't work."
Once you get out of the box of thinking that C++ templates are the only
kind, things get easier.
I'm aware of templates in Java (although I've not used them
yet), and in Ada (where they're called generics). There are
lots of alternatives to C++ templates, and there are things in
C++ templates that I'm not too happy with. But they do beat any
macro based solution, by far. I've actually used both, so I'm
in a real position to know.

--
James Kanze (GABI Software) mailto:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Jun 12 '07 #54
On Jun 12, 1:40 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"James Kanze" <james.ka...@gmail.comwrote in message
news:11**********************@j4g2000prf.googlegro ups.com...
On Jun 11, 11:11 am, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"Robbie Hatley" <bogus.addr...@no.spamwrote in message
news:Yh*******************@fe02.news.easynews.com. ..
"JohnQ" wrote:
>Are C++ templates a precompiler thing?
By "precompiler", I presume you mean the C/C++ preprocessor?
That's not *any* kind of "compiler", pre-, post-, or otherwise.
It's just a text editor.
Templates are a part of the C++ language. They are not
preprocessor macros.
Can they be implemented that way though (early work did exactly that).
"Then they're not templates."
Not "C++ templates" you mean.
Not templates. C++ didn't invent templates; they were present
in languages long before C++ added them. In fact, C++ added
them mainly because the earlier macro-based solution didn't
work.
"Basically, templates were added to
the language in CFront 3.0 because macros (<generic.h>) were
found to be insufficient."
YMMV.
Whatever. The fact remains that a macro based solution was
tried, over a long period of time, by many people of many
different persuations, and was found not to be workable. So the
authors of C++ looked around, and saw that the template based
solution in Ada and Eiffel did work, and "invented" something
similar. Not identical, because of course Ada and Eiffel are
different languages, with a different philosophy, and their
version of templates wouldn't fit in nicely with that of C++.
But the fact remains that templates were added to C++ because
they worked well in other languages, and the pre-processor based
solution which was present before didn't work.

--
James Kanze (GABI Software) mailto:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Jun 12 '07 #55
JohnQ wrote:
>
"Dizzy" <di***@roedu.netwrote in message news:f4**********@aioe.org...
>JohnQ wrote:
>>That's my definition of templates: a typing saver, patterned
text-replacement. Anything else is a C++-ism (extension of the original
concept). You're assuming the C++ definition is the gold cow standard of
all template definition. That's in-the-box-thinking (paradigmic).

Then you are offtopic to the subject of this discussion. You throw a
question like "Are _C++ templates_ a precompiler thing" then you
transform it to "my definition of templates a typing saver... anything
else is a C++-ism". You see that there is no logic there don't you?

"C++ templates" are "C++ templates" and not your definition of them (and
they are C++-isms my definition).

I know what information I am seeking. And that is the plausibility of
implementing templates (not the C++ kind) via modification of the
preprocessor (as a modest improvement over the "macro-ised" implementation
technique). If the answer to the original question was "yes", that would
have made things appear more plausible. Since I'm not enamoured with the
feature set of C++ templates that require templates to be integrated into
the compiler, even though the answer was "no" to the original question,
the plausibility of doing templates (not the C++ kind) with a modified
precompiler remains.
Certainly you can implement a very limited template functionality using only
the preprocessor (as you could probably translate a limited feature C++ to
C using only the preprocessor or few extensions to it).

--
Dizzy

Jun 12 '07 #56

"James Kanze" <ja*********@gmail.comwrote in message
news:11**********************@d30g2000prg.googlegr oups.com...
On Jun 12, 1:40 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"James Kanze" <james.ka...@gmail.comwrote in message
Certainly others are using OE. What's up with mine, if so
then, I have no idea.
"You don't know how to configure it? Microsoft is generally
pretty good for internationalization issues."

I've never had to venture past the defaults until now perhaps.
I do think news should be 7-bit ASCII though when the posts
are in English.
"What you think and what things actually are are two different
things. The general tendancy is for everything on the Internet
to be in UTF-8 (although we still have a long way to go). Are
you suggesting that people born in other countries should be
required to change their name in order to participate here? Or
their address?"

When in Rome... And when I post in the Chinese groups, I promise to use only
Chinese.

"And the problem doesn't seem to be the characters themselves,
because I modified my .sig in one posting, to remove them. The
problem is, I think, one of the headers, probably inserted by
Google."

What if the header is being inserted because something notices non-7-bit
ASCII characters?

John
Jun 12 '07 #57

"James Kanze" <ja*********@gmail.comwrote in message
news:11**********************@d30g2000prg.googlegr oups.com...
On Jun 12, 1:40 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"James Kanze" <james.ka...@gmail.comwrote in message
news:11********************@a26g2000pre.googlegrou ps.com...
On Jun 12, 2:06 am, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"Gianni Mariani" <gi3nos...@mariani.wswrote in message
[...]
If you refer to cfront then that's not true. The output from cfront
just
used C as the "assembler".
HP hacked a preprocessor (PCC) to provide probably the earliest template
implementation for C++.
"HP never hacked the C++ preprocessor to provide templates. Get
your facts straight."
Texas Instruments. Decus C preprocessor. 1990. My bad. The
fact that someone did it though is the important thought.
"Did what?"

Hacked an existing preprocessor to implement templates (and exceptions also,
BTW).

" <generic.hpredates that by a lot. It proved to be
unusable. Real templates (albeit very buggy) first appeared in
CFront 3.0 (from AT&T), in 1989, I think."

Unusable to do all the advanced things that "the language within a language"
C++ templates do, yes. And again, it's just some constructs in there that
can be useful. It's not an end.
Can you create a macro to tell you if a type converts to
another type or if a type has a particular member or change
behaviour of a function template for a specific type (I call
this the C++ come-from).
If I just need to create containers and that is my only
interest in using templates, the specialized stuff you're
doing is, well specialized!
"I've actually used <generic.hin production code. For
containers and smart pointers. It doesn't work. That's why
templates were invented, because a pre-processor based solution
doesn't work."
Once you get out of the box of thinking that C++ templates are the only
kind, things get easier.
"I'm aware of templates in Java (although I've not used them
yet), and in Ada (where they're called generics). There are
lots of alternatives to C++ templates, and there are things in
C++ templates that I'm not too happy with. But they do beat any
macro based solution, by far. I've actually used both, so I'm
in a real position to know."

I've used both and now have much better code since abandoning C++ templates
(and yeah, I could refactor the current code back into C++ template syntax
and some of y'all would say it is arguably better, but actually it would be
pretty much the same, only the syntax would be a little different). I tend
to be complexity-averse. YMMV.

John
Jun 12 '07 #58

"James Kanze" <ja*********@gmail.comwrote in message
news:11**********************@d30g2000prg.googlegr oups.com...
On Jun 12, 2:06 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
I know what information I am seeking. And that is the plausibility of
implementing templates (not the C++ kind) via modification of the
preprocessor (as a modest improvement over the "macro-ised" implementation
technique).
"If you don't mean C++ templates, when talking about C++, you
really have to find a different word."

Well C++ didn't invent the word 'template'.

" And describe exactly what
you mean. All I can say is that in the past, there was an
effort to do something similar, using <generic.h>; anyone who
has actually used it understands why C++ decided to add
templates."

The generic.h thing is just a starting point, not an end all.

"The concept really only works well if it is integrated into the language."

Only if by "concept" you mean "all the bells and whistles of C++ templates".

John
Jun 12 '07 #59

"Old Wolf" <ol*****@inspire.net.nzwrote in message
news:11**********************@z28g2000prd.googlegr oups.com...
On Jun 13, 12:16 am, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
>(I can then make a conforming implementation using preprocessor-based
templates?).
Well I'm not really sure what you mean by 'preprocessor-based
templates'.

By "preprocessor-based templates", in this post's context, I
mean "implementing templates (not the conforming kind) via
modification of a preprocessor.

Well, if they're not conforming, then it's a moot
point as to what the standard says about it :)
I'll have to investigate the TI stuff some more to see what additional
features they got by modifying a preprocessor to implement templates. My
impression is that they got pretty close to the Stroustrup description back
then and that's probably all the functionality I need (or even less!).

John
Jun 12 '07 #60

"James Kanze" <ja*********@gmail.comwrote in message
news:11**********************@g37g2000prf.googlegr oups.com...
On Jun 12, 1:40 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"James Kanze" <james.ka...@gmail.comwrote in message
news:11**********************@j4g2000prf.googlegro ups.com...
On Jun 11, 11:11 am, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"Robbie Hatley" <bogus.addr...@no.spamwrote in message
news:Yh*******************@fe02.news.easynews.com. ..
"JohnQ" wrote:
>Are C++ templates a precompiler thing?
By "precompiler", I presume you mean the C/C++ preprocessor?
That's not *any* kind of "compiler", pre-, post-, or otherwise.
It's just a text editor.
Templates are a part of the C++ language. They are not
preprocessor macros.
Can they be implemented that way though (early work did exactly that).
"Then they're not templates."
Not "C++ templates" you mean.
"Not templates. C++ didn't invent templates; they were present
in languages long before C++ added them. In fact, C++ added
them mainly because the earlier macro-based solution didn't
work."

You keep saying that, but of course it isn't true, for my containers and
algos work just fine. You're thinking about some pre-existing implementation
that had failed for any of a number of reasons, not the least of which is
that if you define "successful" as being all things to all people all of the
time, then something that doesn't include the kitchen sink is labeled a
failure.
"Basically, templates were added to
the language in CFront 3.0 because macros (<generic.h>) were
found to be insufficient."
YMMV.
"Whatever. The fact remains that a macro based solution was
tried, over a long period of time, by many people of many
different persuations, and was found not to be workable."

Seems to work just fine for me.

"So the
authors of C++ looked around, and saw that the template based
solution in Ada and Eiffel did work, and "invented" something
similar. Not identical, because of course Ada and Eiffel are
different languages, with a different philosophy, and their
version of templates wouldn't fit in nicely with that of C++.
But the fact remains that templates were added to C++ because
they worked well in other languages, and the pre-processor based
solution which was present before didn't work."

It depends on your requirements of the concept. If you like implementing
technologies which give "10% more functionality for 90% more complexity",
power to ya. I'll stick with the 80% solution that is simple and elegant.

John
Jun 12 '07 #61
On 12 Jun, 12:40, "JohnQ" <johnqREMOVETHISprogram...@yahoo.comwrote:
"Gavin Deane" <deane_ga...@hotmail.comwrote in message

news:11**********************@j4g2000prf.googlegro ups.com...
JohnQ: Oh no - I don't mean things that complex or specialised. What I
meant to ask was, "Can a limited subset of template capabilities be
implemented as straight text substitution? The subset is limited to
only those things that can be implemented as straight text
substitution."

That's my definition of templates: a typing saver, patterned
text-replacement. Anything else is a C++-ism (extension of the original
concept). You're assuming the C++ definition is the gold cow standard of all
template definition. That's in-the-box-thinking (paradigmic).
No, I'm assuming that *in this newsgroup* the C++ definition is the
only one applicable - if someone uses the term "C++ templates" they
mean "templates as defined by the C++ standard". Not an unreasonable
assumption I think. What other definitions of "template" might exist
in the wider programming field and what their relative merits might be
against the C++ definition is entirely off-topic in this group and so
of no concern whatsoever when I am posting here.

The subject of your original post included the term "C++ templates".
Are you aware that in standard C++, "template" has a precise and well-
defined meaning? And that, with standard C++ being the topic of this
newsgroup, anyone who reads the term "C++ templates" here would be
perfectly justified in thinking that the person who wrote it meant
"templates as defined by the C++ standard"? Can you not see that, in
this forum, if you want the word "template" to mean something else,
the onus is 100% on you to provide your definition of "template" at
the outset? (Or better still, choose a different word).

And you still appear to be asking the rather pointless and self-
answering question as I paraphrased above.

Gavin Deane

Jun 12 '07 #62

"Gavin Deane" <de*********@hotmail.comwrote in message
news:11**********************@x35g2000prf.googlegr oups.com...
On 12 Jun, 12:40, "JohnQ" <johnqREMOVETHISprogram...@yahoo.comwrote:
>"Gavin Deane" <deane_ga...@hotmail.comwrote in message

news:11**********************@j4g2000prf.googlegr oups.com...
JohnQ: Oh no - I don't mean things that complex or specialised. What I
meant to ask was, "Can a limited subset of template capabilities be
implemented as straight text substitution? The subset is limited to
only those things that can be implemented as straight text
substitution."

That's my definition of templates: a typing saver, patterned
text-replacement. Anything else is a C++-ism (extension of the original
concept). You're assuming the C++ definition is the gold cow standard of
all
template definition. That's in-the-box-thinking (paradigmic).

No, I'm assuming that *in this newsgroup* the C++ definition is the
only one applicable - if someone uses the term "C++ templates" they
mean "templates as defined by the C++ standard". Not an unreasonable
assumption I think. What other definitions of "template" might exist
in the wider programming field and what their relative merits might be
against the C++ definition is entirely off-topic in this group and so
of no concern whatsoever when I am posting here.

The subject of your original post included the term "C++ templates".
Are you aware that in standard C++, "template" has a precise and well-
defined meaning? And that, with standard C++ being the topic of this
newsgroup, anyone who reads the term "C++ templates" here would be
perfectly justified in thinking that the person who wrote it meant
"templates as defined by the C++ standard"? Can you not see that, in
this forum, if you want the word "template" to mean something else,
the onus is 100% on you to provide your definition of "template" at
the outset? (Or better still, choose a different word).

And you still appear to be asking the rather pointless and self-
answering question as I paraphrased above.
I did mean "C++ templates" with the original post. I recognize them as some
kind of departure from a more generic (no pun intended) meaning. Perhaps
that more generic thing is what I would like to implement with the modified
preprocessor (though I'm not sure it would buy me much over the macro-ised
technique).

John
Jun 12 '07 #63
On 12 Juni, 15:31, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"James Kanze" <james.ka...@gmail.comwrote in message

news:11**********************@d30g2000prg.googlegr oups.com...
On Jun 12, 2:06 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
I know what information I am seeking. And that is the plausibility of
implementing templates (not the C++ kind) via modification of the
preprocessor (as a modest improvement over the "macro-ised" implementation
technique).

"If you don't mean C++ templates, when talking about C++, you
really have to find a different word."

Well C++ didn't invent the word 'template'.
When in Rome...

Sorry, couldn't resist.

--
Erik Wikström

Jun 12 '07 #64
JohnQ wrote:
....
To me, "templates" means the kind of thing the preprocessor does (text
substitution) and using it to generate typed code.
That's only one of the things that templates are about.

C++ templates allow you to:

Change behaviour for different types.

Compute compile time constants (like find first set bit) etc.

Force compile time errors when various assumptions are invalid.

Allows extensibility by the application through overloading and
specialization.

.... just to name a few ...

Macros are almost impossible to debug because of the way they work. It
is surprising that after so many years of using the preprocessor,
debuggers can't single step through macros but alas, they can't. C++
templates however are well supported by debuggers in comparison.

While you may like to think of templates as a facncy pre-processor, in
C++ templates are a more substantial and provide a "meta programmming"
paradigm.

As I explained earlier, one example where it worked by simplification of
the code was the mapping of types to ints for reading DXF files.
Without templates, it would have been very tedious to map 1000+
operations. With C++ templates, it was cut-paste relevant table in the
docs, decorate it with a few templates, viola. Extensibility is easy as
well because as the file format expands, there is a direct correlation
to the docs and so it will be simply a matter of adding a few more types
to the header file.

If you want to talk about C++ the standard (which is what we do here),
you need to understand that templates are a more extensive meta
programming feature. While you yourself may not want to use it, it is
part of the standard and is used in a much more extensive way.
Jun 12 '07 #65
JohnQ wrote:
....
When I say "containers" I mean the whole ball of wax:
containers/iterators/algorithms, things like smart pointers etc.
Try the smart pointer thing in macros. Specifically, you do you
implement assignment of one smart pointer type to another smart pointer
type without using templates.

i.e. Ptr<Base *ptr = derived_smart_pointer.

... It's all
very basic stuff that preprocessor templates can handle. And those are "the
general case". No need to make everything complex IMO. Make special things
for the special cases and don't impact the general case is my motto.
Sometimes I need a truck to bring things home from Home Depot, so I rent
one. Most times I just use my car. I wouldn't want to drive a truck all the
time, or purchase one, just because I need one once a year.
OK. You think that C++ templates are too complex to learn, they're more
like the truck than the car.

That's nice, thank you for your input but you're a few years too late.
C++ templates are not going away any time soon. Go use D or Java.
>
>>>...
Again, I whole-heartedly disagree.
That you disagree is great. Don't stop there, do tell us of your
reasoning.
I limit what templates can do by requiring of them that they can be
implemented simply.
That's a "reason" ?

You clipped the context, so here it is:

"Templates do have a learning curve. You do have to think of your code
in a more generic fashion."

To which I'll respond:

Templates shouldn't be (and are not) difficult at all. It's the C++
"almighty powerful" ones that can be "hard" (take time to learn).
This discussion then is OT here. This forum is for discussing C++ as it
is defined in the standard. If you wish to change the standard
comp.std.c++ is the proper forum. I suggest they're not going to bother
much if you proclaim C++ templates are a mess and you want to use macros
so you might want to save it, it's up to you.
Jun 12 '07 #66

"Gianni Mariani" <gi*******@mariani.wswrote in message
news:46***********************@per-qv1-newsreader-01.iinet.net.au...
JohnQ wrote:
...
>To me, "templates" means the kind of thing the preprocessor does (text
substitution) and using it to generate typed code.

That's only one of the things that templates are about.

C++ templates allow you to:

Change behaviour for different types.

Compute compile time constants (like find first set bit) etc.

Force compile time errors when various assumptions are invalid.

Allows extensibility by the application through overloading and
specialization.

... just to name a few ...

Macros are almost impossible to debug because of the way they work.
It is surprising that after so many years of using the preprocessor,
debuggers can't single step through macros but alas, they can't. C++
templates however are well supported by debuggers in comparison.

Just expand the preprocessor template and debug it. Problem solved.
>
While you may like to think of templates as a facncy pre-processor, in C++
templates are a more substantial and provide a "meta programmming"
paradigm.
Understood. It's overkill for my needs. But I'll still use them if need be
(but in a very light way).

John
Jun 13 '07 #67

"Gianni Mariani" <gi*******@mariani.wswrote in message
news:46***********************@per-qv1-newsreader-01.iinet.net.au...
JohnQ wrote:
...
>When I say "containers" I mean the whole ball of wax:
containers/iterators/algorithms, things like smart pointers etc.

Try the smart pointer thing in macros. Specifically, you do you implement
assignment of one smart pointer type to another smart pointer type without
using templates.

i.e. Ptr<Base *ptr = derived_smart_pointer.

>... It's all
very basic stuff that preprocessor templates can handle. And those are
"the
general case". No need to make everything complex IMO. Make special
things
for the special cases and don't impact the general case is my motto.
Sometimes I need a truck to bring things home from Home Depot, so I rent
one. Most times I just use my car. I wouldn't want to drive a truck all
the
time, or purchase one, just because I need one once a year.

OK. You think that C++ templates are too complex to learn, they're more
like the truck than the car.
I used them for years before I knew how detrimental they were to
maintainable code. Now that I've gotten back to basics, I can use templates
without getting into trouble with them. That is, I know what NOT to do with
them.
>
That's nice, thank you for your input but you're a few years too late. C++
templates are not going away any time soon. Go use D or Java.
>>
>>>>...
>Again, I whole-heartedly disagree.
That you disagree is great. Don't stop there, do tell us of your
reasoning.
I limit what templates can do by requiring of them that they can be
implemented simply.
That's a "reason" ?

You clipped the context, so here it is:

"Templates do have a learning curve. You do have to think of your code
in a more generic fashion."

To which I'll respond:

Templates shouldn't be (and are not) difficult at all. It's the C++
"almighty powerful" ones that can be "hard" (take time to learn).

This discussion then is OT here. This forum is for discussing C++ as it
is defined in the standard.
The preprocessor is part of the standard also.
If you wish to change the standard comp.std.c++ is the proper forum.
It's probably not worth fixing. Easier to create something new and put the
old stuff in maintenance mode.
I suggest they're not going to bother much if you proclaim C++ templates
are a mess and you want to use macros so you might want to save it, it's
up to you.
That's why I'm investigating hacking a preprocessor to do a templates
implementation. I'm not convinced that I need any more power than the text
substitution of the existing preprocessors though. I'm thinking that the
only thing it would get me is not having to type all those backslashes. Oh
yeah, and a mechanism to control template generation. Neither needed, but it
would be more convenient and elegant.

John
Jun 13 '07 #68
On Jun 12, 3:31 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"James Kanze" <james.ka...@gmail.comwrote in message
[...]
" <generic.hpredates that by a lot. It proved to be
unusable. Real templates (albeit very buggy) first appeared in
CFront 3.0 (from AT&T), in 1989, I think."
Unusable to do all the advanced things that "the language
within a language" C++ templates do, yes.
Unusable for even the simplest container classes.

--
James Kanze (GABI Software, from CAI) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Jun 13 '07 #69
On Jun 12, 3:31 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"James Kanze" <james.ka...@gmail.comwrote in message
news:11**********************@g37g2000prf.googlegr oups.com...
On Jun 12, 1:40 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"James Kanze" <james.ka...@gmail.comwrote in message
news:11**********************@j4g2000prf.googlegro ups.com...
On Jun 11, 11:11 am, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"Robbie Hatley" <bogus.addr...@no.spamwrote in message
>news:Yh*******************@fe02.news.easynews.com ...
"JohnQ" wrote:
Are C++ templates a precompiler thing?
By "precompiler", I presume you mean the C/C++ preprocessor?
That's not *any* kind of "compiler", pre-, post-, or otherwise.
It's just a text editor.
Templates are a part of the C++ language. They are not
preprocessor macros.
Can they be implemented that way though (early work did exactly that).
"Then they're not templates."
Not "C++ templates" you mean.
"Not templates. C++ didn't invent templates; they were present
in languages long before C++ added them. In fact, C++ added
them mainly because the earlier macro-based solution didn't
work."
You keep saying that, but of course it isn't true, for my
containers and algos work just fine.
I keep saying because it is true. Macro based generic classes
require an unacceptable amount of time and effort to use and
maintain. I've been there; I've had to maintain stuff written
using the preprocessor. And I'm not alone.

--
James Kanze (GABI Software, from CAI) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Jun 13 '07 #70
On 2007-06-13 12:31, JohnQ wrote:
"Gianni Mariani" <gi*******@mariani.wswrote in message
news:46***********************@per-qv1-newsreader-01.iinet.net.au...
>JohnQ wrote:
...
>>To me, "templates" means the kind of thing the preprocessor does (text
substitution) and using it to generate typed code.

That's only one of the things that templates are about.

C++ templates allow you to:

Change behaviour for different types.

Compute compile time constants (like find first set bit) etc.

Force compile time errors when various assumptions are invalid.

Allows extensibility by the application through overloading and
specialization.

... just to name a few ...

Macros are almost impossible to debug because of the way they work.
It is surprising that after so many years of using the preprocessor,
debuggers can't single step through macros but alas, they can't. C++
templates however are well supported by debuggers in comparison.


Just expand the preprocessor template and debug it. Problem solved.
Don't know about your preprocessor but the preprocessed output of a very
simple file (~20 lines) which includes <iostreamis ~50,000 lines and
760 KB large. You could probably make the preprocessor smarter (and more
complex) but then again, wasn't the complexity of templates one of your
problems?

Another point, many people use and IDE nowadays, and as long as they
don't support debugging the preprocessed code there's no easy way to
debug macro-based templates.

--
Erik Wikström
Jun 13 '07 #71
JohnQ wrote:
That's why I'm investigating hacking a preprocessor to do a templates
implementation. I'm not convinced that I need any more power than the text
substitution of the existing preprocessors though. I'm thinking that the
only thing it would get me is not having to type all those backslashes.
Then do it with files:

#define LIST_TYPE int
#define LIST_NAME int_list
#include <johnq/list.h>

#define LIST_TYPE double
#define LIST_NAME double_list
#include <johnq/list.h>

No need for backslashes in the file. No need for a class generating #define
also.

Maybe your debugger is happier with it, too, so it can step through your
functions (didn't try).
Oh
yeah, and a mechanism to control template generation. Neither needed, but it
would be more convenient and elegant.
comp.compilers - for compiler hacking
comp.lang.misc - for discussions about languages

--
Thomas
http://www.netmeister.org/news/learn2quote.html
Jun 13 '07 #72
James Kanze wrote:
>
I keep saying because it is true. Macro based generic classes
require an unacceptable amount of time and effort to use and
maintain. I've been there; I've had to maintain stuff written
using the preprocessor. And I'm not alone.
Ah, so there's two of us!

--
Ian Collins.
Jun 13 '07 #73

"Erik Wikström" <Er***********@telia.comwrote in message
news:aB****************@newsb.telia.net...
On 2007-06-13 12:31, JohnQ wrote:
>"Gianni Mariani" <gi*******@mariani.wswrote in message
news:46***********************@per-qv1-newsreader-01.iinet.net.au...
>>JohnQ wrote:
...
To me, "templates" means the kind of thing the preprocessor does (text
substitution) and using it to generate typed code.

That's only one of the things that templates are about.

C++ templates allow you to:

Change behaviour for different types.

Compute compile time constants (like find first set bit) etc.

Force compile time errors when various assumptions are invalid.

Allows extensibility by the application through overloading and
specialization.

... just to name a few ...

Macros are almost impossible to debug because of the way they work.
It is surprising that after so many years of using the preprocessor,
debuggers can't single step through macros but alas, they can't. C++
templates however are well supported by debuggers in comparison.


Just expand the preprocessor template and debug it. Problem solved.

Don't know about your preprocessor but the preprocessed output of a very
simple file (~20 lines) which includes <iostreamis ~50,000 lines and 760
KB large. You could probably make the preprocessor smarter (and more
complex) but then again, wasn't the complexity of templates one of your
problems?
Don't use the existing preprocessor to expand the "template". It's just text
replacement afterall.
Another point, many people use and IDE nowadays, and as long as they don't
support debugging the preprocessed code there's no easy way to debug
macro-based templates.
That's silly. Just expand the "macro" (search and replace if you don't have
something scriptable to work with). Template code should be pretty stable
after debugged so it's not a big deal to make a little effort during
template development.

John
Jun 14 '07 #74
JohnQ wrote:
"Erik Wikström" <Er***********@telia.comwrote:
>Another point, many people use and IDE nowadays, and as long as they don't
support debugging the preprocessed code there's no easy way to debug
macro-based templates.

That's silly. Just expand the "macro" (search and replace if you don't have
something scriptable to work with). Template code should be pretty stable
after debugged so it's not a big deal to make a little effort during
template development.
More effort that isn't required when using C++ templates.

--
Ian Collins.
Jun 14 '07 #75

"James Kanze" <ja*********@gmail.comwrote in message
news:11*********************@d30g2000prg.googlegro ups.com...
On Jun 12, 3:31 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"James Kanze" <james.ka...@gmail.comwrote in message
[...]
" <generic.hpredates that by a lot. It proved to be
unusable. Real templates (albeit very buggy) first appeared in
CFront 3.0 (from AT&T), in 1989, I think."
Unusable to do all the advanced things that "the language
within a language" C++ templates do, yes.
"Unusable for even the simplest container classes."

Like I said, it's just one technique... a starting point. I have a nice set
of containers that I find a joy to use compared to the STL ones.

John
Jun 14 '07 #76

"James Kanze" <ja*********@gmail.comwrote in message
news:11********************@i13g2000prf.googlegrou ps.com...
On Jun 12, 3:31 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"James Kanze" <james.ka...@gmail.comwrote in message
news:11**********************@g37g2000prf.googlegr oups.com...
On Jun 12, 1:40 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"James Kanze" <james.ka...@gmail.comwrote in message
news:11**********************@j4g2000prf.googlegro ups.com...
On Jun 11, 11:11 am, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"Robbie Hatley" <bogus.addr...@no.spamwrote in message
>news:Yh*******************@fe02.news.easynews.com ...
"JohnQ" wrote:
Are C++ templates a precompiler thing?
By "precompiler", I presume you mean the C/C++ preprocessor?
That's not *any* kind of "compiler", pre-, post-, or otherwise.
It's just a text editor.
Templates are a part of the C++ language. They are not
preprocessor macros.
Can they be implemented that way though (early work did exactly that).
"Then they're not templates."
Not "C++ templates" you mean.
"Not templates. C++ didn't invent templates; they were present
in languages long before C++ added them. In fact, C++ added
them mainly because the earlier macro-based solution didn't
work."
You keep saying that, but of course it isn't true, for my
containers and algos work just fine.
"I keep saying because it is true. Macro based generic classes
require an unacceptable amount of time and effort to use and
maintain. I've been there; I've had to maintain stuff written
using the preprocessor. And I'm not alone."

That's opinion. And you're making assumptions about the implementation that
are not necessarily correct. Again, YMMV. You say "to-maye-toe", I say
"to-mah-toe" (tomato). It's not "a thing to vote on", it's personal
preference. We'll just have to agree to disagree on this one.

John

Jun 14 '07 #77

"Ian Collins" <ia******@hotmail.comwrote in message
news:5d**************@mid.individual.net...
JohnQ wrote:
>"Erik Wikstrm" <Er***********@telia.comwrote:
>>Another point, many people use and IDE nowadays, and as long as they
don't
support debugging the preprocessed code there's no easy way to debug
macro-based templates.

That's silly. Just expand the "macro" (search and replace if you don't
have
something scriptable to work with). Template code should be pretty stable
after debugged so it's not a big deal to make a little effort during
template development.
More effort that isn't required when using C++ templates.
That's right. I draw the line of acceptability/concession in a different
place and for different reasons for I value different things. No big deal,
right?

John
Jun 14 '07 #78
JohnQ wrote:
"James Kanze" <ja*********@gmail.comwrote:

"I keep saying because it is true. Macro based generic classes
require an unacceptable amount of time and effort to use and
maintain. I've been there; I've had to maintain stuff written
using the preprocessor. And I'm not alone."

That's opinion.
Could you do us all a favor and change or fix your newsreader to quote
properly. Don't go blaming James's character set, no one else here is
troubled by it.

--
Ian Collins.
Jun 14 '07 #79
JohnQ wrote:
"Ian Collins" <ia******@hotmail.comwrote in message
news:5d**************@mid.individual.net...
>JohnQ wrote:
>>"Erik Wikstrm" <Er***********@telia.comwrote:

Another point, many people use and IDE nowadays, and as long as they
don't
support debugging the preprocessed code there's no easy way to debug
macro-based templates.
That's silly. Just expand the "macro" (search and replace if you don't
have
something scriptable to work with). Template code should be pretty stable
after debugged so it's not a big deal to make a little effort during
template development.
More effort that isn't required when using C++ templates.

That's right. I draw the line of acceptability/concession in a different
place and for different reasons for I value different things. No big deal,
right?
I draw the line at reinventing and using wheels with solid tyres when I
have access to pneumatic ones.

--
Ian Collins.
Jun 14 '07 #80

"Ian Collins" <ia******@hotmail.comwrote in message
news:5d*************@mid.individual.net...
JohnQ wrote:
>"James Kanze" <ja*********@gmail.comwrote:

"I keep saying because it is true. Macro based generic classes
require an unacceptable amount of time and effort to use and
maintain. I've been there; I've had to maintain stuff written
using the preprocessor. And I'm not alone."

That's opinion.

Could you do us all a favor and change or fix your newsreader to quote
properly. Don't go blaming James's character set, no one else here is
troubled by it.
All I know that it happens whenever someone has NON-ENGLISH characters in
their post. Why should I make concessions to posts that have elements that
are in a foreign language? Maybe I feel like making a little stand that
English newsgroups should be 7-bit ASCII. (Though the problem has not yet
been identified).

John
Jun 14 '07 #81

"Ian Collins" <ia******@hotmail.comwrote in message
news:5d**************@mid.individual.net...
JohnQ wrote:
>"Ian Collins" <ia******@hotmail.comwrote in message
news:5d**************@mid.individual.net...
>>JohnQ wrote:
"Erik Wikstrm" <Er***********@telia.comwrote:

Another point, many people use and IDE nowadays, and as long as they
don't
support debugging the preprocessed code there's no easy way to debug
macro-based templates.
That's silly. Just expand the "macro" (search and replace if you don't
have
something scriptable to work with). Template code should be pretty
stable
after debugged so it's not a big deal to make a little effort during
template development.

More effort that isn't required when using C++ templates.

That's right. I draw the line of acceptability/concession in a different
place and for different reasons for I value different things. No big
deal,
right?
I draw the line at reinventing and using wheels with solid tyres when I
have access to pneumatic ones.
Sounds like propoganda.

John
Jun 14 '07 #82
JohnQ wrote:
"Ian Collins" <ia******@hotmail.comwrote in message
news:5d*************@mid.individual.net...
>JohnQ wrote:
>>"James Kanze" <ja*********@gmail.comwrote:

"I keep saying because it is true. Macro based generic classes
require an unacceptable amount of time and effort to use and
maintain. I've been there; I've had to maintain stuff written
using the preprocessor. And I'm not alone."

That's opinion.
Could you do us all a favor and change or fix your newsreader to quote
properly. Don't go blaming James's character set, no one else here is
troubled by it.

All I know that it happens whenever someone has NON-ENGLISH characters in
their post. Why should I make concessions to posts that have elements that
are in a foreign language? Maybe I feel like making a little stand that
English newsgroups should be 7-bit ASCII. (Though the problem has not yet
been identified).
It's not for your benefit, your replies are bloody hard for everyone
else to read.

--
Ian Collins.
Jun 14 '07 #83

"Ian Collins" <ia******@hotmail.comwrote in message
news:5d*************@mid.individual.net...
JohnQ wrote:
>"James Kanze" <ja*********@gmail.comwrote:

"I keep saying because it is true. Macro based generic classes
require an unacceptable amount of time and effort to use and
maintain. I've been there; I've had to maintain stuff written
using the preprocessor. And I'm not alone."

That's opinion.

Could you do us all a favor and change or fix your newsreader to quote
properly. Don't go blaming James's character set, no one else here is
troubled by it.
I think I've tried everything I can on this end to no avail. I know that
when there are no extended characters in the signature of the post,
everything works fine, since JK sent one post without those characters and
it worked.

John

Jun 14 '07 #84
JohnQ wrote:
>
"Ian Collins" <ia******@hotmail.comwrote in message
news:5d*************@mid.individual.net...
>JohnQ wrote:
>>"James Kanze" <ja*********@gmail.comwrote:

"I keep saying because it is true. Macro based generic classes
require an unacceptable amount of time and effort to use and
maintain. I've been there; I've had to maintain stuff written
using the preprocessor. And I'm not alone."

That's opinion.

Could you do us all a favor and change or fix your newsreader to quote
properly. Don't go blaming James's character set, no one else here is
troubled by it.

I think I've tried everything I can on this end to no avail. I know that
when there are no extended characters in the signature of the post,
everything works fine, since JK sent one post without those characters
and it worked.
Even something a crappy as outlook can quote messages with non-ascii
characters. There are plenty of other users who don't have this
problem. I think you just enjoy being a pain in the arse.

--
Ian Collins.
Jun 14 '07 #85

"Ian Collins" <ia******@hotmail.comwrote in message
news:5d**************@mid.individual.net...
JohnQ wrote:
>>
"Ian Collins" <ia******@hotmail.comwrote in message
news:5d*************@mid.individual.net...
>>JohnQ wrote:
"James Kanze" <ja*********@gmail.comwrote:

"I keep saying because it is true. Macro based generic classes
require an unacceptable amount of time and effort to use and
maintain. I've been there; I've had to maintain stuff written
using the preprocessor. And I'm not alone."

That's opinion.

Could you do us all a favor and change or fix your newsreader to quote
properly. Don't go blaming James's character set, no one else here is
troubled by it.

I think I've tried everything I can on this end to no avail. I know that
when there are no extended characters in the signature of the post,
everything works fine, since JK sent one post without those characters
and it worked.
Even something a crappy as outlook can quote messages with non-ascii
characters.
If I reply in HTML, it works. In plain text, it doesn't. I wonder if the
fact that the 8-bit characters are in the signature has anything to do with
it. I'd be interested in seeing if the 8-bit chars in ONLY a message body
would cause the problem.
There are plenty of other users who don't have this problem.
So I would assume also. I tried it on another account on my computer and got
the same result. I'll go try it from another computer here... Same result
(and it's a virtually clean install of WinXP).
>I think you just enjoy being a pain in the arse.
LOL, not. Tell me how to fix it and I will. (No, I'm not switching
newsreaders).

John

Jun 14 '07 #86
On Jun 14, 7:19 am, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"Ian Collins" <ian-n...@hotmail.comwrote in message
news:5d*************@mid.individual.net...
JohnQ wrote:
"James Kanze" <james.ka...@gmail.comwrote:
"I keep saying because it is true. Macro based generic classes
require an unacceptable amount of time and effort to use and
maintain. I've been there; I've had to maintain stuff written
using the preprocessor. And I'm not alone."
That's opinion.
Could you do us all a favor and change or fix your newsreader to quote
properly. Don't go blaming James's character set, no one else here is
troubled by it.
All I know that it happens whenever someone has NON-ENGLISH characters in
their post. Why should I make concessions to posts that have elements that
are in a foreign language?
In other words, I don't have a right to post because of my
address, and others don't have that right because of their name.
Maybe I feel like making a little stand that
English newsgroups should be 7-bit ASCII. (Though the problem has not yet
been identified).
You can't write correct English in just 7-bit ASCII. Words like
"naïve" still cause problems.

And the actual problem is independant of the characters used; it
still appeared when I removed the accented characters from my
posting. The actual problem is that somewhere, a system is
converting my postings to quoted-ascii, and your newsreader
doesn't seem to be able to handle that. (In short, the problem
is that you are receiving pure, 7-bit ASCII.)

--
James Kanze (GABI Software, from CAI) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Jun 14 '07 #87
On Jun 14, 8:17 am, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"Ian Collins" <ian-n...@hotmail.comwrote in message
news:5d*************@mid.individual.net...
JohnQ wrote:
"James Kanze" <james.ka...@gmail.comwrote:
"I keep saying because it is true. Macro based generic classes
require an unacceptable amount of time and effort to use and
maintain. I've been there; I've had to maintain stuff written
using the preprocessor. And I'm not alone."
That's opinion.
Could you do us all a favor and change or fix your newsreader to quote
properly. Don't go blaming James's character set, no one else here is
troubled by it.
I think I've tried everything I can on this end to no avail. I know that
when there are no extended characters in the signature of the post,
everything works fine, since JK sent one post without those characters and
it worked.
No it didn't. The posts which work are those from my home site,
where the headers don't include a "Content-Transfer-Encodeing:
quoted-printable" line. I don't know where this line is
inserted; it may be that some site between me and Google is
using it to work-around a site that doesn't support 8-bit codes.
But it's a fully legitimate line, even if I didn't intend it.

There are any number of free newsreaders which actually work.
There's really no excuse for not using them. And quoting by
hand isn't that difficult either, at least not with a good
editor. I've done it in the past when I didn't have direct
access. (In the editor I use: ":%s:^.:&:". Which I can bind
to a function key if I want.) I can understand such problems in
a non-technical group, but surely anyone posting here knows how
to use such tools.

--
James Kanze (GABI Software, from CAI) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Jun 14 '07 #88

"James Kanze" <ja*********@gmail.comwrote in message
news:11*********************@a26g2000pre.googlegro ups.com...
On Jun 14, 8:17 am, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"Ian Collins" <ian-n...@hotmail.comwrote in message
news:5d*************@mid.individual.net...
JohnQ wrote:
"James Kanze" <james.ka...@gmail.comwrote:
"I keep saying because it is true. Macro based generic classes
require an unacceptable amount of time and effort to use and
maintain. I've been there; I've had to maintain stuff written
using the preprocessor. And I'm not alone."
That's opinion.
Could you do us all a favor and change or fix your newsreader to quote
properly. Don't go blaming James's character set, no one else here is
troubled by it.
I think I've tried everything I can on this end to no avail. I know that
when there are no extended characters in the signature of the post,
everything works fine, since JK sent one post without those characters and
it worked.
"No it didn't. The posts which work are those from my home site,
where the headers don't include a "Content-Transfer-Encodeing:
quoted-printable" line."

Well it's also devoid of any encoded characters also. So that post went
through something that stripped them out and replaced them with the
best-match English character?

"I don't know where this line is
inserted; it may be that some site between me and Google is
using it to work-around a site that doesn't support 8-bit codes.
But it's a fully legitimate line, even if I didn't intend it."

"There are any number of free newsreaders which actually work.
There's really no excuse for not using them."

Sure there is: installing and maintaining an addtional program.

"And quoting by
hand isn't that difficult either, at least not with a good
editor. I've done it in the past when I didn't have direct
access. (In the editor I use: ":%s:^.:&:". Which I can bind
to a function key if I want.) I can understand such problems in
a non-technical group, but surely anyone posting here knows how
to use such tools."

And the excuse for posting partially in French is...?

John

Jun 14 '07 #89

"James Kanze" <ja*********@gmail.comwrote in message
news:11**********************@i38g2000prf.googlegr oups.com...
On Jun 14, 7:19 am, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"Ian Collins" <ian-n...@hotmail.comwrote in message
news:5d*************@mid.individual.net...
JohnQ wrote:
"James Kanze" <james.ka...@gmail.comwrote:
"I keep saying because it is true. Macro based generic classes
require an unacceptable amount of time and effort to use and
maintain. I've been there; I've had to maintain stuff written
using the preprocessor. And I'm not alone."
That's opinion.
Could you do us all a favor and change or fix your newsreader to quote
properly. Don't go blaming James's character set, no one else here is
troubled by it.
All I know that it happens whenever someone has NON-ENGLISH characters in
their post. Why should I make concessions to posts that have elements that
are in a foreign language?
"In other words, I don't have a right to post because of my
address, and others don't have that right because of their name."

It would be nice if y'all posted in English instead of just partially so.
It's the same response that one gets when they post HTML or post binaries: i
put all of those things in the same category.
Maybe I feel like making a little stand that
English newsgroups should be 7-bit ASCII. (Though the problem has not yet
been identified).
"You can't write correct English in just 7-bit ASCII. Words like
"naove" still cause problems."

Did you mean 'naive'? Are you suggesting that an English word has an umlaut?

"And the actual problem is independant of the characters used; it
still appeared when I removed the accented characters from my
posting."

This post of yours works:

news:11**********************@p47g2000hsd.googlegr oups.com

It is devoid of encoded characters in it (with '=xx' where the 8-bit chars
were).

"The actual problem is that somewhere, a system is
converting my postings to quoted-ascii, and your newsreader
doesn't seem to be able to handle that."

And OE allows me to SEND with quoted-printable as a UTF encoding. Bizarre
that it would choke, then, on incoming messages.

" (In short, the problem is that you are receiving pure, 7-bit ASCII.)"

The combination of the "quoted-printable" header and the encoded characters.
(Or so we think). I'll post something in an MS support group tomorrow and
ask them what's up with OE in this scenario. And if no one else is
experiencing the same thing with OE, then I begin to wonder what global
system setting could possibly cause such bizarro behavior. I've tried it on
2 machines here and the same thing happens.

John

Jun 14 '07 #90

"Thomas J. Gritzan" <Ph*************@gmx.dewrote in message
news:f4**********@newsreader3.netcologne.de...
JohnQ wrote:
>That's why I'm investigating hacking a preprocessor to do a templates
implementation. I'm not convinced that I need any more power than the
text
substitution of the existing preprocessors though. I'm thinking that the
only thing it would get me is not having to type all those backslashes.

Then do it with files:

#define LIST_TYPE int
#define LIST_NAME int_list
#include <johnq/list.h>

#define LIST_TYPE double
#define LIST_NAME double_list
#include <johnq/list.h>

No need for backslashes in the file. No need for a class generating
#define
also.
Neat trick (does it work? I wouldn't expect it to and haven't tried it yet).
Can it
be depended on across implementations? Because it doesn't seem like it's
expanding anything at the #include place like a macro would. Where is the
typed list class definition expanded at? I have a hard time believing that
the
compiler would make multiple copies of the header file somewhere and that
those would end up in the compiled code.

If it works, you can put a concatenator (#define slist(T) concat2(slist_,T))
in the "template file". Then you can eliminate the LIST_NAME define above. I
think you'll need an "#undef LIST_TYPE" after the #include line though in
any case.
>
Maybe your debugger is happier with it, too, so it can step through your
functions (didn't try).
>Oh
yeah, and a mechanism to control template generation. Neither needed, but
it
would be more convenient and elegant.

comp.compilers - for compiler hacking
comp.lang.misc - for discussions about languages
I added them now that I'm investigating this stuff.

John
Jun 14 '07 #91
JohnQ wrote:
"Thomas J. Gritzan" <Ph*************@gmx.dewrote...
>Then do it with files:

#define LIST_TYPE int
#define LIST_NAME int_list
#include <johnq/list.h>
[...]
>
Neat trick (does it work? I wouldn't expect it to and haven't tried it
yet). Can it
be depended on across implementations? Because it doesn't seem like it's
expanding anything at the #include place like a macro would.
Its just text. An #include directive just places the contents of the file
where the #include directive is. It's a stupid preprocessor after all.
That's why you need include guards: To avoid double declaration/definition.

With your DefineSListOfType() macro you maybe will have this double
definition problem some times, too.
If it works, you can put a concatenator (#define slist(T)
concat2(slist_,T))
in the "template file". Then you can eliminate the LIST_NAME define
above. I
think you'll need an "#undef LIST_TYPE" after the #include line though in
any case.
The #undef can be in the include file for ease of use.
There also should be:
#ifndef LIST_TYPE
#error LIST_TYPE must be defined...
#endif

To catch errors early.

Well I just can't understand what should be easier with such macro tricks
when you can use templates instead.

--
Thomas
http://www.netmeister.org/news/learn2quote.html
Jun 14 '07 #92
JohnQ wrote:
"James Kanze" <ja*********@gmail.comwrote...
"There are any number of free newsreaders which actually work.
There's really no excuse for not using them."

Sure there is: installing and maintaining an addtional program.
Says somebody who talks about hacking a preprocessor just to do something
that the compiler already can to with templates?

Just try Mozilla Thunderbird. It's close to OE in usage but without the bugs.
"And quoting by
hand isn't that difficult either, at least not with a good
editor. [...]"

And the excuse for posting partially in French is...?
Being french.

--
Thomas
http://www.netmeister.org/news/learn2quote.html
Jun 14 '07 #93

Thomas J. Gritzan wrote in message...
JohnQ wrote:
"Thomas J. Gritzan" wrote...
Then do it with files:

#define LIST_TYPE int
#define LIST_NAME int_list
#include <johnq/list.h>
[...]

Neat trick (does it work? I wouldn't expect it to and haven't tried it
yet). Can it
be depended on across implementations? Because it doesn't seem like it's
expanding anything at the #include place like a macro would.

Its just text. An #include directive just places the contents of the file
where the #include directive is.
Example (JohnQ try this):

// --- Guts.h ---
cout<<"Hello World, from Guts.h"<<std::endl;
#define BLAHBLAH cout<<"Hello World2, from Guts.h"<<std::endl;
// --- Guts.h --- END

// --- main.cpp ---
#include <iostream>
int main(){ using std::cout;
#include "Guts.h"
BLAHBLAH
// note no semicolon at end of that line
return 0;
}
// --- main.cpp --- END

--
Bob R
POVrookie
Jun 14 '07 #94
On Jun 14, 3:55 am, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"Thomas J. Gritzan" <Phygon_ANTIS...@gmx.dewrote in messagenews:f4**********@newsreader3.netcologne.de ...
JohnQ wrote:
I'm thinking that the only thing it would get me is not having to
type all those backslashes.
Then do it with files:

#define LIST_TYPE int
#define LIST_NAME int_list
#include <johnq/list.h>
#define LIST_TYPE double
#define LIST_NAME double_list
#include <johnq/list.h>

Neat trick (does it work? I wouldn't expect it to and haven't tried it yet).
Yes. The preprocessor works by token manipulation only, and #include
instructs it to replace the #include directives with an implementation-
defined set of tokens (by convention, the contents of the named file),
then continue preprocessing.
Can it be depended on across implementations? Because it doesn't seem like it's
expanding anything at the #include place like a macro would. Where is the
typed list class definition expanded at? I have a hard time believing that
the
compiler would make multiple copies of the header file somewhere and that
those would end up in the compiled code.
If your compiler supports it, put together a small sample and run it
through the preprocessor phase only (gcc -E, for instance) and examine
the output. The contents of johnq/list.h will appear twice, with
LIST_TYPE and LIST_NAME replaced appropriately.

JohnQ wrote:
That's why I'm investigating hacking a preprocessor to do a templates
implementation.
You have asked: "Are C++ templates a precompiler thing?" The answer
is no.

You meant to ask: "Can a template mechanism be implemented using the C+
+ preprocessor?" The answer is yes, you can do that if you think it's
better.

You may also have meant to ask: "Can a template mechanism be
implemented by textual manipulation alone?" The answer is yes, you
can do that if you think it's better; languages which do so are
(mostly) not C++ and are off-topic here.

Why is this thread still going, again?

Jun 14 '07 #95

"James Kanze" <ja*********@gmail.comwrote in message
news:11**********************@d30g2000prg.googlegr oups.com...
On Jun 12, 1:40 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"James Kanze" <james.ka...@gmail.comwrote in message
"And the problem doesn't seem to be the characters themselves,
because I modified my .sig in one posting, to remove them. The
problem is, I think, one of the headers, probably inserted by
Google."

From Wikipedia:

"Quoted-printable, or QP Encoding, is an encoding using printable characters
(i.e. alphanumeric and the equals sign "=") to transmit 8-bit data over a
7-bit data path. It is defined as a MIME content transfer encoding for use
in Internet e-mail."

"Lines of quoted-printable encoded data must not be longer than 76
characters. To satisfy this requirement without altering the encoded text,
soft line breaks may be added as desired. A soft line break consists of an
"=" at the end of an encoded line, and does not cause a line break in the
decoded text."

So that probably means that if there are 8-bit characters in the message
being encoded, the line breaks are probably being converted also and being
moved forward like that. So, the 8-bit characters are messing up the concept
of "lines ending in CR/LF" that newsreaders are expecting.

Should OE be able to handle quoted-printable? Maybe, but as far as I can
tell, news articles should only contain characters 1-127 of the ASCII
character set (RFC 822). So, if something is encoding your articles into
quoted-printable based upon the extended (illegal) characters (the same
thing happens with other peoples' articles that have extended characters in
them, I have noticed), well.. "if it hurts when you do that, don't do
that!".

It appears to me that my newsreader should never see anything but
CR/LF-terminated text lines, but perhaps NNTP has been updated to say that
newsreaders should be able to handle encoded articles and specific
encodings? If no update to NNTP exists that deals with different line
encodings, then whoever/whatever is pushing the non-CR/LF articles around
(or putting 8-bit characters in messages) deserves the flak. By putting
8-bit characters in what was designed for 7-bit ASCII, you're probably
asking NNTP to do something it was not intended for.

What the current state of all this is officially, I dunno. If
quoted-printable is expected to be handled by newsreaders (specified in
NNTP), then MS should fix OE. If encodings aren't addressed by the RFCs,
then people shouldn't expect them to be supported everywhere or anywhere
(are binaries in newsgroups an ad hoc hack?). Obviously, just turning
something into ASCII as an encoded article is not adequate because it relies
on proper decoding at the endpoint, which may not be present and probably
won't be if it is ad hoc usage other than designed for.

Personally, I like English and 7-bit ASCII because it makes stuff a lot
simpler.

John
Jun 15 '07 #96
On Jun 14, 11:15 am, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"James Kanze" <james.ka...@gmail.comwrote in message
[...]
All I know that it happens whenever someone has NON-ENGLISH characters in
their post. Why should I make concessions to posts that have elements that
are in a foreign language?
"In other words, I don't have a right to post because of my
address, and others don't have that right because of their name."
It would be nice if y'all posted in English instead of just partially so.
I am posting in English. My address doesn't change just because
I'm speaking English. Neither does Erik Wikström's name.
It's the same response that one gets when they post HTML or
post binaries: i put all of those things in the same category.
If I were posting in French or German, you'd have a point. But
I'm not.
Maybe I feel like making a little stand that
English newsgroups should be 7-bit ASCII. (Though the problem has not yet
been identified).
"You can't write correct English in just 7-bit ASCII. Words like
"naove" still cause problems."
Did you mean 'naive'? Are you suggesting that an English word
has an umlaut?
The correct spelling in English uses a diaeresis over the i, at
least according to my dictionaries. In North American English,
it's optional; in British English, it's required.

Like most languages, correctly typeset English requires more
characters than are available on a standard typewriter keyboard
(or in US ASCII), and so adopts compromizes when the characters
aren't possible. In the 1970's, we accepted such compromizes in
computer text. Today, much less so.
"And the actual problem is independant of the characters used; it
still appeared when I removed the accented characters from my
posting."
This post of yours works:
news:11**********************@p47g2000hsd.googlegr oups.com
It is devoid of encoded characters in it (with '=xx' where the 8-bit chars
were).
"The actual problem is that somewhere, a system is
converting my postings to quoted-ascii, and your newsreader
doesn't seem to be able to handle that."
And OE allows me to SEND with quoted-printable as a UTF encoding. Bizarre
that it would choke, then, on incoming messages.
" (In short, the problem is that you are receiving pure, 7-bit ASCII.)"
The combination of the "quoted-printable" header and the encoded characters.
(Or so we think).
Or something. I agree that we aren't quite sure where the
problem lies. From what I've seen, a compliant newsreader
should be able to handle what I've posted, but it isn't what I
want to post, either. Somethings not behaving the way it should
be, even before the message gets to you.

One further update, however: the problem doesn't affect just
your answers to me---other people using OE have the same
problem. And as we've seen, I'm not the only person causing
this problem either. Also, and in my mind, this is very
significant, the problem is new. People have been posting
answers to my postings for a very long time, and I'm sure many
were using OE. Something has changed in the last week or two.
I don't know what, but that sort of makes me suspect Google.
Their software seems particularly unstable and changing.
I'll post something in an MS support group tomorrow and
ask them what's up with OE in this scenario. And if no one else is
experiencing the same thing with OE, then I begin to wonder what global
system setting could possibly cause such bizarro behavior. I've tried it on
2 machines here and the same thing happens.
One poster in fr.comp.lang.c++ said he had the same problem with
my posts. He blamed it on OE not handling quoted-ascii
correctly.

--
James Kanze (GABI Software, from CAI) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Jun 15 '07 #97

"James Kanze" <ja*********@gmail.comwrote in message
news:11**********************@g37g2000prf.googlegr oups.com...
>I'm going to try to find out where it is inserted in my case,
and get rid of it if I can. But you really should get your
newsreader fixed. As far as I can tell, you're the only one who
has this problem.
I'm using OE and don't seem to have any problem with
the characters themselves. In replying though, I had
to add the ">" in the above as OE stopped paying attention
to comments at that point. Not sure if the two are
related though.
Jun 15 '07 #98

"James Kanze" <ja*********@gmail.comwrote in message
news:11**********************@p77g2000hsh.googlegr oups.com...
On Jun 14, 11:15 am, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
"James Kanze" <james.ka...@gmail.comwrote in message
[...]
All I know that it happens whenever someone has NON-ENGLISH characters
in
their post. Why should I make concessions to posts that have elements
that
are in a foreign language?
"In other words, I don't have a right to post because of my
address, and others don't have that right because of their name."
It would be nice if y'all posted in English instead of just partially so.
"I am posting in English. My address doesn't change just because
I'm speaking English. Neither does Erik Wikström's name."

But the words or his name are not in English if they have non-English
characters in them.
It's the same response that one gets when they post HTML or
post binaries: i put all of those things in the same category.
"If I were posting in French or German, you'd have a point. But
I'm not."

Untranslated foreign language words are not English words.
Maybe I feel like making a little stand that
English newsgroups should be 7-bit ASCII. (Though the problem has not
yet
been identified).
"You can't write correct English in just 7-bit ASCII. Words like
"naove" still cause problems."
Did you mean 'naive'? Are you suggesting that an English word
has an umlaut?
"The correct spelling in English uses a diaeresis over the i, at
least according to my dictionaries. In North American English,
it's optional; in British English, it's required."

"Like most languages, correctly typeset English requires more
characters than are available on a standard typewriter keyboard
(or in US ASCII), and so adopts compromizes when the characters
aren't possible. In the 1970's, we accepted such compromizes in
computer text. Today, much less so."

Well that's the first time that I've heard that the English alphabet has
more than 26 characters. Someone better contact all the grade schools across
the USA and clue them in.

"And the actual problem is independant of the characters used; it
still appeared when I removed the accented characters from my
posting."
This post of yours works:
news:11**********************@p47g2000hsd.googlegr oups.com
It is devoid of encoded characters in it (with '=xx' where the 8-bit chars
were).
"The actual problem is that somewhere, a system is
converting my postings to quoted-ascii, and your newsreader
doesn't seem to be able to handle that."
And OE allows me to SEND with quoted-printable as a UTF encoding. Bizarre
that it would choke, then, on incoming messages.
" (In short, the problem is that you are receiving pure, 7-bit ASCII.)"
The combination of the "quoted-printable" header and the encoded
characters.
(Or so we think).
Or something. I agree that we aren't quite sure where the
problem lies.

I think I have it figured out (see my post I posted in this thread earlier
today or last night).

"From what I've seen, a compliant newsreader
should be able to handle what I've posted,"

The question is "compliant to what?". Can you reference the source to comply
to? My cursory research indicates that putting 8-bit characters in news
articles is a no-no.

"but it isn't what I want to post, either. Somethings not behaving the way
it should
be, even before the message gets to you."

Either Erik Wikström is using the same newsreader as you are or there's some
kind of commonality in handling the 8-bit character-laden articles (encoding
the article) by servers or certain servers. It will be interesting to see if
this post of mine, with the 8-bit characters, results in the same problem.

"One further update, however: the problem doesn't affect just
your answers to me---other people using OE have the same
problem."

Oh, well that is "good" to hear.

" And as we've seen, I'm not the only person causing
this problem either. Also, and in my mind, this is very
significant, the problem is new. People have been posting
answers to my postings for a very long time, and I'm sure many
were using OE. Something has changed in the last week or two."

I do believe that is true because certainly I've responded to your posts in
the past and haven't always had to deal with the lack of proper quoting.

"I don't know what, but that sort of makes me suspect Google.
Their software seems particularly unstable and changing."

MS concedes it's a problem with OE and they hope to have it fixed in the
next release of OE (whether that means the next patch or on Vista, I don't
know). Whether allowing the encodings or 8-bit character handling in NNTP is
specified or not, I would like to know.
I'll post something in an MS support group tomorrow and
ask them what's up with OE in this scenario. And if no one else is
experiencing the same thing with OE, then I begin to wonder what global
system setting could possibly cause such bizarro behavior. I've tried it
on
2 machines here and the same thing happens.
"One poster in fr.comp.lang.c++ said he had the same problem with
my posts. He blamed it on OE not handling quoted-ascii
correctly."

That's what MS conceded. Though I'd prefer 7-bit clean newsgroups when they
are English groups.

John

Jun 15 '07 #99
On 2007-06-15 07:08, JohnQ wrote:
"James Kanze" <ja*********@gmail.comwrote in message
news:11**********************@d30g2000prg.googlegr oups.com...
On Jun 12, 1:40 pm, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
>"James Kanze" <james.ka...@gmail.comwrote in message

"And the problem doesn't seem to be the characters themselves,
because I modified my .sig in one posting, to remove them. The
problem is, I think, one of the headers, probably inserted by
Google."

From Wikipedia:

"Quoted-printable, or QP Encoding, is an encoding using printable characters
(i.e. alphanumeric and the equals sign "=") to transmit 8-bit data over a
7-bit data path. It is defined as a MIME content transfer encoding for use
in Internet e-mail."

"Lines of quoted-printable encoded data must not be longer than 76
characters. To satisfy this requirement without altering the encoded text,
soft line breaks may be added as desired. A soft line break consists of an
"=" at the end of an encoded line, and does not cause a line break in the
decoded text."

So that probably means that if there are 8-bit characters in the message
being encoded, the line breaks are probably being converted also and being
moved forward like that. So, the 8-bit characters are messing up the concept
of "lines ending in CR/LF" that newsreaders are expecting.

Should OE be able to handle quoted-printable? Maybe, but as far as I can
tell, news articles should only contain characters 1-127 of the ASCII
character set (RFC 822). So, if something is encoding your articles into
quoted-printable based upon the extended (illegal) characters (the same
thing happens with other peoples' articles that have extended characters in
them, I have noticed), well.. "if it hurts when you do that, don't do
that!".
Actually the bodies of the message shall be UTF-8:

This specification extends NNTP from US-ASCII [ANSI1986] to UTF-8
[RFC3629]. Except in the two areas discussed below, UTF-8 (which is
a superset of US-ASCII) is mandatory, and implementations MUST NOT
use any other encoding.

Headers though should be in US-ASCII and the char-set of the message
shall be indicated in the headers using MIME.

I have no idea what this implies about the standards conformance of OE
or google groups, and I should point out that RFC3977 is quite new, so
there's a high probability that there are some implementations out there
that don't follow it (especially OE I would imagine considering MS's
track record of standards conformance and that OE6 is quite old and
probably just barely maintained).

--
Erik Wikström
Jun 15 '07 #100

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.