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


Groups > comp.lang.c > #67072

Re: Untyped Variables

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Untyped Variables
Date 2015-08-10 08:41 -0700
Organization None to speak of
Message-ID <lna8tzdubu.fsf@kst-u.example.com> (permalink)
References (1 earlier) <55C61BBF.8090302@verizon.net> <ln37ztfte6.fsf@kst-u.example.com> <8eb33dc8-5c47-4b7b-a20e-584166a50d58@googlegroups.com> <lnr3nde23c.fsf@kst-u.example.com> <55f47816-7e96-4592-937c-76da266a3b7a@googlegroups.com>

Show all headers | View raw


David Kleinecke <dkleinecke@gmail.com> writes:
> On Saturday, August 8, 2015 at 4:37:47 PM UTC-7, Keith Thompson wrote:
>> David Kleinecke <dkleinecke@gmail.com> writes:
>> [...]
>> > The answer is in the list of possible types given as a constraint in 
>> > 6.5.2 which in the 1990 standard includes:
>> >     int, signed, signed 1nt, or no type specifier.
>> > I haven't been thinking of constraints as part of syntax. I like to keep
>> > a clear separation between syntax and semantics so I imagine some
>> > constraints are syntactic and some semantic. I need to do some research
>> > because it is not obvious that there is no third possibility lying 
>> > between syntax and semantics.
>> 
>> There are two kinds of rules whose violation requires a diagnostic,
>> syntax rules and contraints.  Syntax rules are expressed in the grammar
>> in something resembling BNF.  Constraints are expressed in English text
>> in sections labeled "Constraints".
>  
> I would expect semantic rules to also issue diagnostic messages. But, at 
> least in theory, we could make two passes - a syntax pass and a semantic 
> pass because semantic failures do not impact on syntax (except, of course,
> in the case of tydef names). 

In theory, the grammar could specify that a translation unit is a
sequence of characters, with all rules expressed in English as
constraints.  Such a description would be extraordinarily unwieldy.

> So, roughly, I would group those constraints that cause a parsing failure
> with syntax and the rest with semantics. But I am still unsure that any  
> constraints are syntactic. 

I'm not sure either.  The boundary between syntax rules and constraints
is somewhat arbitrary, though there are many constraints that cannot be
expressed as syntax (for example those restricting the types of
operands).  It's possible that some rules are expressed as constraints
rather than as syntax rules simply for convenience.

It's easy enough to search the standard for the word "Constraints" to
see if any of them could have been expressed in syntax.  I haven't taken
the time to do so.

[...]

> So you're agreeing with me that there is no third stage - constraints
> are either syntactic or semantic  - and, putting words into your mouth,
> expeted to be semantic.

I'm not sure what a "third state" would be.  Certainly *most*
constraints are semantic (meaning that they can't, or can't easily, be
expressed in the grammar).

> PS: Typedef names appear to require semantic feedback into syntax. It
> is inelegant but unescapable.

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

