Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #67518

Re: Labels

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Labels
Date 2015-08-15 19:47 -0700
Organization None to speak of
Message-ID <lnbne87xuo.fsf@kst-u.example.com> (permalink)
References (2 earlier) <874mk0goix.fsf@bsb.me.uk> <55CFC58E.5090600@verizon.net> <87mvxsf713.fsf@bsb.me.uk> <55CFD75B.6020102@verizon.net> <mqon12$20n$1@dont-email.me>

Show all headers | View raw


Bartc <bc@freeuk.com> writes:
> On 16/08/2015 01:20, James Kuyper wrote:
>> On 08/15/2015 07:47 PM, Ben Bacarisse wrote:
>
>>> ... I don't see any connection with the original issue
>>> of labels.
>>
>> Until you read the following ':', you can't distinguish a label that has
>> the same name as a typedef from a typedef used as the first token of a
>> declaration. And that's one of the three reasons (the other two are
>> object names and function names) why the ':' must (in some cases) be
>> read before a statement label can be unambiguously identified as such.
>
> You mean that a label can have the same name as a typedef within the 
> same function scope?

Yes.

> Interesting. (And ... why?)

An identifier is a label name if and only if appears either before the
":" in a labelled statement or it appears following a "goto" keyword, so
there's no ambiguity if a label name happens to match a non-label
identifier.  (Similarly, struct tags can only follow a "struct"
keyword.)

And since labels needn't be predeclared, it might be awkward to diagnose
conflicts if they weren't in their own namespace.  I haven't given that
a lot of though, so I'm not entirely sure about it.

Using the same identifier for a label and for something else is probably
a bad idea, but it's not forbidden, and I suspect that just makes the
compiler's job a little easier (something that would have been more
important when the language was designed).

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Labels David Kleinecke <dkleinecke@gmail.com> - 2015-08-15 09:46 -0700
  Re: Labels James Kuyper <jameskuyper@verizon.net> - 2015-08-15 14:49 -0400
    Re: Labels David Kleinecke <dkleinecke@gmail.com> - 2015-08-15 18:48 -0700
  Re: Labels Bartc <bc@freeuk.com> - 2015-08-15 18:27 +0100
    Re: Labels Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-08-15 23:44 +0100
      Re: Labels James Kuyper <jameskuyper@verizon.net> - 2015-08-15 19:04 -0400
        Re: Labels Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-08-16 00:47 +0100
          Re: Labels James Kuyper <jameskuyper@verizon.net> - 2015-08-15 20:20 -0400
            Re: Labels Bartc <bc@freeuk.com> - 2015-08-16 01:56 +0100
              Re: Labels Keith Thompson <kst-u@mib.org> - 2015-08-15 19:47 -0700
                Re: Labels James Kuyper <jameskuyper@verizon.net> - 2015-08-16 11:59 -0400
            Re: Labels Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-08-16 22:42 +0100
              Re: Labels James Kuyper <jameskuyper@verizon.net> - 2015-08-16 20:39 -0400
                Re: Labels Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-08-17 03:16 +0100
        Re: Labels David Kleinecke <dkleinecke@gmail.com> - 2015-08-15 19:01 -0700
      Re: Labels Bartc <bc@freeuk.com> - 2015-08-16 01:11 +0100
        Re: Labels Keith Thompson <kst-u@mib.org> - 2015-08-15 19:13 -0700
          Re: Labels Bartc <bc@freeuk.com> - 2015-08-16 10:34 +0100
            Re: Labels Keith Thompson <kst-u@mib.org> - 2015-08-16 13:58 -0700
            Re: Labels David Kleinecke <dkleinecke@gmail.com> - 2015-08-16 20:42 -0700
              Re: Labels Keith Thompson <kst-u@mib.org> - 2015-08-16 21:24 -0700
                Re: Labels David Kleinecke <dkleinecke@gmail.com> - 2015-08-17 18:01 -0700
              Re: Labels Bartc <bc@freeuk.com> - 2015-08-17 11:04 +0100
        Re: Labels David Kleinecke <dkleinecke@gmail.com> - 2015-08-15 19:04 -0700
        Re: Labels Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-08-16 23:55 +0100
    Re: Labels David Kleinecke <dkleinecke@gmail.com> - 2015-08-15 19:00 -0700

csiph-web