home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16330 < prev    next >
Encoding:
Text File  |  1992-11-15  |  2.2 KB  |  46 lines

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