To bean or not to bean

R

Richard Herring

Steven T. Hatton said:
I don't know what the reason for templates not taking char* constants is, so
I can't really comment on what you might be able to do with them if the
capability to pass them were there.

You seem to want to be able to compile, or maybe interpret, them. I
don't see that coming up in the near future.
Regular code won't do things like

#define twice(x) ((x)+(x))
int n = 1;
int sum;
sum = twice(++n); //undefined

Sure, but who'd write such a thing? Strawmen don't make compelling
arguments.
 
S

Steven T. Hatton

Paul said:
Sure. The main factors, by far, that has led to the lack of more
sophisticated development environments (in C++) is templates (or more
specifically,
second-phase lookup) and (in C and C++) context-dependent parsing.

I don't know what you mean by 'context-dependent parsing'. The only context
dependency I can think of in C and C++ that is signally different from that
of other languages is the CPP.
For a
tool to do an analysis that is anywhere near complete, it has to do a
nearly complete parse of the language, *and* it has to be able to deal
with intermediate stages of construct completion (i.e. as you type in an
IDE; it can't just bail like a
compiler can).

That's just not true. IDE tools can, and do, fail to parse a given block of
code until the code can be completely evaluated. Sometimes they can pickup
once the block is completed, sometimes they need to be manually refreshed,
and sometimes they need to have the compiler run on the code in question.
The preprocessor is almost insignificant in comparison.

This paper was called to my attention by the person who wrote much of the
code responsible for parsing C++ to provide syntax checking, code
completion and other facilities in the most popular IDE used on Linux. It
was part of his response to my question: 'Is the #include evil'?

https://netfiles.uiuc.edu/garrido/www/papers/ASE_paper.pdf

Abstract
Refactoring, an important technique for increasing
flexibility of the source code, can be applied with much
ease and efficiency by using automated tools. There is
currently a lack of refactoring tools for C with full
support for preprocessor directives because directives
complicate refactorings in many ways.
This paper describes refactoring of C programs in the
presence of conditional compilation directives and how
we propose to support them in a refactoring tool.
 

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

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top