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


Groups > comp.lang.c > #103766

Re: better atoi

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: better atoi
Date 2017-02-13 00:16 +0000
Organization A noiseless patient Spider
Message-ID <87bmu7uer4.fsf@bsb.me.uk> (permalink)
References (13 earlier) <a0b5a4f1-4e7b-41d6-88b8-d63a0de85a4c@googlegroups.com> <491bde1c-4dc9-4c49-ab7c-496eb64f4362@googlegroups.com> <o7q9kb$dcr$1@dont-email.me> <877f4vw83z.fsf@bsb.me.uk> <o7qc9t$nj9$1@dont-email.me>

Show all headers | View raw


BartC <bc@freeuk.com> writes:

> On 12/02/2017 18:56, Ben Bacarisse wrote:
>> BartC <bc@freeuk.com> writes:
>> <snip>
>>> ...  but C presumably must have been
>>> perfect because few of the troublesome details has been touched for
>>> decades!
>>
>> More accurately: C has been successful for decades because few of the
>> details have been touched.
>>
>> <snip>
>>>   int (*abc)[10];
>>>
>>> This follows the recursive definition in the Standard
>>> beautifully. Except the implementation of it doesn't match the
>>> grammar: that "*" pointer somewhere has to find its way outside the
>>> brackets,
>>
>> It matches the grammar just fine (as you say).  If your implementation
>> does does not reflect the parse, that's not C's fault.  The * must be
>> inside the brackets or the type would an array type.
>
> The type in the example can be expressed definitively in English as
> the left-to-right sequence:
>
>   Pointer-Array-Int

Sure.

> If "*" is Pointer, abc is Int, and [10] is Array, then the declaration
> is arranged like this:
>
>   (Pointer-Int)-Array

Eh?  Why would you rename "abc" as "Int"?  That looks like you are
trying to mess up the meaning.  If you rename int as Int, * as Pointer,
[10] as Array you get

  Int (Pointer-abc)Array

but how does that help?  You've just renamed things.

> I can just about get the Array part to be moved in between the other
> two, but it's an ugly hack.

Nothing needs to be "moved".  The declarator is parsed like you'd parse
an expression.  Write the reverse polish (or stack operations) you'd get
from the expressions

  (*abc)[10]  and  *abc[10]

and you'll see.  The first is abc deref 10 index and the second is abc
10 index deref.  Parse the declarators in the same way but change the
wording and you get the types in a linear form.

> However, if I change abc to Pointer-Array-Int, "*" to "Deref", and
> "[10]" to index, then the declaration becomes:
>
>  (Deref-Pointer-Array-Int)-Index
>
> Now, Deref-Pointer cancel, leaving (Array-Int)Index. Array-Index
> cancel, leaving Int, the type you can get when you evaluate
> abc[i]. This is the famous Declaration-follows-use, the reason
> type-decls are as they are.

This is even more odd than renaming "abc" "Int".  What is Deref doing in
a declaration?  I think you are trying to confuse yourself.

<snip>
-- 
Ben.

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


Thread

