Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > 2 suggested new features for C++

Reply
Thread Tools

2 suggested new features for C++

 
 
Gennaro Prota
Guest
Posts: n/a
 
      07-14-2008
James Kanze wrote:
> On Jul 11, 4:21 pm, Juha Nieminen <(E-Mail Removed)> wrote:
>> I apologize for shamelessly put this here, but it seemed to be a
>> proper place...

>
>> I have compiled my own C++ wishlist, if anyone is interested:

>
>> http://warp.povusers.org/cpluspluswishlist.html

>
> Well, my first wish would be that compilers would actually
> implement the features we've got (e.g. like export).


I think I gave up hoping for export in compilers not based on the EDG
front-end when H. Sutter presented his paper "Why We Can't Afford Export"

<http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1426.pdf>

about five years ago. The minutes of the following meeting

<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1459.html>

show that pretty much nobody in the committee took it into much
consideration (see the straw poll results) but it seemed to generate
quite an outcry in the world outside. It was IMHO a "Why we
--Microsoft-- don't want to tackle export" which turned into "Why
top-most experts like Herb Sutter say that if I think I'm capable to
implement export than I haven't understood it" for every other
implementor.

And, alas, note that *even* most of the EDG-based compilers come with
export disabled.

--
Gennaro Prota | <https://sourceforge.net/projects/breeze/>
Do you need expertise in C++? I'm available.
 
Reply With Quote
 
 
 
 
Juha Nieminen
Guest
Posts: n/a
 
      07-14-2008
Gennaro Prota wrote:
> I think I gave up hoping for export in compilers not based on the EDG
> front-end when H. Sutter presented his paper "Why We Can't Afford Export"


If I'm not completely mistaken, the latest gcc does support export
templates.
 
Reply With Quote
 
 
 
 
Lionel B
Guest
Posts: n/a
 
      07-15-2008
On Mon, 14 Jul 2008 19:12:41 +0000, Juha Nieminen wrote:

> Gennaro Prota wrote:
>> I think I gave up hoping for export in compilers not based on the EDG
>> front-end when H. Sutter presented his paper "Why We Can't Afford
>> Export"

>
> If I'm not completely mistaken, the latest gcc does support export
> templates.


I think you may be mistaken... where did you see that? My 4.3.1 (current
stable) doesn't and the documentation under "Current development"
(http://gcc.gnu.org/onlinedocs/) still says "GCC implements the majority
of C++98 (export is a notable exception)...".

--
Lionel B
 
Reply With Quote
 
Juha Nieminen
Guest
Posts: n/a
 
      07-15-2008
Lionel B wrote:
> I think you may be mistaken... where did you see that? My 4.3.1 (current
> stable) doesn't and the documentation under "Current development"
> (http://gcc.gnu.org/onlinedocs/) still says "GCC implements the majority
> of C++98 (export is a notable exception)...".


http://gcc.gnu.org/gcc-4.3/cxx0x_status.html

Maybe I got confused with "extern template" (which I really don't know
what it means, if it's something different than an export template).
 
Reply With Quote
 
Juha Nieminen
Guest
Posts: n/a
 
      07-15-2008
Gennaro Prota wrote:
> I think I gave up hoping for export in compilers not based on the EDG
> front-end when H. Sutter presented his paper "Why We Can't Afford Export"
>
> <http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1426.pdf>


IMO that paper is a bit misleading in one point: It seems to make it
sound like the only (and imaginary) advantage of export templates is
that you can reorganize your code better (that is, you don't have to put
everything in header files), and that's about it. The section 2.4 is
even titled "provides little or no value".

Unless I have understood export templates incorrectly (and please
correct me if I'm wrong, I really want to get this straight), export
templates allow for better modularity (which is one of the most, if not
the single most important feature of object-oriented programming).

Without export templates (which is the current situation with
basically all compilers) it's impossible to have templated classes and
functions which have private code inside their own compilation unit
(that is, inside a nameless namespace). In other words, non-export
templates can *not* use their own private nameless namespaces because
they don't have their own private compilation unit.

Unless I'm completely mistaken (please correct me if I am), export
templates can use data and code inside a nameless namespace inside the
compilation unit where those templates are implemented. This allows for
greater modularity and data hiding. The larger the amount of data and
code inside this nameless namespace, the more important it would be for
it to be inside that namespace. (For example trying to put hundreds or
even thousands of lines of non-templated code, or unrelated templates,
inside the private section of a template class as static data and static
functions can quickly make the header file a huge mess. With template
functions you can't even do that at all.)
 
Reply With Quote
 
Gennaro Prota
Guest
Posts: n/a
 
      07-15-2008
Juha Nieminen wrote:
> Gennaro Prota wrote:
>> I think I gave up hoping for export in compilers not based on the EDG
>> front-end when H. Sutter presented his paper "Why We Can't Afford Export"
>>
>> <http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1426.pdf>

>
> IMO that paper is a bit misleading in one point: It seems to make it
> sound like the only (and imaginary) advantage of export templates is
> that you can reorganize your code better (that is, you don't have to put
> everything in header files), and that's about it. The section 2.4 is
> even titled "provides little or no value".


A comment that I'd actually apply to the paper Frankly it is
probably the worst of all H. Sutter's writings, from a technical point
of view.

> Unless I have understood export templates incorrectly (and please
> correct me if I'm wrong, I really want to get this straight), export
> templates allow for better modularity (which is one of the most, if not
> the single most important feature of object-oriented programming).
>
> Without export templates (which is the current situation with
> basically all compilers) it's impossible to have templated classes and
> functions which have private code inside their own compilation unit
> (that is, inside a nameless namespace). In other words, non-export
> templates can *not* use their own private nameless namespaces because
> they don't have their own private compilation unit.

[further elaboration snipped...]

I believe you got it very right. I'm not saying that the world can't
leave without export but certainly the paper presents an unbalanced
view of the matter. Frankly, even the 4.5 person-years... is it such a
show-stopper for a compiler vendor? At EDG, of course, they were just
three at the time, so the issue was a tad different for them

--
Gennaro Prota | <https://sourceforge.net/projects/breeze/>
Do you need expertise in C++? I'm available.
 
Reply With Quote
 
Juha Nieminen
Guest
Posts: n/a
 
      07-18-2008
Allen wrote:
> One feature I'd love to see is support for keyword arguments when
> calling a function. When a function looks like:
>
> void MyObject::Function(int x, int y, int z = 0 int z2 = 5 int z3 = 10)
>
> it would be nice to be able to do something like:
>
> a.Function(x, y, z3 <-- 20)
>
> to specify a value for z3 without changing/specifying defaults for z and
> z2.


Some programmers argue that default function parameter values are
actually bad design, at least if there are many of them. Personally I
can't decide one way or the other (but I do find them handy in many cases).
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Are c++ features a subset of java features? BillJosephson C++ 148 01-27-2007 11:40 AM
ANN: New book on Java 5.0 new features & SCJP 5.0 upgrade exam kent@cpttm.org.mo Java 0 12-03-2006 02:04 AM
Two favorite features of C++, and over-rated, and misued features Jonathan Mcdougall C++ 2 11-03-2005 06:22 PM
"Monitoring Wireless Connection Transfer Rate...suggested software =?Utf-8?B?SmltLi4u?= Wireless Networking 1 06-14-2005 02:56 PM
Suggested material for A+ exam MJBrown Microsoft Certification 2 12-03-2003 12:47 AM



Advertisments