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


Groups > comp.lang.c > #100455

Re: Octal

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Octal
Date 2016-12-28 10:19 -0800
Organization None to speak of
Message-ID <lnk2aj531s.fsf@kst-u.example.com> (permalink)
References (12 earlier) <o3v2hu$qq5$1@dont-email.me> <lntw9o6cr1.fsf@kst-u.example.com> <o407g6$dgp$1@dont-email.me> <a1f82620-a8cb-472f-b9e1-3b480f084587@googlegroups.com> <o40r4j$cqc$1@dont-email.me>

Show all headers | View raw


BartC <bc@freeuk.com> writes:
> On 28/12/2016 16:17, supercat@casperkitty.com wrote:
>> On Wednesday, December 28, 2016 at 5:27:34 AM UTC-6, Bart wrote:
>>> This is contrary to my understanding of how the preprocessor works,
>>> which is that the output is considered to be text-based, not
>>> token-based, and the next compilation phase will see the character
>>> sequence "127.0.0.1" and re-tokenise it whichever way it wants.
>>
>> Prior to the C Standard, some compilers had a preprocessor stage which ran
>> through all the source files and combined them into a preprocessor-output
>> text file, which was then fed to subsequent compilation stages, while others
>> would have the preprocessor generate data in an internal-use format (either
>> in memory or disk) which retained the results of scanning certain parts.
>
> I rarely use macros with parameters but never realised they were such a 
> minefield. And in fact the rules would effect also affect straight 
> source whether it uses macros or not.

They're not really that much of a minefield.

>> For example, given something like:
>>
>>     #define plusplus() ++
>>     int main(void)
>>     {
>>       int i=0,=0;
>>       return i+plus()j;
>>     }
>>
>> some compilers which ran the preprocessor as a separate stage may have
>> converted the return statement into "return i+++j;" which would in turn
>> be parsed as "return i++ +j;", but others may have converted the first
>> + to a token before expanding the macro "plus()", and thus interpreting
>> the statement as "return i+ ++j;".
>
> How was it possible to have a language that gave different results 
> depending on how the preprocessing rules were interpreted?

It was possible because the language had not yet been standardized.

Since 1989, it has been, and there is no ambiguity in supercat's
example.  `i+plus()j` is unambiguously equivalent to `i + ++ j`.

> But fortunately your example is parsed as "+ ++" on all the compilers 
> I've tried.

Good.

> (Tomorrow I'll have a go at writing a preprocessor to see how far I can 
> get; not an enticing prospect. Hopefully it'll have little impact on 
> throughput for code that sparsely uses macros (currently around 5Mlps).
>
> But there is no way my pp would generate "+++" and then "++","+" from 
> that example, no matter what the Standard says! Nor "0x123E+3" as a 
> single token.)

So you're going to implement a C preprocessor, but you're not interested
in what the Standard says.  Interesting choice.

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

