[Geany-Devel] Let's move to C++98 - Re: Lets move to C99
Nick Treleaven
nick.treleaven at xxxxx
Wed Aug 28 14:52:17 UTC 2013
On 26/08/2013 19:54, Dimitar Zhekov wrote:
> On Mon, 26 Aug 2013 16:07:13 +0100
> Nick Treleaven <nick.treleaven at btinternet.com> wrote:
>> * RAII - this is a pretty essential feature for safe resource
>> >management.
> This works for global/static and auto classes. We can wrap a gchar *s
> = g_strdup_printf() in a class, but I'd rather not...
We don't always need a gchar*. For string processing we could use the
STL basic_string (or Scintilla SString).
>> * References can be useful in making code more readable vs pointers.
>
> But using both heavily (as GLib/GTK+ required pointers) will make it
> harder to read.
Just use them where they help ;-)
>> * Developer enjoyment, productivity & gaining more experience with C++.
>> (This might be an incentive for e.g. me to spend more time working on
>> Geany). This has to be offset against those that might need to learn
>> e.g. RAII.
>
> Hmmm?..
Time spent for contributors who don't know C++ to learn the parts we
use. What's the question?
>> * Possibly we might use some STL containers internally.
>
> There things are heavily templated. They generate more code,
> compilation is slower, and (unless improved significantly from the last
> time I tried them) the code is overall slower than using GArray/GList.
Slower compilation may be an issue. The minor performance/bloat
differences you mention would not be a problem for Geany IMO.
Assuming we're comparing the same design in C vs templated C++ code, the
C++ code would normally have an advantage because more code can be
inlined. It might be at a disadvantage because of code bloat though, but
the inlining may outweigh that. Are you sure you tested the C++ code
with full compiler optimization?
> Moreover, you propose to ban "class".
struct = class but with public member visibility by default.
>> * Possibly we could use a GObject wrapper for safe reference counting.
>
> Why? Where? How to do that without classes and destructors?
Obviously you need destructors for RAII. I meant ban the keyword 'class'
in Geany code, not in STL code.
> Note that gcc has a non-standard extension for RAII, which works with
> the base C types. And Geany compiles with gcc only.
Really? Have you read HACKING?
>> * Possibly we could have some template function utilities instead of
>> unsafe macros.
>
> Do we need these macros to work with different types? If not, "inline
> is already declared in a portable manner in the GLib headers and can be
> used normally."
See FALLBACK in tagmanager. Matt doesn't like it though. I don't expect
we need to replace many macros, more that some template utility
functions will be useful in C++ code. I can give an example if you like.
>> I don't know if this can be enforced by g++, but I suggest we disallow
>> these keywords:
>>
>> class
>
> There isn't, that's THE most basic feature of C++.
> And you can write classes with struct and union.
exactly.
>> dynamic_cast
>
> -fno-rtti
ok.
>> friend
>
> No classes -> no usage for friends.
...
>> virtual
>
> No classes -> no virtual methods.
*cough* structs *cough*
>> throw
>
> -fno-exceptions
nice
>> Thoughts?
>
> Sorry, but IMHO, that seems even more pointless than using C99.
RAII != pointless
More information about the Devel
mailing list