Topic: Extending the expressiveness of unions - has it been discussed before?


Author: stefan_heinzmann@yahoo.com (Stefan Heinzmann)
Date: Fri, 29 Apr 2005 03:55:09 GMT
Raw View
Hi all,

unions in current C++ are rather limited creatures, which others have
noted before (see for example Alexandrescu's work on discriminated
unions). Is there any movement towards extending the standard towards
more capable unions?

I would be interested in particular in unions that can hold real
objects. That of course would mean to destruct the "current" member in
place, and constructing another in the same memory when the "current"
type gets changed. It would be particularly cute if this destruction and
construction were partial if the old and the new "current" type shared
common base classes. I can see interesting applications for this in
hierarchical state machines, for example.

This would support the notion of "in-place object mutation". A way of
initiating such a mutation would be needed (another kind of cast, maybe).

Or is there a reasonable way how this can be implemented with the
current language?

Cheers
Stefan

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: francis@robinton.demon.co.uk (Francis Glassborow)
Date: Fri, 29 Apr 2005 20:34:41 GMT
Raw View
In article <d4qiat$sac$00$1@news.t-online.com>, Stefan Heinzmann
<stefan_heinzmann@yahoo.com> writes
>Hi all,
>
>unions in current C++ are rather limited creatures, which others have
>noted before (see for example Alexandrescu's work on discriminated
>unions). Is there any movement towards extending the standard towards
>more capable unions?

AFAIR there are no proposals on the table at the moment. If you want to
make one you better do so very soon as we are about to close out
accepting new proposals for language (rather than library) change. Even
now the probability that new papers will actually get floor time is
small unless they are already very mature and have taken consideration
of the proposal's interaction with the rest of the language.


--
Francis Glassborow      ACCU
Author of 'You Can Do It!' see http://www.spellen.org/youcandoit
For project ideas and contributions: http://www.spellen.org/youcandoit/projects

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]