This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Using C++ in GCC is OK
On Wed, Jun 2, 2010 at 9:55 AM, åææ <chiheng.xu@gmail.com> wrote:
> On Wed, Jun 2, 2010 at 8:38 AM, DJ Delorie <dj@redhat.com> wrote:
>>
>> "Hargett, Matt" <matt.hargett@bluecoat.com> writes:
>>>> As noted earlier I think we do want to use some STL classes.
>>>
>>> I agree with Mark's earlier declaration that it is relatively
>>> straight-forward, low-hanging fruit to replace VEC_*
>>
>> I do not object to simple and obvious uses of STL to replace equivalent
>> functionality, but I've seen code that layers STL over STL over STL to
>> the point where the code is very difficult to understand. ÂHence, my
>> recommendation to avoid STL *at first*. ÂIt teaches caution against
>> over-abstracting and arbitrary complexity.
>>
>
> STL is good, but may surplus what GCC really needs, and will introduce
> many complex, "uncontrollable" C++ features.
>
>
> Personally, I think what GCC need most is Âan simple, generic, one
> layer containers of pointers to objects, Âwith their iterators.
> Instead of containers of arbitrary types. ÂThat means the type
> parameters of the standard templates is restricted to pointer to
> objects.
>
>
> If you can't refrain from using STL and don't like the mess it may
> introduce, you can derive classes from instantiated standard templates
> with pointer as type parameters, and use the derived, template-free
> classes in rest of your code.
>
The complexity of compiler determined that , in compiler, Java style
C/C++ code may be unavoidable.
In Java language, there are only two kinks of types, primitive types
and reference types. When translated to C/C++, reference type are
converted to pointer(to object) types. So, In a C/C++ program, if you
only use primitive types and pointer(to object) types, I will call it
Java style C/C++ code. You can use Java language to write arbitrary
complex programs ? It may be true you can use Java style C/C++ code
to write compiler, with some garbage collection mechanism, of course.
But C/C++ may have an another advantage, it can use ADT(Abstract Data
Type) to extend its set of "primitive type", e.g., string.
--
åææ(Chiheng Xu)
Wuhan,China