Re: dead code or otherwise, was Alternative C compilers on x86_64 Linux?

Kaz Kylheku <221-501-9011@kylheku.com>
Fri, 9 Sep 2016 06:05:44 +0000 (UTC)

          From comp.compilers

Related articles
Alternative C compilers on x86_64 Linux? arnold@skeeve.com (2016-09-02)
Re: Alternative C compilers on x86_64 Linux? bc@freeuk.com (BartC) (2016-09-05)
Re: Alternative C compilers on x86_64 Linux? 221-501-9011@kylheku.com (Kaz Kylheku) (2016-09-06)
Re: Alternative C compilers on x86_64 Linux? bc@freeuk.com (BartC) (2016-09-06)
Re: dead code or otherwise, was Alternative C compilers on x86_64 Linu gneuner2@comcast.net (George Neuner) (2016-09-08)
Re: dead code or otherwise, was Alternative C compilers on x86_64 Linu 221-501-9011@kylheku.com (Kaz Kylheku) (2016-09-08)
Re: dead code or otherwise, was Alternative C compilers on x86_64 Linu gneuner2@comcast.net (George Neuner) (2016-09-09)
Re: dead code or otherwise, was Alternative C compilers on x86_64 Linu 221-501-9011@kylheku.com (Kaz Kylheku) (2016-09-09)
Re: dead code or otherwise, was Alternative C compilers on x86_64 Linu gneuner2@comcast.net (George Neuner) (2016-09-09)
Re: dead code or otherwise, was Alternative C compilers on x86_64 Linu 221-501-9011@kylheku.com (Kaz Kylheku) (2016-09-09)
| List of all articles for this month |
From: Kaz Kylheku <221-501-9011@kylheku.com>
Newsgroups: comp.compilers
Date: Fri, 9 Sep 2016 06:05:44 +0000 (UTC)
Organization: Aioe.org NNTP Server
References: 16-09-001 16-09-005 16-09-009 16-09-012 16-09-015 16-09-016 16-09-017
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

On 2016-09-09, George Neuner <gneuner2@comcast.net> 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))
#<COMPILED-FUNCTION NIL> ;
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


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.