Octal BartC <bc@freeuk.com> - 2016-12-27 14:08 +0000
  Octal "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-12-27 06:19 -0800
    Re: Octal BartC <bc@freeuk.com> - 2016-12-27 14:58 +0000
      Re: Octal "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-12-27 07:07 -0800
        Re: Octal BartC <bc@freeuk.com> - 2016-12-27 15:22 +0000
          Re: Octal "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-12-27 07:37 -0800
            Re: Octal BartC <bc@freeuk.com> - 2016-12-27 16:24 +0000
              Re: Octal "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-12-27 08:30 -0800
              Re: Octal supercat@casperkitty.com - 2016-12-27 09:10 -0800
                Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-27 09:35 -0800
                Re: Octal supercat@casperkitty.com - 2016-12-27 10:47 -0800
                Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-27 12:03 -0800
                Re: Octal supercat@casperkitty.com - 2016-12-27 12:27 -0800
                Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-27 12:44 -0800
                Re: Octal supercat@casperkitty.com - 2016-12-27 13:37 -0800
                Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-27 16:38 -0800
                Re: Octal supercat@casperkitty.com - 2016-12-27 17:53 -0800
                Re: Octal Robert Wessel <robertwessel2@yahoo.com> - 2016-12-27 20:26 -0600
                Re: Octal supercat@casperkitty.com - 2016-12-27 18:48 -0800
                Re: Octal Robert Wessel <robertwessel2@yahoo.com> - 2016-12-27 22:20 -0600
                Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-27 18:41 -0800
                Re: Octal supercat@casperkitty.com - 2016-12-27 19:19 -0800
                Re: Octal Ian Collins <ian-news@hotmail.com> - 2016-12-29 14:52 +1300
                Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-28 18:41 -0800
                Re: Octal Tim Rentsch <txr@alumni.caltech.edu> - 2016-12-28 16:54 -0800
                Re: Octal BartC <bc@freeuk.com> - 2016-12-27 17:44 +0000
                Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-27 12:17 -0800
                Re: Octal BartC <bc@freeuk.com> - 2016-12-27 22:39 +0000
                Re: Octal Ian Collins <ian-news@hotmail.com> - 2016-12-28 11:49 +1300
                Re: Octal BartC <bc@freeuk.com> - 2016-12-27 23:09 +0000
                Re: Octal Ian Collins <ian-news@hotmail.com> - 2016-12-28 12:32 +1300
                Re: Octal BartC <bc@freeuk.com> - 2016-12-28 00:51 +0000
                Re: Octal Ian Collins <ian-news@hotmail.com> - 2016-12-28 14:00 +1300
                Re: Octal BartC <bc@freeuk.com> - 2016-12-28 01:13 +0000
                Re: Octal Robert Wessel <robertwessel2@yahoo.com> - 2016-12-27 20:04 -0600
                Re: Octal supercat@casperkitty.com - 2016-12-27 18:45 -0800
                Re: Octal Tim Rentsch <txr@alumni.caltech.edu> - 2016-12-29 13:35 -0800
                Re: Octal supercat@casperkitty.com - 2016-12-29 14:49 -0800
                Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-29 15:33 -0800
                Re: Octal supercat@casperkitty.com - 2016-12-30 12:35 -0800
                Re: Octal Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-13 15:19 -0800
                Re: Octal Keith Thompson <kst-u@mib.org> - 2017-01-13 15:32 -0800
                Re: Octal Ian Collins <ian-news@hotmail.com> - 2017-01-14 12:35 +1300
                Re: Octal Keith Thompson <kst-u@mib.org> - 2017-01-13 15:51 -0800
                Re: Octal supercat@casperkitty.com - 2017-01-13 18:25 -0800
                Re: Octal Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-01-14 06:21 -0800
                Re: Octal supercat@casperkitty.com - 2017-01-14 14:00 -0800
                Re: Octal Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-15 23:08 -0800
                Re: Octal Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-15 23:02 -0800
                Re: Octal supercat@casperkitty.com - 2017-01-13 18:52 -0800
                Re: Octal Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-15 23:46 -0800
                Re: Octal supercat@casperkitty.com - 2017-01-16 01:46 -0800
                Re: Octal Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-31 08:33 -0800
                Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-27 17:19 -0800
                Re: Octal raltbos@xs4all.nl (Richard Bos) - 2016-12-28 09:39 +0000
                Re: Octal BartC <bc@freeuk.com> - 2016-12-28 11:02 +0000
                Re: Octal David Brown <david.brown@hesbynett.no> - 2016-12-28 12:13 +0100
                Re: Octal BartC <bc@freeuk.com> - 2016-12-28 11:41 +0000
                Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-28 09:31 -0800
                Re: Octal BartC <bc@freeuk.com> - 2016-12-28 17:39 +0000
                Re: Octal David Brown <david.brown@hesbynett.no> - 2016-12-28 22:05 +0100
                Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-28 12:01 -0800
                Re: Octal BartC <bc@freeuk.com> - 2016-12-28 20:05 +0000
                Re: Octal asetofsymbols@gmail.com - 2016-12-28 11:20 -0800
                Re: Octal Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-28 12:01 +0000
                Re: Octal BartC <bc@freeuk.com> - 2016-12-28 12:30 +0000
                Re: Octal David Brown <david.brown@hesbynett.no> - 2016-12-28 13:51 +0100
                Re: Octal Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-28 16:26 +0000
                Re: Octal supercat@casperkitty.com - 2016-12-28 08:40 -0800
                Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-28 09:41 -0800
                Re: Octal BartC <bc@freeuk.com> - 2016-12-28 18:04 +0000
                Re: Octal Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-28 19:36 +0000
                Re: Octal BartC <bc@freeuk.com> - 2016-12-28 19:42 +0000
                Re: Octal Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-29 00:34 +0000
                Re: Octal supercat@casperkitty.com - 2016-12-28 11:04 -0800
                Re: Octal raltbos@xs4all.nl (Richard Bos) - 2016-12-28 12:09 +0000
                Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-27 16:46 -0800
                Re: Octal BartC <bc@freeuk.com> - 2016-12-28 00:56 +0000
                Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-27 17:52 -0800
                Re: Octal BartC <bc@freeuk.com> - 2016-12-28 11:27 +0000
                Re: Octal Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-28 12:09 +0000
                Re: Octal supercat@casperkitty.com - 2016-12-28 08:17 -0800
                Re: Octal BartC <bc@freeuk.com> - 2016-12-28 17:02 +0000
                Re: Octal Ike Naar <ike@iceland.freeshell.org> - 2016-12-28 17:25 +0000
                Re: Octal BartC <bc@freeuk.com> - 2016-12-28 17:45 +0000
                Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-28 10:21 -0800
                Re: Octal supercat@casperkitty.com - 2016-12-28 09:27 -0800
                Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-28 10:23 -0800
                Re: Octal supercat@casperkitty.com - 2016-12-28 11:18 -0800
                Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-28 10:19 -0800
                Re: Octal BartC <bc@freeuk.com> - 2016-12-29 15:54 +0000
                Re: Octal Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-12-29 12:57 -0800
                Re: Octal Ian Collins <ian-news@hotmail.com> - 2016-12-30 10:01 +1300
                Re: Octal David Brown <david.brown@hesbynett.no> - 2016-12-30 10:44 +0100
                Re: Octal David Brown <david.brown@hesbynett.no> - 2016-12-29 17:32 +0100
                Re: Octal BartC <bc@freeuk.com> - 2016-12-29 17:03 +0000
                Re: Octal Robert Wessel <robertwessel2@yahoo.com> - 2016-12-29 16:26 -0600
                Re: Octal Ian Collins <ian-news@hotmail.com> - 2016-12-30 11:31 +1300
                Re: Octal Robert Wessel <robertwessel2@yahoo.com> - 2016-12-29 16:58 -0600
                Re: Octal Ian Collins <ian-news@hotmail.com> - 2016-12-30 11:59 +1300
                Re: Octal Ian Collins <ian-news@hotmail.com> - 2016-12-30 09:00 +1300
                Re: Octal David Brown <david.brown@hesbynett.no> - 2016-12-30 10:21 +0100
                Re: Octal asetofsymbols@gmail.com - 2016-12-30 01:29 -0800
                Re: Octal asetofsymbols@gmail.com - 2016-12-30 01:29 -0800
                Re: Octal asetofsymbols@gmail.com - 2016-12-30 01:36 -0800
                Re: Octal BartC <bc@freeuk.com> - 2016-12-29 11:52 +0000
                Re: Octal BartC <bc@freeuk.com> - 2016-12-29 17:10 +0000
                Re: Octal supercat@casperkitty.com - 2016-12-29 05:52 -0800
                Re: Octal Robert Wessel <robertwessel2@yahoo.com> - 2016-12-28 19:51 -0600
                Re: Octal BartC <bc@freeuk.com> - 2016-12-29 21:09 +0000
                Re: Octal Ian Collins <ian-news@hotmail.com> - 2016-12-30 10:15 +1300
                Re: Octal Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-12-29 13:53 -0800
                Re: Octal David Brown <david.brown@hesbynett.no> - 2016-12-30 12:07 +0100
                Re: Octal BartC <bc@freeuk.com> - 2016-12-30 13:04 +0000
                Re: Octal Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-12-30 05:31 -0800
                Re: Octal David Brown <david.brown@hesbynett.no> - 2016-12-30 15:00 +0100
                Re: Octal BartC <bc@freeuk.com> - 2016-12-30 15:55 +0000
                Re: Octal David Brown <david.brown@hesbynett.no> - 2017-01-01 16:00 +0100
                Re: Octal Ian Collins <ian-news@hotmail.com> - 2017-01-02 08:33 +1300
                Re: Octal Ian Collins <ian-news@hotmail.com> - 2017-01-02 09:02 +1300
                Re: Octal Ian Collins <ian-news@hotmail.com> - 2017-01-02 09:38 +1300
                Re: Octal Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-01-01 13:59 -0800
                Re: Octal Keith Thompson <kst-u@mib.org> - 2017-01-01 14:24 -0800
                Re: Octal supercat@casperkitty.com - 2017-01-01 15:51 -0800
                Re: Octal Ian Collins <ian-news@hotmail.com> - 2017-01-02 13:09 +1300
                Re: Octal supercat@casperkitty.com - 2017-01-01 16:50 -0800
                Re: Octal Ian Collins <ian-news@hotmail.com> - 2017-01-02 14:24 +1300
                Re: Octal David Brown <david.brown@hesbynett.no> - 2017-01-02 01:53 +0100
                Re: Octal Ian Collins <ian-news@hotmail.com> - 2017-01-02 14:15 +1300
                Re: Octal Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-02 02:28 -0800
                Re: Octal Ian Collins <ian-news@hotmail.com> - 2016-12-31 06:24 +1300
                Re: Octal BartC <bc@freeuk.com> - 2016-12-30 17:53 +0000
                Re: Octal luser droog <luser.droog@gmail.com> - 2016-12-30 10:01 -0800
                Re: Octal Ian Collins <ian-news@hotmail.com> - 2016-12-31 09:57 +1300
                Re: Octal supercat@casperkitty.com - 2016-12-30 13:50 -0800
                Re: Octal Ian Collins <ian-news@hotmail.com> - 2016-12-31 11:09 +1300
                Re: Octal supercat@casperkitty.com - 2016-12-30 14:46 -0800
                Re: Octal Ian Collins <ian-news@hotmail.com> - 2016-12-31 12:28 +1300
                Re: Octal supercat@casperkitty.com - 2016-12-30 16:01 -0800
                Re: Octal Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-12-30 14:48 -0800
                Re: Octal BartC <bc@freeuk.com> - 2016-12-30 22:51 +0000
                Re: Octal supercat@casperkitty.com - 2016-12-30 15:20 -0800
                Re: Octal Ian Collins <ian-news@hotmail.com> - 2016-12-31 12:34 +1300
                Re: Octal BartC <bc@freeuk.com> - 2016-12-30 23:40 +0000
                Re: Octal BartC <bc@freeuk.com> - 2016-12-30 22:12 +0000
                Re: Octal raltbos@xs4all.nl (Richard Bos) - 2016-12-28 21:38 +0000
                Re: Octal BartC <bc@freeuk.com> - 2016-12-29 12:04 +0000
                Re: Octal David Brown <david.brown@hesbynett.no> - 2016-12-29 13:42 +0100
                Re: Octal Ian Collins <ian-news@hotmail.com> - 2016-12-30 08:59 +1300
                Re: Octal supercat@casperkitty.com - 2016-12-29 12:23 -0800
                Re: Octal David Brown <david.brown@hesbynett.no> - 2016-12-30 10:56 +0100
                Re: Octal BartC <bc@freeuk.com> - 2016-12-28 22:09 +0000
                Re: Octal David Brown <david.brown@hesbynett.no> - 2016-12-29 12:27 +0100
                Re: Octal BartC <bc@freeuk.com> - 2016-12-28 21:18 +0000
                Re: Octal BartC <bc@freeuk.com> - 2016-12-28 20:46 +0000
                Re: Octal raltbos@xs4all.nl (Richard Bos) - 2016-12-28 20:55 +0000
                Re: Octal Robert Wessel <robertwessel2@yahoo.com> - 2016-12-28 14:54 -0600
                Re: Octal BartC <bc@freeuk.com> - 2016-12-29 15:44 +0000
                Re: Octal BartC <bc@freeuk.com> - 2016-12-28 19:39 +0000
                Re: Octal Robert Wessel <robertwessel2@yahoo.com> - 2016-12-28 15:04 -0600
                Re: Octal raltbos@xs4all.nl (Richard Bos) - 2016-12-28 19:52 +0000
                Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-29 09:36 -0800
                Re: Octal BartC <bc@freeuk.com> - 2016-12-29 18:02 +0000
                Re: Octal BartC <bc@freeuk.com> - 2016-12-30 16:17 +0000
                Re: Octal David Brown <david.brown@hesbynett.no> - 2017-01-01 16:09 +0100
                Re: Octal BartC <bc@freeuk.com> - 2016-12-28 20:02 +0000
                Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-28 12:32 -0800
                Re: Octal Richard Heathfield <rjh@cpax.org.uk> - 2016-12-29 13:45 +0000
                Re: Octal Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-28 17:16 +0000
                Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-28 10:04 -0800
                Re: Octal Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-02 02:26 -0800
                Re: Octal Keith Thompson <kst-u@mib.org> - 2017-01-02 12:35 -0800
                Re: Octal Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-12 23:22 -0800
                Re: Octal Keith Thompson <kst-u@mib.org> - 2017-01-13 10:04 -0800
                Re: Octal Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-14 00:45 -0800
                Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-28 09:59 -0800
                Re: Octal "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-12-27 09:45 -0800
        Re: Octal David Brown <david.brown@hesbynett.no> - 2016-12-27 17:14 +0100
          Re: Octal "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-12-27 08:23 -0800
            Re: Octal David Brown <david.brown@hesbynett.no> - 2016-12-28 10:37 +0100
              Re: Octal "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-12-28 03:07 -0800
                Re: Octal David Brown <david.brown@hesbynett.no> - 2016-12-28 12:25 +0100
                Re: Octal Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-28 11:58 +0000
                Re: Octal "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-12-28 04:35 -0800
                Re: Octal Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-28 17:31 +0000
                Re: Octal "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-12-28 09:38 -0800
                Re: Octal Robert Wessel <robertwessel2@yahoo.com> - 2016-12-28 15:12 -0600
                Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-28 12:01 -0800
              Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-28 09:20 -0800
                Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-28 13:39 -0800
                Re: Octal David Brown <david.brown@hesbynett.no> - 2016-12-29 12:29 +0100
                Re: Octal David Brown <david.brown@hesbynett.no> - 2016-12-28 22:20 +0100
      Re: Octal Noob <root@127.0.0.1> - 2016-12-28 13:02 +0100
        Re: Octal David Brown <david.brown@hesbynett.no> - 2016-12-28 13:30 +0100
        Re: Octal BartC <bc@freeuk.com> - 2016-12-28 13:25 +0000
  Re: Octal Manfred <noname@invalid.add> - 2016-12-27 15:19 +0100
    Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-27 08:37 -0800
      Re: Octal Manfred <noname@invalid.add> - 2016-12-27 18:43 +0100
        Re: Octal Keith Thompson <kst-u@mib.org> - 2016-12-27 12:07 -0800
    Re: Octal Manfred <noname@invalid.add> - 2016-12-27 18:21 +0100
  Re: Octal David Brown <david.brown@hesbynett.no> - 2016-12-27 15:28 +0100
  Re: Octal BGB <cr88192@hotmail.com> - 2016-12-27 11:42 -0600

csiph-web