Path: csiph.com!news.mixmin.net!enother.net!enother.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: Kaz Kylheku <221-501-9011@kylheku.com> Newsgroups: comp.compilers Subject: Re: dead code or otherwise, was Alternative C compilers on x86_64 Linux? Date: Fri, 9 Sep 2016 06:05:44 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 40 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <16-09-018@comp.compilers> References: <16-09-001@comp.compilers> <16-09-005@comp.compilers> <16-09-009@comp.compilers> <16-09-012@comp.compilers> <16-09-015@comp.compilers> <16-09-016@comp.compilers> <16-09-017@comp.compilers> Injection-Info: miucha.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="33577"; mail-complaints-to="abuse@iecc.com" Keywords: C, optimize Posted-Date: 09 Sep 2016 11:50:05 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:1757 On 2016-09-09, George Neuner wrote: > But like any good Usenet discussion, it (d)evolved into something more > general. > > Not every language with a CASE like construct has C's limitations on > specifying the alternatives. Lisp certainly doesn't. Yes, it does, in fact. The labels in Lisp case are literals that are embedded in the CASE syntax itself, and not evaluated. They are compared to the input value using EQL equality. Duplicate cases are a bug, which is not required to be diagnosed. CLISP: [1]> (case 'a (a 1) (a 2)) ;; (a 2) unreachable 1 [2]> (compile nil (lambda () (case 'a (a 1) (a 2)))) WARNING: Duplicate CASE label A : (CASE 'A (A 1) (A 2)) # ; 1 ; NIL > In fact, many (non-Lisp) compilers do implement CASE like constructs > using chained IF performing a binary search when the set of > alternatives is either sparse enough or large enough to make using a > dispatch table unweildy (or mostly empty). Still, duplicates which are static literals should be diagnosed, even if computed labels are allowed that can produce duplicates at run time, and that isn't diagnosed. case value of computed(): ... computed(): # at compile time, we trust this is different ... 3: ... 3: # obviously clashing, diagnose damn thing! endcase