Untyped Variables David Kleinecke <dkleinecke@gmail.com> - 2015-08-07 18:19 -0700
  Re: Untyped Variables Lőrinczy Zsigmond <nospam@for.me> - 2015-08-08 06:53 +0200
  Re: Untyped Variables James Kuyper <jameskuyper@verizon.net> - 2015-08-08 11:09 -0400
    Re: Untyped Variables Keith Thompson <kst-u@mib.org> - 2015-08-08 12:09 -0700
      Re: Untyped Variables James Kuyper <jameskuyper@verizon.net> - 2015-08-08 14:24 -0400
    Re: Untyped Variables Keith Thompson <kst-u@mib.org> - 2015-08-08 12:54 -0700
      Re: Untyped Variables David Kleinecke <dkleinecke@gmail.com> - 2015-08-08 16:06 -0700
        Re: Untyped Variables Keith Thompson <kst-u@mib.org> - 2015-08-08 17:29 -0700
          Re: Untyped Variables David Kleinecke <dkleinecke@gmail.com> - 2015-08-09 17:52 -0700
            Re: Untyped Variables Ian Collins <ian-news@hotmail.com> - 2015-08-10 12:57 +1200
            Re: Untyped Variables Keith Thompson <kst-u@mib.org> - 2015-08-10 08:41 -0700
              Re: Untyped Variables David Kleinecke <dkleinecke@gmail.com> - 2015-08-10 17:06 -0700
        Re: Untyped Variables Richard Damon <Richard@Damon-Family.org> - 2015-08-08 19:44 -0400
        Re: Untyped Variables James Kuyper <jameskuyper@verizon.net> - 2015-08-08 20:34 -0400
          Re: Untyped Variables glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-08-09 02:03 +0000
            Re: Untyped Variables Richard Damon <Richard@Damon-Family.org> - 2015-08-08 22:52 -0400
              Re: Untyped Variables glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-08-09 04:57 +0000
                Re: Untyped Variables Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2015-08-09 09:58 -0600
                Re: Untyped Variables Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-08-10 03:54 -0700
                Re: Untyped Variables Richard Damon <Richard@Damon-Family.org> - 2015-08-09 16:59 -0400
          Re: Untyped Variables David Kleinecke <dkleinecke@gmail.com> - 2015-08-09 18:02 -0700
            Re: Untyped Variables James Kuyper <jameskuyper@verizon.net> - 2015-08-10 11:01 -0400
              Re: Untyped Variables James Kuyper <jameskuyper@verizon.net> - 2015-08-10 13:20 -0400
              Re: Untyped Variables David Kleinecke <dkleinecke@gmail.com> - 2015-08-10 16:54 -0700
                Re: Untyped Variables James Kuyper <jameskuyper@verizon.net> - 2015-08-11 00:20 -0400
            Re: Untyped Variables Keith Thompson <kst-u@mib.org> - 2015-08-10 08:11 -0700
              Re: Untyped Variables David Kleinecke <dkleinecke@gmail.com> - 2015-08-10 17:15 -0700
                Re: Untyped Variables James Kuyper <jameskuyper@verizon.net> - 2015-08-11 00:30 -0400
                Re: Untyped Variables David Kleinecke <dkleinecke@gmail.com> - 2015-08-11 16:50 -0700
                Re: Untyped Variables Keith Thompson <kst-u@mib.org> - 2015-08-11 17:24 -0700
                Re: Untyped Variables Richard Heathfield <rjh@cpax.org.uk> - 2015-08-12 01:37 +0100
                Re: Untyped Variables glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-08-12 04:46 +0000
                Re: Untyped Variables David Kleinecke <dkleinecke@gmail.com> - 2015-08-12 18:12 -0700
                Re: Untyped Variables Keith Thompson <kst-u@mib.org> - 2015-08-13 12:08 -0700
                Re: Untyped Variables David Kleinecke <dkleinecke@gmail.com> - 2015-08-13 16:25 -0700
                Re: Untyped Variables Keith Thompson <kst-u@mib.org> - 2015-08-14 10:36 -0700
                Re: Untyped Variables Bartc <bc@freeuk.com> - 2015-08-14 19:13 +0100
                Re: Untyped Variables Keith Thompson <kst-u@mib.org> - 2015-08-11 07:58 -0700
          Re: Untyped Variables richard@cogsci.ed.ac.uk (Richard Tobin) - 2015-08-10 13:53 +0000
            Re: Untyped Variables Keith Thompson <kst-u@mib.org> - 2015-08-10 08:29 -0700
              Re: Untyped Variables David Kleinecke <dkleinecke@gmail.com> - 2015-08-10 17:01 -0700
                Re: Untyped Variables Keith Thompson <kst-u@mib.org> - 2015-08-10 17:42 -0700
                Re: Untyped Variables glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-08-11 02:56 +0000
            Re: Untyped Variables David Kleinecke <dkleinecke@gmail.com> - 2015-08-10 16:50 -0700
              Re: Untyped Variables Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-08-11 01:39 +0100
                Re: Untyped Variables Keith Thompson <kst-u@mib.org> - 2015-08-10 19:03 -0700
                Re: Untyped Variables Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-08-11 11:21 +0100
                Re: Untyped Variables David Kleinecke <dkleinecke@gmail.com> - 2015-08-11 16:37 -0700

csiph-web