Using C++ in GCC is OK

Richard Guenther richard.guenther@gmail.com
Mon May 31 12:23:00 GMT 2010


On Mon, May 31, 2010 at 12:59 PM, Robert Dewar <dewar@adacore.com> wrote:
> 徐持恒 wrote:
>>
>> On Mon, May 31, 2010 at 6:41 PM, Robert Dewar <dewar@adacore.com> wrote:
>>
>>> It's a pity to exclude namespaces, the advantage of breaking the
>>> single-big-namespace model are evident.
>>
>> Yes, the advantage of namespace is obvious.
>>
>> But, I think namespace is just a syntax sugar. You can name your
>> variables, functions, classes properly  to  "avoid" it.
>
> All of OO is just syntactic sugar :-)
> You can mimic anything in C, the point is that it obscures the
> code, this kind of naming obscures the code, so it is better
> avoided.

Indeed.  Like the funny names you start to invent when you
have wrappers that allow different kind of argument types for
a common worker.  Like building a points-to constraint in
tree-ssa-structalias.c, those have two args which technically
can be either of type int, of type varinfo_t or of type
struct constraint_expr ...  The most convenient variant
would be auto-conversion to struct constraint_expr, but even
an explicit constructor call would be ok.  Or simply
use function overloading for a sub-set of all argument type
combinations.

The same applies to functions operating on HWI vs.
double-int vs. tree integer constants vs. RTL integer constants.
Where at that point the question is whether we want to
allow operator overloading.  (No would be my answer)

Richard.



More information about the Gcc mailing list