From 2364121328166419379 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f78e5,5be30c38f618a07b X-Google-Attributes: gidf78e5,public X-Google-ArrivalTime: 2002-05-23 17:47:51 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!kibo.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail From: news_comp.std.c++_expires-2002-07-01@nmhq.net (Niklas Matthies) Newsgroups: comp.std.c++ Subject: Re: Why switch w/ only integral types? Date: Fri, 24 May 2002 00:36:54 GMT Organization: Team Rocket Approved: Fergus Henderson , moderator of comp.std.c++ Message-ID: References: <6ee7d287.0203202005.63e0b7b3@posting.google.com> <3CCE6310.672E55DF@webmaster.com> <3CED0FA3.1050102@mail.com> X-Trace: mail2news.demon.co.uk 1022201024 mail2news:22755 mail2news mail2news.demon.co.uk X-Complaints-To: abuse@demon.net X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov) X-Orig-NNTP-Posting-Host: p508afca3.dip.t-dialin.net (80.138.252.163) X-Orig-X-Trace: fu-berlin.de 1022191340 27563393 80.138.252.163 (16 [27100]) User-Agent: slrn/0.9.7.1 (Linux) Lines: 30 Xref: archiver1.google.com comp.std.c++:11474 On Thu, 23 May 2002 17:15:07 GMT, Hyman Rosen wrote: > Hans Aberg wrote: > > cases (v) { > > case e_1: s_1; > > ... > > case e_k: s_k; > > }; > > Why in the world would anyone add a new language construct for this? > Just do > > const v_type &v_ref = v; > if (v_ref == e_1) { s_1; } > else if (v_ref == e_2) { s_2; } > ... > else if (v_ref == e_k) { s_k; } The proposed construct seems a lot more readable and concise than your solution. That's one reason why. -- Niklas Matthies -- Never attribute to malice what can be explained by sheer stupidity. --- [ 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 ]