Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.c Subject: Re: "...the value becomes,indeterminate each time the declaration is reached" Date: Sun, 10 Feb 2019 16:51:36 +0000 Organization: A noiseless patient Spider Lines: 87 Message-ID: <87ftsva8o7.fsf@bsb.me.uk> References: <20190204120834.7d3f84f25052b6a8315f693a@g{oogle}mail.com> <30065f8f-0b5b-4d17-846f-4fa63051cd0e@googlegroups.com> <9d6896dc-a369-4eb0-a93c-c0317a19908e@googlegroups.com> <7615cc12-0e98-4917-a0d0-682c7aeabeb5@googlegroups.com> <8736oze00i.fsf@bsb.me.uk> <3f4afc9e-c532-4ee1-93f6-d6872c55928c@googlegroups.com> <87h8debdlm.fsf@bsb.me.uk> <6cc27732-6b74-4503-88e6-e0b991615a2a@googlegroups.com> <875ztub1vq.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="5c595da6dcefa6922b7d6848baf5c22b"; logging-data="29498"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Z1S5Lb+Gm79ZRwvXqIO2bcyFVgukIJJk=" Cancel-Lock: sha1:ZD4i1k2A4+QjNCLRlwt5k4t4CHU= sha1:l4lpG+Z95GckTWgfseoWIS13vuE= X-BSB-Auth: 1.be77d57b945cdf656258.20190210165136GMT.87ftsva8o7.fsf@bsb.me.uk Xref: csiph.com comp.lang.c:140829 Malcolm McLean writes: > On Friday, 8 February 2019 17:56:21 UTC, Ben Bacarisse wrote: >> Malcolm McLean writes: >> >> > On Friday, 8 February 2019 13:43:13 UTC, Ben Bacarisse wrote: >> >> Malcolm McLean writes: >> >> >> >> > On Thursday, 7 February 2019 21:56:07 UTC, Ben Bacarisse wrote: >> >> >> >> >> ... But then many languages have programs >> >> >> with no meaning at run-time. You are then using the term "grammar" as >> >> >> Malcolm used it. Run-time undefined programs are >> >> >> un-Malcolm-grammatical. >> >> >> >> >> > The grammar is the set of rules that distinguish meaningful from non-meaningful >> >> > "productions". >> >> >> >> Why the scare quotes? >> >> >> >> Provided it is safe the assume the "productions" are just productions, >> >> your description is confusing me. A grammar is a set of rules that >> >> state what productions are applicable at any point in a derivation. Is >> >> that what you mean -- that applicable productions are meaningful and >> >> those that can't be applied are not? If that is /not/ what you mean, >> >> you need to explain how meaning comes into it in Malcolm-grammars. >> >> >> >> Finally, what's the connection with what you've been calling >> >> ungrammatical programs -- which include those with run-time undefined >> >> behaviour? >> >> >> > Yes, you can only apply meaningful strings. So in computer theory, we >> > can define a "meaningful string" as "something the compiler will turn >> > into an executable". Then you can program the grammar into the computer. >> > If we define "meaningful string" as "something the compiler will turn >> > into a program with defined behaviour" and the language is C, we can no >> > longer in practice program the grammar into the computer. Undefined >> > behaviour is an admission that the rules of the language have broken >> > down or in other words, that the grammar isn't complete. >> >> That's not how I'd put it. Undefined behaviour in C is a conscious >> decision not to specify the semantics of certain constructs and run-time >> events. It's not an admission of some flaw in the rules, it's a >> deliberate property of the rules. >> >> No practical grammars come close to defining meaningful strings in >> either of your senses[1]. Only a subset of context-free grammars >> can be parsed efficiently by current algorithms, and they will permit >> all sorts meaningless C programs. >> > A compiler turns some strings into executables and rejects others. So > it has grammar rules, in the first sense. What's confusing you is that > in basic computer science class rules for composing strings like "aab > aaaabaabaaaaab" are described as "grammars". The strings have a form, > but don't mean anything. So the so-called "grammar" actually lacks an > essential attribute of grammar. Then it's not sufficient, it needs > extra higher level rules if it is to specify a real programming > language. Why do you think I'm confused by this? When I said "no practical grammars come close to defining meaningful strings in either of your senses" I was (I'd hoped) making it perfectly clear that others (the impractical ones) can do what you mean. What's more I posted about attribute grammars which would, I'd have thought, flagged the fact I know about /some/ ways in which pure syntax /and/ semantics can be defined. (Don't take this as an endorsement -- I suspect that attribute grammars won't go much further than they did in the first 20 years.) The trouble with your most general statement -- about undefined behaviour being ungrammatical -- is that the implied grammar would be undecidable. That makes the point dubious even in the most abstract and purely theoretical sense. >> > Remember that the producer is not a program, it's a human programmer >> > applying or trying to apply the rules to communicate his intention. >> >> And sometimes her intentions. >> > That's a grammar rule. The male embraces the female. Currently under > challenge. The words we use are useful social indicators. -- Ben.