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


Groups > comp.std.c > #6001

Re: Addition of nocode keyword

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.std.c
Subject Re: Addition of nocode keyword
Date 2019-10-26 22:52 +0100
Organization A noiseless patient Spider
Message-ID <87k18rtbsq.fsf@bsb.me.uk> (permalink)
References <942b0023-9e69-4fb1-b382-e720d87e0d62@googlegroups.com> <878sp8v44k.fsf@bsb.me.uk> <qp0agr$911$1@dont-email.me>

Show all headers | View raw


"Rick C. Hodgin" <rick.c.hodgin@gmail.com> writes:

> On 10/25/2019 6:42 PM, Ben Bacarisse wrote:
>> C already ... has an empty statement.  All of these are human-
>> language agnostic ways to do the same thing as "nocode".
>
> I'm not aware of them.  Can you teach me?

I am sure you know them; I must have simply not have been clear.

The expression in an expression statement is optional, as are the
contents of a compound statement, so

  ;
  {}
  {;}
  {;;}

and so on (with optional comments) are all increasing insistent ways of
saying that no code was really, really what was intended.

> In C today, how would you deterministically identify or signify
> that this block of code's logic test was intentionally left empty?
>
>     for (x = 0; ; ++x)
>     {
>         // Code here
>     }

I don't understand the question.  The best way to show intent to a
reader (when it really is in doubt) is with a comment, and the best was
to show intent to a compiler is by writing code with the intended
meaning.  Maybe I don't know what "deterministically identify" means.

If you are talking about giving permission for a compiler to issue a
warning for the above then it already has it.  It could, perfectly
legally, say something like "Did you intend to leave the condition
empty?  To silence this warning, write an explicitly always true
expression.".

> Or this one:
>
>     for (i = 0; ; )
>     {
>     }
>
> How do you know the empty portions weren't left out by mistake?

The surest way for me to know is to understand the code.  Have you come
across an example where such a thing is an accident and yet it's not
obviously wrong?  I feel (without evidence) that any code like that will
be bad code for all sorts of other, more significant, reasons so I'd
like to see an example.

> Without nocode or something like it, there's no way for the com-
> piler to know.

See above.  The compiler can be suspicious about anything it likes and
can warn the programmer along with offering advice about what will make
it (the compiler) shut up.  You could even document a special meaning
for an option: -Waccidentally-empty that turns on these warnings while at
the same time behaving like -Dnocode.  You could then write

  for (i = 0; nocode; nocode) nocode;

a get no warnings even when compiled with -Waccidentally-empty.

> There's no way for another developer to know
> either without something like this:
>
>     for (x = 0; /*no test here*/; ++x)
>     {
>         // Code here
>     }

I would hope there is!  Do you have an actual example where it is not
obvious that the empty test was intended?  If you do, at the very least,
the code needs a comment which probably should explain more than your
example comment does.

> But what if in this online world we get some code from some
> foreign language?  Rely on Google Translate to convey what it
> means?
>
>     for (x = 0; /*لا يوجد اختبار هنا*/; ++x)
>     {
>         // Code here
>     }
>
> There's no way to know with certainty, and that's the issue.

Unless you are proposing a breaking change by /insisting/ on something
compiler-checkable, then I don't see how your suggestion helps for code
written by anyone else.  Other people will always be able to write the
form you obect to, and they can currently write explicit always-true
expressions and explicitly empty code (of any degree of complexity) if
they feel the intent is not clear.  And if they don't think they need to
make themselves extra clear, they probably won't use any new keywords
either.

-- 
Ben.

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


Thread

