home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!stanford.edu!EE.Stanford.EDU!sierra!mcgrant
- From: mcgrant@rascals.stanford.edu (Michael C. Grant)
- Subject: Two things: typeof() and exceptions
- Message-ID: <MCGRANT.92Nov15134127@rascals.stanford.edu>
- Sender: usenet@EE.Stanford.EDU (Usenet)
- Organization: Information Systems Laboratory, Stanford University
- Date: 15 Nov 92 13:41:27
- Lines: 35
-
-
- First of all, I'm disappointed that the typeof() operator suggestion did
- not generate much discussion, save a couple of e-mail messages. Don't you
- think that it would extend the utility of templates?
-
- One person pointed out that, in my example,
- template <class T> class Foo { ---> <double> <complex>
- T data; ---> double data; complex data;
- typeof(abs(T)) norm; ---> double norm; double norm;
- } --->
- that it must be considered that abs(const T&) should be a possible
- substitution as well (thought the tone of his message was that he
- didn't think it was necessary). Well, I agree that abs(const T&) should
- be considered by typeof(abs(T)), since standard overloading would
- consider it, but perhaps then the syntax is a bit confusing.
-
- Secondly, I was reading the reference manual for Dylan (Apple's new OO
- language) and I noticed something that was pretty hot in the exception-
- handling domain. Basically, in any given procedure you can define a set
- of instructions that are guaranteed to be executed even if the rest of
- the procedure is terminated early due to an exception. Currently in C++,
- automatic variables are destroyed as the stack is unwound. But, with
- a set of 'unwind' statements in a function, I could destroy all of the
- variables I allocated on the heap as well.
-
- If I had the Dylan manual with me I'd give you the exact syntax and
- description. But, if you understand that last paragraph, please
- comment! Note that that behavior could be simulated by defining a
- class local to that function that contains in its destructor all of
- the said 'unwinid' statements. Then, when that class is destroyed by
- the stack-unwinding procedure it would give the desired effect. But,
- since exceptions haven't been implemented on a wide basis yet perhaps
- the Dylan model can be considered.
-
- Michael C. Grant
-