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


Groups > comp.lang.c > #112081

Re: Scope of identifiers

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Scope of identifiers
Date 2017-06-12 13:19 -0700
Organization None to speak of
Message-ID <lnwp8hez7v.fsf@kst-u.example.com> (permalink)
References <ohmea9$nft$1@gioia.aioe.org> <lnink1gnzy.fsf@kst-u.example.com> <081872d4-3f9d-0004-8c0d-25a274bba7bb@verizon.net> <ln60g1gfmy.fsf@kst-u.example.com> <e74c416a-d6e4-7f4d-e939-ec5f0cfd010b@verizon.net>

Show all headers | View raw


"James R. Kuyper" <jameskuyper@verizon.net> writes:
> On 06/12/2017 03:39 PM, Keith Thompson wrote:
>> "James R. Kuyper" <jameskuyper@verizon.net> writes:
> ...
>>> I think the fundamental problem is at a slightly higher level. They had
>>> two concepts of scope, and tried to use the same name for both concepts.
>>> I think it would have been easier to describe things clearly if they had
>>> used two different terms for the two concepts. I'll use "visibility
>>> range" for one of the two, and "scope" for the other. Everything below
>>> is my suggestion how the standard could be re-written for clarity on
>>> this issue (it certainly does NOT describe what the standard currently
>>> says). My intent is to leave the actual meaning of the standard's words
>>> unchanged: if my suggestion fails to do that, it is my re-wording that
>>> is at fault.
>>>
>>> Suggested conceptual reorganization:
>>
>> Summary: For a declaration in a block, an identifiers "visibility range"
>> is the same as what the standard currently calls its "scope", and
>> extends from the declaration to the end of the block.  Its "scope" (new
>> meaning) extends from the beginning of the block to the end of the
>> block.  (Glossing over, for now, what these terms mean for scopes other
>> than block scope.)
>>
>> I haven't checked, but I can't think of anything in the standard that
>> refers to your new wider "scope" other than the definition of the term
>> "same scope".
>
> If you're right (and that seems plausible) I'd take that as a 
> justification for retaining "scope" for the first meaning, rather than 
> the second one. Reserve the new, more complicated term for the second 
> meaning.
>
>> A good goal, but I'm still not convinced that inventing a new term,
>> rather than using something like "matching scope" rather than "same
>> scope", is necessary.
>
> The term "matching scope" does not admit to a unique obvious meaning 
> that fits, so what it means for two scopes to match would have to be 
> defined. With an appropriate definition of some alternative term 
> ("extended scope"?), the meaning of "same extended scope" should be 
> sufficiently clear that it doesn't need to be explicitly defined.

What you suggest calling an "extended scope" isn't really a scope (a
region of program text within which a given identifier is visible).  I'd
rather not introduce a term such that an "<adjective> <noun>" is not an
example of a "<noun>".

What I proposed was to replace the current definition of "same scope"
(which is problematic because two non-identical scopes can be the "same
scope") by something like "matching scope".  (I'm open to a better
adjective than "matching".)  I think that solves the (minor) problem of
"same scope" being confusing, it doesn't add to the number of defined
terms, and it's a fairly minimal change.

-- 
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

Scope of identifiers Steve Keller <keller@no.invalid> - 2017-06-12 18:08 +0200
  Re: Scope of identifiers "James R. Kuyper" <jameskuyper@verizon.net> - 2017-06-12 12:22 -0400
    Re: Scope of identifiers Keith Thompson <kst-u@mib.org> - 2017-06-12 09:39 -0700
  Re: Scope of identifiers Keith Thompson <kst-u@mib.org> - 2017-06-12 09:38 -0700
    Re: Scope of identifiers "James R. Kuyper" <jameskuyper@verizon.net> - 2017-06-12 14:41 -0400
      Re: Scope of identifiers Keith Thompson <kst-u@mib.org> - 2017-06-12 12:39 -0700
        Re: Scope of identifiers "James R. Kuyper" <jameskuyper@verizon.net> - 2017-06-12 15:53 -0400
          Re: Scope of identifiers Keith Thompson <kst-u@mib.org> - 2017-06-12 13:19 -0700
            Re: Scope of identifiers David Kleinecke <dkleinecke@gmail.com> - 2017-06-13 11:01 -0700
              Re: Scope of identifiers jameskuyper@verizon.net - 2017-06-13 11:25 -0700
              Re: Scope of identifiers Keith Thompson <kst-u@mib.org> - 2017-06-13 12:16 -0700
                Re: Scope of identifiers David Kleinecke <dkleinecke@gmail.com> - 2017-06-13 21:02 -0700
                Re: Scope of identifiers Ian Collins <ian-news@hotmail.com> - 2017-06-14 21:53 +1200
                Re: Scope of identifiers supercat@casperkitty.com - 2017-06-14 08:10 -0700
                Re: Scope of identifiers Keith Thompson <kst-u@mib.org> - 2017-06-14 09:19 -0700
                Re: Scope of identifiers supercat@casperkitty.com - 2017-06-14 10:14 -0700
                Re: Scope of identifiers Keith Thompson <kst-u@mib.org> - 2017-06-14 09:12 -0700
  Re: Scope of identifiers Robert Wessel <robertwessel2@yahoo.com> - 2017-06-12 13:02 -0500

csiph-web