Re: Bug in C++ /CLI 2005
- From: "Mark Salsbery [MVP]" <MarkSalsbery[MVP]@newsgroup.nospam>
- Date: Thu, 9 Oct 2008 11:08:35 -0700
"Ben Voigt [C++ MVP]" <rbv@xxxxxxxxxxxxx> wrote in message news:ex5QaOhKJHA.1160@xxxxxxxxxxxxxxxxxxxxxxx
Mark Salsbery [MVP] wrote:"Howard Swope" <howard_swopeAThms3DOTcom> wrote in message
news:Oyv$tJgJJHA.1308@xxxxxxxxxxxxxxxxxxxxxxx
Declaring variables with stack semantics is one of the Advertised
features in C++ CLI
Not member variables.
It makes no sense to have member variables with stack semantics -
there's no "stack" involved unless you have an actual object.
I definitely do NOT agree with this. Stack semantics give you all the correct calls to Dispose in all the corner cases, like exceptions thrown in constructor initializer lists, automatically. Stack semantics is perhaps not the best description -- scoped variable lifetime (vs dynamic lifetime) might be better.
Hi Ben,
How does scoped variable lifetime apply to member variables?
The scoped variable lifetime of a member variable is determined by it's containing class, right?
For this to work, the compiler would need to generate the gcnew calls for the member variables. That means one would be stuck with a parameterless constructor, unless some (possibly obscure) construct syntax was added to the language to allow other constructor calls for these "automatic" variables.
I imagine a similar argument occurred when this feature of the language was designed. :)
Is it a bug or by design?
I still think, given the way it currently works, that stack semantics on ref class member variables shouldn't be allowed.
Mark
--
Mark Salsbery
Microsoft MVP - Visual C++
.
- Follow-Ups:
- Re: Bug in C++ /CLI 2005
- From: Ben Voigt [C++ MVP]
- Re: Bug in C++ /CLI 2005
- References:
- Bug in C++ /CLI 2005
- From: Howard Swope
- Re: Bug in C++ /CLI 2005
- From: Mark Salsbery [MVP]
- Re: Bug in C++ /CLI 2005
- From: Ben Voigt [C++ MVP]
- Bug in C++ /CLI 2005
- Prev by Date: Re: How to detect multiple lib versions?
- Next by Date: Re: Bug in C++ /CLI 2005
- Previous by thread: Re: Bug in C++ /CLI 2005
- Next by thread: Re: Bug in C++ /CLI 2005
- Index(es):
Relevant Pages
|