Signed word lengths and indexes

BCS none at anon.com
Tue Jun 15 09:06:13 PDT 2010


Hello Steven,

> On Tue, 15 Jun 2010 11:28:43 -0400, BCS <none at anon.com> wrote:
> 
>> Hello Steven,
>> 
>>> On Tue, 15 Jun 2010 08:49:56 -0400, Pelle <pelle.mansson at gmail.com>
>>> wrote:
>>> 
>>>> Clever code is bad because you have to think a couple of times more
>>>> every time you see it.
>>>> 
>>> This is a temporary problem.  Once you get used to any particular
>>> coding  trick, you understand it better.
>>> 
>> People cutting you off on the road is a temporary problem, once you
>> tell  everyone off, they will understand better.
>> 
>> Your statement might have merit if the "you" in it were the specific
>> "you" rather than the universal "you".
>> 
> In fact, I meant the specific you.  Once a person gets used to any
> particular coding trick, that person will understand it better when
> the  trick is encountered again.  This is a basic principle of
> learning.

Yes, once Pelle (sorry to pick on you) gets used to any particular coding 
trick, Pelle will understand it better when the trick is encountered again. 
But what about everyone else? If Pelle were the only one who was going to 
read your code, that would be fine. But unless you can, right now, list by 
name everyone who will ever read your (and if you can, just go buy a lottery 
ticket and retire) then anything but the universal "you" makes the statement 
irrelevant.

> 
>>>> Also, it looks wrong.
>>>> 
>>> Why?  i is unsigned, therefore >= 0, and must be < length.  That
>>> seems reasonable and correct to me.
>>> 
>> It looks wrong because i only gets smaller. People are hardwired to
>> think about continues number system, not modulo number system
>> (explain  that 0 - 1 = -1 to a 6 year old; easy, explain that 0 - 1 =
>> 2^32-1 to  them, good luck). Yes we can be trained to use such
>> system, but most  people still wont think that way reflexively.
>> 
> It's really easy to explain.  Use an odometer as an example.  And we
> don't  have to be specific in this case, you can substitue 'some very
> large  number' for '2^32 - 1'.

Most 6 year olds will need to have an odometer explained to them first.

> Besides, why does a 6-year old have to understand a for loop?  D
> doesn't  cater to people who can't grasp the modulo arithmetic
> concept.

I wasn't taking about for loops, but the semantics of int vs. uint near zero. 
If a 6 year old can understand something, I won't have to think about it 
to work with it and I can use the time and cycles I gain for something else.

-- 
... <IXOYE><





More information about the Digitalmars-d mailing list