public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Niall Douglas" <ned@nedprod.com>
To: gcc@gcc.gnu.org
Subject: Proposed C++ extension
Date: Fri, 30 Aug 2002 16:32:00 -0000	[thread overview]
Message-ID: <3D701B78.8275.2A4BC906@localhost> (raw)

Firstly, I'll apologise for not diving deep and producing a patch for 
g++. Last time I tried, I got very very lost ...

My suggestion is adding support for temporary object copy 
constructors - these differ from normal copy constructors in that 
when the object is being created by the compiler rather than the 
user, the temporary object copy constructor is called instead.

Why? Because C++ doesn't support multithreading very well. I have a 
number of implicitly shared classes for which I had to disable 
implicit sharing because of the potential of data corruption as it's 
impossible to synchronise all users of the implicit data without 
running through a mutex each time.

Unfortunately disabling implicit sharing creates performance problems 
in something like a string class. If we had a special copy 
constructor for temporary objects, we could do ptr copies for the 
temporary objects and the real copy constructor for the final object. 
Obviously, optimisation can decide when user created local objects 
are unnecessary, and hence optimise them into temporary land.

Anyway, if you were to add this, I'd stick the appropriate code into 
my implicitly shared-disabled classes. So would others I'm sure. 
String work would become much quicker.

The other suggestion is a precall and postcall handler whereby in 
every call to an object, the compiler wraps the call with the precall 
and postcall code. Again, it's use is for porting old code to become 
multithreading aware - but I can envisage other useful uses as well.

Anyway, those are my experiences from learning C++. I'm well into 
year three of learning it, but I'm still nowhere close to done!

Cheers,
Niall Douglas

             reply	other threads:[~2002-08-30 16:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-30 16:32 Niall Douglas [this message]
2002-08-31  7:09 ` Nathan Sidwell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3D701B78.8275.2A4BC906@localhost \
    --to=ned@nedprod.com \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).