home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16826 < prev    next >
Encoding:
Internet Message Format  |  1992-11-24  |  2.6 KB

  1. Xref: sparky comp.lang.c++:16826 comp.std.c++:1615
  2. Newsgroups: comp.lang.c++,comp.std.c++
  3. Path: sparky!uunet!munnari.oz.au!sol.deakin.OZ.AU!news.cs.uow.edu.au!cssc-syd.tansu.com.au!pete
  4. From: pete@cssc-syd.tansu.com.au (Peter Alexander Merel)
  5. Subject: Re: Proposal - enhancement for switch statement.
  6. Message-ID: <1992Nov24.024600.26040@cssc-syd.tansu.com.au>
  7. Organization: AOTC - CSSC
  8. References: <1992Nov16.004558.9855@muddcs.claremont.edu> <1992Nov16.213015.1@vax1.bham.ac.uk> <1992Nov19.163944.19935@ucc.su.OZ.AU> <1992Nov20.195059.1@vax1.bham.ac.uk>
  9. Date: Tue, 24 Nov 1992 02:46:00 GMT
  10. Lines: 56
  11.  
  12. mccauleyba@vax1.bham.ac.uk (Brian McCauley) writes:
  13.  
  14. >In article <1992Nov19.163944.19935@ucc.su.OZ.AU>, maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  15. >[It's illegal]
  16. >Of course it's illegal!
  17. >What is being discussed is the merit of allowing the switch command to 
  18. >accept an argument of any type and resolve cases using the appropriate == 
  19. >operator.
  20.  
  21. Or any extension that achieves the same end - to allow switch to deal with
  22. types that don't go onto int.
  23.  
  24. >no such thing as a compile-time class object constant this implies that
  25. >the case clause would have to be able to take an expression if
  26. >this proposal were accepted. 
  27.  
  28. Yes.
  29.  
  30. >It would also mean that switch was not
  31. >a primitive operation (unless it happened to obey C rules in which
  32. >case it would optimize back to a primative operation). 
  33.  
  34. So far no one's suggested a reason this could not be made so.
  35.  
  36. >The ability for
  37. >the compiler to detect duplicate cases would also be lost when varaible
  38. >expressions where use in case clauses (or when the == operator was not
  39. >inline). 
  40.  
  41. The compiler can still check for duplicate cases when switch devolves to 
  42. the simple C variety, and of course this won't break code (it is more 
  43. permissive than otherwise).
  44.  
  45. >The range issue was introduced as an amendment and I was demonstrating
  46. >that it was redundant given the implications of the original proposal.
  47.  
  48. Yah.
  49.  
  50. >IMHO...
  51. >On balance the extension of switch to operate on any class is probably
  52. >unecessary and the extension to case to take ranges is therefore a good idea. 
  53.  
  54. I'd rather have a simple semantic extension that does the job for a broad
  55. range of expressions than a syntactic hack that doesn't do much of the
  56. job at all. Ranges won't, for a good instance, allow use of switch with
  57. string classes.
  58.  
  59. >Adding a new syntax (or worse still token) to the language should not
  60. >be done lightly.
  61.  
  62. You ain't just whistling dixie.
  63.  
  64. -- 
  65. Internet: pete@cssc-syd.tansu.com.au   UUCP: {uunet,mcvax}!munnari!cssc-syd!pete
  66. Snail: 1/18-20 Orion Road, Lane Cove NSW 2066 Australia    Phone: +61 2 911 3130
  67. I am a big pond in a small fish.
  68.