Re: Programming Language Productivity: The Stupidity of Programmers
From: Sheldon Simms (sheldonsimms_at_yahoo.com)
Date: 11/14/03
- Next message: Mark A. Odell: "Re: [OT] Re: writing tsr in c"
- Previous message: Programmer Dude: "Re: [OT] Re: writing tsr in c"
- In reply to: Arthur J. O'Dwyer: "Re: Programming Language Productivity: The Stupidity of Programmers"
- Next in thread: Arthur J. O'Dwyer: "Re: Programming Language Productivity: The Stupidity of Programmers"
- Reply: Arthur J. O'Dwyer: "Re: Programming Language Productivity: The Stupidity of Programmers"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 14 Nov 2003 17:09:53 -0500
On Fri, 14 Nov 2003 15:56:44 -0500, Arthur J. O'Dwyer wrote:
>
> On Fri, 14 Nov 2003, Sheldon Simms wrote:
>>
>> On Fri, 14 Nov 2003 19:56:24 +0100, Joachim Durchholz wrote:
>> > Andreas Rossberg wrote:
>> >>
>> >> Er, in C, indexing is just syntactic sugar for pointer arithmetics.
>> >
>> > No, it isn't. Indexing retains more information that the compiler can
>> > exploit.
>>
>> The C Standard states:
>>
>> The definition of the subscript operator [] is that E1[E2] is
>> identical to (*((E1)+(E2))).
>
> Right. So indexing retains more information. Which is more verbose,
>
> a[i] --or-- *p
>
> So, which one contains more information? Obviously, the one that
> specifies "base address plus offset" (a and i, respectively), as opposed
> to the one that only specifies "address" (p).
The assertion made was "indexing retains more information" than pointer
arithmetic. That is false. The expression *p does not involve any pointer
arithmetic. The expression p+i _is_ pointer arithmetic and the expression
*(p+i) uses pointer arithmetic to access an element of an array. In fact,
as we see from the C standard, *(p+i) is exactly the same as p[i] or i[p].
There is no question about which kind of expression "retains more
information".
> You see, nobody ever writes expressions involving '*(p+i)' in C,
> because that would in the *vast* majority of cases be silly.
Well gee, *I* write that sort of expression occasionally. Does that
make me silly?
> <strawman analogy> In C, the literal -1 is defined as the result
> of applying the unary minus operator to the literal 1. Which is
> more amenable to compiler optimization,
>
> i = -1; --or-- i = 1; i = -i;
Neither is more amenable to compiler optimization. The abstract semantics
are slightly different, but unless i is declared volatile, the observed
behavior would be the same, unless the compiler is *very* stupid.
I don't know what this example has to do with indexing vs. pointer
arithmetic in any case.
- Next message: Mark A. Odell: "Re: [OT] Re: writing tsr in c"
- Previous message: Programmer Dude: "Re: [OT] Re: writing tsr in c"
- In reply to: Arthur J. O'Dwyer: "Re: Programming Language Productivity: The Stupidity of Programmers"
- Next in thread: Arthur J. O'Dwyer: "Re: Programming Language Productivity: The Stupidity of Programmers"
- Reply: Arthur J. O'Dwyer: "Re: Programming Language Productivity: The Stupidity of Programmers"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|