better atoi fir <profesor.fir@gmail.com> - 2017-02-10 12:24 -0800
  Re: better atoi fir <profesor.fir@gmail.com> - 2017-02-10 12:35 -0800
  Re: better atoi Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-02-10 14:48 -0700
    Re: better atoi fir <profesor.fir@gmail.com> - 2017-02-10 14:12 -0800
      Re: better atoi Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-02-10 22:36 -0700
        Re: better atoi fir <profesor.fir@gmail.com> - 2017-02-11 01:07 -0800
          Re: better atoi Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-02-11 10:10 -0700
            Re: better atoi fir <profesor.fir@gmail.com> - 2017-02-11 09:26 -0800
              Re: better atoi Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-02-11 15:36 -0700
                Re: better atoi fir <profesor.fir@gmail.com> - 2017-02-12 00:18 -0800
                Re: better atoi fir <profesor.fir@gmail.com> - 2017-02-12 00:31 -0800
                Re: better atoi fir <profesor.fir@gmail.com> - 2017-02-12 03:47 -0800
                Re: better atoi fir <profesor.fir@gmail.com> - 2017-02-12 04:22 -0800
                Re: better atoi fir <profesor.fir@gmail.com> - 2017-02-12 06:08 -0800
                Re: better atoi fir <profesor.fir@gmail.com> - 2017-02-12 06:13 -0800
                Re: better atoi fir <profesor.fir@gmail.com> - 2017-02-12 07:31 -0800
                Re: better atoi fir <profesor.fir@gmail.com> - 2017-02-12 08:02 -0800
                Re: better atoi fir <profesor.fir@gmail.com> - 2017-02-12 08:08 -0800
                Re: better atoi fir <profesor.fir@gmail.com> - 2017-02-12 08:17 -0800
                Re: better atoi fir <profesor.fir@gmail.com> - 2017-02-12 08:23 -0800
                Re: better atoi Robert Latest <boblatest@yahoo.com> - 2017-02-19 11:11 +0000
            Re: better atoi Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-11 17:33 +0000
              Re: better atoi Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-02-11 15:35 -0700
                Re: better atoi "James R. Kuyper" <jameskuyper@verizon.net> - 2017-02-11 17:52 -0500
                Re: better atoi Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-02-11 18:53 -0700
    Re: better atoi Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-10 22:50 +0000
      Re: better atoi Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-02-10 21:59 -0700
        Re: better atoi Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-11 12:08 +0000
          Re: better atoi Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-02-11 09:39 -0700
            Re: better atoi Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-11 17:26 +0000
              Re: better atoi Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-02-11 15:30 -0700
                Re: better atoi Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-11 22:58 +0000
                Re: better atoi Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-02-11 18:48 -0700
                Re: better atoi Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-12 02:16 +0000
                Re: better atoi "James R. Kuyper" <jameskuyper@verizon.net> - 2017-02-12 09:57 -0500
                Re: better atoi fir <profesor.fir@gmail.com> - 2017-02-12 07:27 -0800
                Re: better atoi jameskuyper@verizon.net - 2017-02-12 08:44 -0800
                Re: better atoi fir <profesor.fir@gmail.com> - 2017-02-12 09:15 -0800
                Re: better atoi Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-02-12 09:44 -0800
                Re: better atoi BartC <bc@freeuk.com> - 2017-02-12 18:32 +0000
                Re: better atoi Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-12 18:56 +0000
                Re: better atoi BartC <bc@freeuk.com> - 2017-02-12 19:18 +0000
                Re: better atoi Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-13 00:16 +0000
                Re: better atoi BartC <bc@freeuk.com> - 2017-02-13 01:56 +0000
                Re: better atoi Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-13 10:44 +0000
                Re: better atoi BartC <bc@freeuk.com> - 2017-02-13 11:38 +0000
                Re: better atoi Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-13 14:37 +0000
                Re: better atoi BartC <bc@freeuk.com> - 2017-02-13 15:00 +0000
                Re: better atoi Keith Thompson <kst-u@mib.org> - 2017-02-12 11:15 -0800
                Re: better atoi BartC <bc@freeuk.com> - 2017-02-12 19:25 +0000
                Re: better atoi Keith Thompson <kst-u@mib.org> - 2017-02-12 11:54 -0800
                Re: better atoi supercat@casperkitty.com - 2017-02-12 13:13 -0800
    Re: better atoi Keith Thompson <kst-u@mib.org> - 2017-02-10 15:16 -0800
      Re: better atoi Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-02-10 22:01 -0700
        Re: better atoi Keith Thompson <kst-u@mib.org> - 2017-02-11 01:30 -0800
      Re: better atoi Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-02-10 22:26 -0700
    Re: better atoi Nick Bowler <nbowler@draconx.ca> - 2017-02-11 00:26 +0000
      Re: better atoi Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-02-10 22:32 -0700
    Re: better atoi "James R. Kuyper" <jameskuyper@verizon.net> - 2017-02-19 11:10 -0500

csiph-web