Addition of nocode keyword "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-10-25 05:26 -0700
  Re: Addition of nocode keyword Philipp Klaus Krause <pkk@spth.de> - 2019-10-25 15:53 +0200
    Re: Addition of nocode keyword "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-10-25 07:26 -0700
      Re: Addition of nocode keyword Philipp Klaus Krause <pkk@spth.de> - 2020-08-04 11:00 +0200
  Re: Addition of nocode keyword "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-10-25 11:04 -0700
  Re: Addition of nocode keyword Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-10-25 23:42 +0100
    Re: Addition of nocode keyword "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-10-25 22:20 -0400
      Re: Addition of nocode keyword Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-10-26 22:52 +0100
        Re: Addition of nocode keyword Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-10-26 23:27 +0100
        Re: Addition of nocode keyword "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-10-26 17:19 -0700
  Re: Addition of nocode keyword Richard Damon <Richard@Damon-Family.org> - 2019-10-25 22:10 -0300
    Re: Addition of nocode keyword "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-10-25 19:02 -0700
      Re: Addition of nocode keyword Richard Damon <Richard@Damon-Family.org> - 2019-10-28 23:45 -0400
        Re: Addition of nocode keyword "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-10-29 08:15 -0400
          Re: Addition of nocode keyword "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-10-29 08:42 -0400
          Re: Addition of nocode keyword Richard Damon <Richard@Damon-Family.org> - 2019-10-29 22:37 -0400
            Re: Addition of nocode keyword "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-10-30 05:10 -0700
    Re: Addition of nocode keyword Philipp Klaus Krause <pkk@spth.de> - 2019-10-26 18:45 +0200
  Re: Addition of nocode keyword Jakob Bohm <jb-usenet@wisemo.com.invalid> - 2019-10-28 10:42 +0100
    Re: Addition of nocode keyword "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-10-28 18:13 -0700
      Re: Addition of nocode keyword David Spencer <spencer@panix.com> - 2019-10-29 02:55 +0000
        Re: Addition of nocode keyword "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-10-29 07:58 -0400
          Re: Addition of nocode keyword David Spencer <spencer@panix.com> - 2019-10-29 20:21 +0000
            Re: Addition of nocode keyword "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-10-29 13:31 -0700
              Re: Addition of nocode keyword jameskuyper@alumni.caltech.edu - 2019-10-29 14:47 -0700
                Re: Addition of nocode keyword "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-10-29 19:36 -0400
                Re: Addition of nocode keyword Richard Damon <Richard@Damon-Family.org> - 2019-10-29 22:13 -0400
                Re: Addition of nocode keyword "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-10-30 05:03 -0700
                Re: Addition of nocode keyword David Brown <david.brown@hesbynett.no> - 2019-10-30 09:48 +0100
                Re: Addition of nocode keyword "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-10-30 05:13 -0700
                Re: Addition of nocode keyword Keith Thompson <kst-u@mib.org> - 2019-10-30 08:40 -0700
                Re: Addition of nocode keyword "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-10-30 09:44 -0700
                Re: Addition of nocode keyword David Brown <david.brown@hesbynett.no> - 2019-10-30 18:30 +0100
                Re: Addition of nocode keyword jameskuyper@alumni.caltech.edu - 2019-10-30 08:12 -0700
                Re: Addition of nocode keyword Nick Bowler <nbowler@draconx.ca> - 2019-10-30 16:47 +0000
                Re: Addition of nocode keyword James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-10-30 13:30 -0400
                Re: Addition of nocode keyword David Brown <david.brown@hesbynett.no> - 2019-10-30 18:37 +0100
                Re: Addition of nocode keyword Nick Bowler <nbowler@draconx.ca> - 2019-10-30 18:34 +0000
                Re: Addition of nocode keyword Keith Thompson <kst-u@mib.org> - 2019-10-31 10:14 -0700
                Re: Addition of nocode keyword "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-10-30 21:29 -0400
                Re: Addition of nocode keyword jameskuyper@alumni.caltech.edu - 2019-10-31 08:37 -0700
                Re: Addition of nocode keyword "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-10-31 09:38 -0700
                Re: Addition of nocode keyword David Brown <david.brown@hesbynett.no> - 2019-10-31 19:50 +0100
                Re: Addition of nocode keyword Philipp Klaus Krause <pkk@spth.de> - 2020-08-04 11:18 +0200
                Re: Addition of nocode keyword "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-11-01 07:20 -0700
              Re: Addition of nocode keyword David Spencer <spencer@panix.com> - 2019-10-29 23:46 +0000
                Re: Addition of nocode keyword "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-10-29 21:41 -0400
              Re: Addition of nocode keyword guinness.tony@gmail.com - 2019-10-30 04:36 -0700
                Re: Addition of nocode keyword Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-10-31 00:19 +0000
    Re: Addition of nocode keyword David Brown <david.brown@hesbynett.no> - 2019-10-29 14:32 +0100
      Re: Addition of nocode keyword Jakob Bohm <jb-usenet@wisemo.com.invalid> - 2019-10-29 17:41 +0100
        Re: Addition of nocode keyword David Brown <david.brown@hesbynett.no> - 2019-10-29 23:24 +0100

csiph-web