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


Groups > comp.lang.c > #103807

Re: better atoi

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: better atoi
Date 2017-02-13 14:37 +0000
Organization A noiseless patient Spider
Message-ID <8737fitaw0.fsf@bsb.me.uk> (permalink)
References (16 earlier) <o7qc9t$nj9$1@dont-email.me> <87bmu7uer4.fsf@bsb.me.uk> <o7r3ln$443$1@dont-email.me> <87y3xatlne.fsf@bsb.me.uk> <o7s5or$krf$1@dont-email.me>

Show all headers | View raw


BartC <bc@freeuk.com> writes:

> On 13/02/2017 10:44, Ben Bacarisse wrote:
>> BartC <bc@freeuk.com> writes:
>
>>> Where does the 'int' go in 'abc deref 10 index'? If it replaces the
>>> 'abc', then it gives me the type in the wrong order.
>>
>> Why would you replace the name with anything (other than some internal
>> representation in a symbol table of course)?
>>
>> A declaration is made up of two parts.  Declaration specifiers (the int
>> and so on) and a list of declarators (in fact, declarators with optional
>> initial values).  You have to treat each declarator separately from the
>> specifiers -- it defines the relationship the name has with the
>> specified type.  This, too, is expressed in the grammar.  In
>>
>>   int a, *p, m[3], f(void), (*x)[10];
>>
>> each of "a", "*p", "m[3]", "f(void)" and "(*x)[10]" describe the way the
>> name relates to "int".  You can read them as "a is", "p is a pointer
>> to", "m is any array of", "f is a function taking void and returning"
>> and "x is a pointer to an array of".  In this form, the "int" simply
>> goes at the end.
>
> I've sorted out dealing with 'int *abc[]' and 'int (*abc)[]'. But it
> needed two passes rather than one. To get it into the internal form I
> need anyway.

If it works, it works.  But try not to suggest that because you did it
in some particular apparently messy way, it must be done that way.

> I take it that with a const pointer, the 'const' (one  or more of
> them) has to go immediately after the '*'?

Of course.

> So 'int const *p;', while legal, is misleading as the const belongs to
> the int. It has to be 'int * const p;'.

Well obviously you can write int const *p; if that is what you mean.  If
you mean int *const p;" then that is what you have to write.  What I
think you mean is that you find this distinction complicated.

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