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


Groups > comp.lang.java.programmer > #14576 > unrolled thread

Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;)

Started by"Skybuck Flying" <Windows7IsOK@DreamPC2006.com>
First post2012-05-17 15:09 +0200
Last post2012-05-24 09:42 -0700
Articles 20 on this page of 101 — 30 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-17 15:09 +0200
    Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-05-17 09:23 -0400
    Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-17 17:26 +0200
      Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Heikki Kallasjoki <fis+usenet@zem.fi> - 2012-05-17 16:19 +0000
        Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-17 19:57 +0200
          Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-05-17 18:33 +0000
            Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-17 23:25 +0200
              Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Lew <lewbloch@gmail.com> - 2012-05-17 14:52 -0700
              Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-05-17 14:58 -0700
              Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-05-17 17:59 -0400
                Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Heikki Kallasjoki <fis+usenet@zem.fi> - 2012-05-17 22:13 +0000
                  Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-18 01:18 +0200
                    Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-05-17 21:32 -0400
                      Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Noob <root@127.0.0.1> - 2012-05-18 17:08 +0200
                        Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-19 20:53 +0200
                        Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-19 21:19 +0200
                          Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-05-19 18:47 -0700
                            Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-20 17:55 +0200
                      Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-19 20:18 +0200
                        Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-19 20:21 +0200
                          Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-19 20:52 +0200
                          Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 18:27 -0400
                        Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Lew <noone@lewscanon.com> - 2012-05-19 14:48 -0700
                          Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Lew <noone@lewscanon.com> - 2012-05-19 15:20 -0700
                            Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Lew <noone@lewscanon.com> - 2012-05-19 15:35 -0700
                        Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 18:25 -0400
                        Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) bugbear <bugbear@trim_papermule.co.uk_trim> - 2012-05-21 17:12 +0100
                    Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Heikki Kallasjoki <fis+usenet@zem.fi> - 2012-05-18 07:22 +0000
                    Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Lew <noone@lewscanon.com> - 2012-05-19 14:50 -0700
                    Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 18:21 -0400
                    Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 18:23 -0400
                Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-18 01:09 +0200
              Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 18:14 -0400
                Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-21 09:36 +0200
            Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-20 17:53 +0200
              Re: names for parameters of ranges Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 18:30 -0400
                Re: names for parameters of ranges Gene Wirchenko <genew@ocis.net> - 2012-05-20 20:48 -0700
              Re: names for parameters of ranges (was: ...) Willem <willem@toad.stack.nl> - 2012-05-23 09:43 +0000
                Re: names for parameters of ranges Willem <willem@toad.stack.nl> - 2012-05-23 11:07 +0000
                  Re: names for parameters of ranges Willem <willem@toad.stack.nl> - 2012-05-23 15:42 +0000
                Re: names for parameters of ranges Willem <willem@toad.stack.nl> - 2012-05-23 11:11 +0000
          Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Heikki Kallasjoki <fis+usenet@zem.fi> - 2012-05-17 19:13 +0000
            Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Heikki Kallasjoki <fis+usenet@zem.fi> - 2012-05-17 19:19 +0000
              Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Jim Janney <jjanney@shell.xmission.com> - 2012-05-17 18:35 -0600
            Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-17 23:16 +0200
              Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 18:32 -0400
                Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-21 09:40 +0200
                  Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-05-21 10:05 -0400
      Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 14:41 -0400
      Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 18:12 -0400
        Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Keith Thompson <kst-u@mib.org> - 2012-05-20 16:38 -0700
          Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Lew <noone@lewscanon.com> - 2012-05-20 18:52 -0700
            Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Keith Thompson <kst-u@mib.org> - 2012-05-20 19:21 -0700
              Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) gazelle@shell.xmission.com (Kenny McCormack) - 2012-05-21 08:24 +0000
                Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Bill Leary" <Bill_Leary@msn.com> - 2012-05-23 14:34 -0400
            Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2012-05-20 21:46 -0600
              Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Lew <noone@lewscanon.com> - 2012-05-21 00:04 -0700
            Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) gazelle@shell.xmission.com (Kenny McCormack) - 2012-05-21 08:25 +0000
        Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-21 09:46 +0200
    Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) jacob navia <jacob@spamsink.net> - 2012-05-17 18:54 +0200
    Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Mark Storkamp <mstorkamp@yahoo.com> - 2012-05-17 12:06 -0500
      Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) markspace <-@.> - 2012-05-17 10:11 -0700
        Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Lew <lewbloch@gmail.com> - 2012-05-17 14:43 -0700
          Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) markspace <-@.> - 2012-05-17 16:13 -0700
            Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) markspace <-@.> - 2012-05-17 16:42 -0700
              Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Jan Burse <janburse@fastmail.fm> - 2012-05-18 02:27 +0200
        Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 15:06 -0400
    Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Marius" <sorry@nospamfor.me> - 2012-05-17 17:32 +0000
      Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-17 23:45 +0200
        Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Marius" <sorry@nospamfor.me> - 2012-05-17 22:16 +0000
          Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-18 00:47 +0200
            Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-24 14:11 +0200
              Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-24 14:17 +0200
    Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Roedy Green <see_website@mindprod.com.invalid> - 2012-05-18 02:57 -0700
      Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-05-18 05:26 -0500
      Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-05-18 08:08 -0400
      Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 14:46 -0400
    Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) rossum <rossum48@coldmail.com> - 2012-05-18 12:25 +0100
      Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Gene Wirchenko <genew@ocis.net> - 2012-05-18 10:46 -0700
        Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-19 21:01 +0200
          Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 18:33 -0400
            Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Patricia Shanahan <pats@acm.org> - 2012-05-20 16:30 -0700
              Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Gene Wirchenko <genew@ocis.net> - 2012-05-20 20:36 -0700
                Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Kaz Kylheku <kaz@kylheku.com> - 2012-05-21 04:28 +0000
                Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-21 09:55 +0200
              Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-21 09:49 +0200
                Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-05-21 10:08 -0400
            Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-21 10:45 +0200
              Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-21 11:13 +0200
              Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-21 11:19 +0200
                Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Lew <lewbloch@gmail.com> - 2012-05-21 11:40 -0700
    Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 18:10 -0400
      Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-21 10:00 +0200
        Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-05-21 10:10 -0400
    Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) falk@rahul.net (Edward A. Falk) - 2012-05-23 05:40 +0000
      Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Jim Janney <jjanney@shell.xmission.com> - 2012-05-23 08:46 -0600
      Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-24 14:03 +0200
        Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Lew <lewbloch@gmail.com> - 2012-05-24 09:56 -0700
        Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) falk@rahul.net (Edward A. Falk) - 2012-05-26 00:52 +0000
          Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Jamie <jamie_ka1lpa_not_valid_after_ka1lpa_@charter.net> - 2012-05-25 21:16 -0400
    Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2012-05-24 09:42 -0700

Page 3 of 6 — ← Prev page 1 2 [3] 4 5 6  Next page →


#14754 — Re: names for parameters of ranges

FromWillem <willem@toad.stack.nl>
Date2012-05-23 11:11 +0000
SubjectRe: names for parameters of ranges
Message-ID<slrnjrphfh.2dqm.willem@toad.stack.nl>
In reply to#14750
Stefan Ram wrote:
) Willem <willem@toad.stack.nl> writes:
)>And once you get into transforming coordinates, anti-aliasing
)>and whatnot, your definition falls flat on its face.
)
)       ?An integer interval that has a finite lower or
)       upper endpoint always includes that endpoint.?
)
) http://en.wikipedia.org/wiki/Interval_(mathematics)#Integer_intervals

So?

Supose I build a straight fence on the edge of my field, with posts at 1
meter intervals.  The fence is 10 posts wide.
Now, I want to build a similar fence (with the same interval) on the edge
of my other field, which is twice as long.  How many posts should I use?

(Why is this relevant: In this example, I'm transforming the coordinates,
 scaling up by a factor of 2).


SaSW, Willem
-- 
Disclaimer: I am in no way responsible for any of the statements
            made in the above text. For all I know I might be
            drugged or something..
            No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT

[toc] | [prev] | [next] | [standalone]


#14591

FromHeikki Kallasjoki <fis+usenet@zem.fi>
Date2012-05-17 19:13 +0000
Message-ID<slrnjrajds.f35.fis@iris.zem.fi>
In reply to#14588
On 2012-05-17, Skybuck Flying <Windows7IsOK@DreamPC2006.com> wrote:
>>> private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) 
>>> {
>>>     if (fromIndex > toIndex)
>>>         throw new IllegalArgumentException("fromIndex(" + fromIndex +
>>>                    ") > toIndex(" + toIndex+")");
>>>     if (fromIndex < 0)
>>>         throw new ArrayIndexOutOfBoundsException(fromIndex);
>>>     if (toIndex > arrayLen)
>>>         throw new ArrayIndexOutOfBoundsException(toIndex);
>>> }
>
> It seems likely this code is called right before the array is accessed to 
> try and prevent an access violation, instead it tries to throw a somewhat 
> nicer exception message to indicate a problem with array access.

No.  It seems likely rangeCheck(10, 4, 7) is testing whether indices 4,
5 and 6 (that is the *range* from 4, inclusive, to 7, exclusive) are
within the bounds of an array of length 10, which it does just fine.

> It's simply not valid. Out of bounds has a very clear meaning in programming 
> practice. It's either within bounds or it's not. The bounds of a java array 

Yes, but it is not designed for testing whether fromIndex and toIndex
are within those bounds.  It is used to test whether fromIndex,
fromIndex+1, ..., toIndex-1 are, which it does.  In particular, the
element with index "toIndex" is not part of the range it's testing, so
it does not need to be inside the array bounds.

In other words, the range fromIndex=5, toIndex=10 denotes the elements
5, 6, 7, 8 and 9.  It does not include element 10.  rangeCheck(10, 5, 10)
is not supposed to throw an exception, nor does it do so.

(Would it be possible to also stop crossposting to all the unrelated
groups?)


-- 
Heikki Kallasjoki

[toc] | [prev] | [next] | [standalone]


#14592

FromHeikki Kallasjoki <fis+usenet@zem.fi>
Date2012-05-17 19:19 +0000
Message-ID<slrnjrajqi.f3k.fis@iris.zem.fi>
In reply to#14591
On 2012-05-17, Heikki Kallasjoki <fis+usenet@zem.fi> wrote:
> On 2012-05-17, Skybuck Flying <Windows7IsOK@DreamPC2006.com> wrote:
>>>> private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) 
>>>> {
>>>>     if (fromIndex > toIndex)
>>>>         throw new IllegalArgumentException("fromIndex(" + fromIndex +
>>>>                    ") > toIndex(" + toIndex+")");
>>>>     if (fromIndex < 0)
>>>>         throw new ArrayIndexOutOfBoundsException(fromIndex);
>>>>     if (toIndex > arrayLen)
>>>>         throw new ArrayIndexOutOfBoundsException(toIndex);
>>>> }
>>
>> It's simply not valid. Out of bounds has a very clear meaning in programming 
>> practice. It's either within bounds or it's not. The bounds of a java array 
>
> Yes, but it is not designed for testing whether fromIndex and toIndex
> are within those bounds.  It is used to test whether fromIndex,
> fromIndex+1, ..., toIndex-1 are, which it does.  In particular, the
> element with index "toIndex" is not part of the range it's testing, so
> it does not need to be inside the array bounds.

For "proof", see the original comments that accompany the rangeCheck
function:

/**
 * Checks that fromIndex and toIndex are in range, and throws an
 * appropriate exception if they aren't.
 *
 * @param arrayLen the length of the array
 * @param fromIndex the index of the first element of the range
 * @param toIndex the index after the last element of the range
 * @throws IllegalArgumentException if fromIndex > toIndex
 * @throws ArrayIndexOutOfBoundsException if fromIndex < 0
 *         or toIndex > arrayLen
 */

Note in particular the words "the index after the last element of the
range".

(Source:
http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/main/java/util/TimSort.java?view=co
)

-- 
Heikki Kallasjoki

[toc] | [prev] | [next] | [standalone]


#14610

FromJim Janney <jjanney@shell.xmission.com>
Date2012-05-17 18:35 -0600
Message-ID<ydnpqa2ba1e.fsf@shell.xmission.com>
In reply to#14592
Heikki Kallasjoki <fis+usenet@zem.fi> writes:

> On 2012-05-17, Heikki Kallasjoki <fis+usenet@zem.fi> wrote:
>> On 2012-05-17, Skybuck Flying <Windows7IsOK@DreamPC2006.com> wrote:
>>>>> private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) 
>>>>> {
>>>>>     if (fromIndex > toIndex)
>>>>>         throw new IllegalArgumentException("fromIndex(" + fromIndex +
>>>>>                    ") > toIndex(" + toIndex+")");
>>>>>     if (fromIndex < 0)
>>>>>         throw new ArrayIndexOutOfBoundsException(fromIndex);
>>>>>     if (toIndex > arrayLen)
>>>>>         throw new ArrayIndexOutOfBoundsException(toIndex);
>>>>> }
>>>
>>> It's simply not valid. Out of bounds has a very clear meaning in programming 
>>> practice. It's either within bounds or it's not. The bounds of a java array 
>>
>> Yes, but it is not designed for testing whether fromIndex and toIndex
>> are within those bounds.  It is used to test whether fromIndex,
>> fromIndex+1, ..., toIndex-1 are, which it does.  In particular, the
>> element with index "toIndex" is not part of the range it's testing, so
>> it does not need to be inside the array bounds.
>
> For "proof", see the original comments that accompany the rangeCheck
> function:
>
> /**
>  * Checks that fromIndex and toIndex are in range, and throws an
>  * appropriate exception if they aren't.
>  *
>  * @param arrayLen the length of the array
>  * @param fromIndex the index of the first element of the range
>  * @param toIndex the index after the last element of the range
>  * @throws IllegalArgumentException if fromIndex > toIndex
>  * @throws ArrayIndexOutOfBoundsException if fromIndex < 0
>  *         or toIndex > arrayLen
>  */
>
> Note in particular the words "the index after the last element of the
> range".
>
> (Source:
> http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/main/java/util/TimSort.java?view=co
> )

This is in fact a good example of someone doing everything exactly
right: the JavaDoc provides a clear, unambiguous specification and the
code implements it exactly.  I can only wish all code were this "buggy".

-- 
Jim Janney

[toc] | [prev] | [next] | [standalone]


#14593

From"Skybuck Flying" <Windows7IsOK@DreamPC2006.com>
Date2012-05-17 23:16 +0200
Message-ID<ebdc3$4fb56a8c$5419acc3$10655@cache60.multikabel.net>
In reply to#14591

"Heikki Kallasjoki"  wrote in message news:slrnjrajds.f35.fis@iris.zem.fi...

On 2012-05-17, Skybuck Flying <Windows7IsOK@DreamPC2006.com> wrote:
>>> private static void rangeCheck(int arrayLen, int fromIndex, int toIndex)
>>> {
>>>     if (fromIndex > toIndex)
>>>         throw new IllegalArgumentException("fromIndex(" + fromIndex +
>>>                    ") > toIndex(" + toIndex+")");
>>>     if (fromIndex < 0)
>>>         throw new ArrayIndexOutOfBoundsException(fromIndex);
>>>     if (toIndex > arrayLen)
>>>         throw new ArrayIndexOutOfBoundsException(toIndex);
>>> }
>
> It seems likely this code is called right before the array is accessed to
> try and prevent an access violation, instead it tries to throw a somewhat
> nicer exception message to indicate a problem with array access.

"
No.  It seems likely rangeCheck(10, 4, 7) is testing whether indices 4,
5 and 6 (that is the *range* from 4, inclusive, to 7, exclusive) are
within the bounds of an array of length 10, which it does just fine.

> It's simply not valid. Out of bounds has a very clear meaning in 
> programming
> practice. It's either within bounds or it's not. The bounds of a java 
> array

Yes, but it is not designed for testing whether fromIndex and toIndex
are within those bounds.  It is used to test whether fromIndex,
fromIndex+1, ..., toIndex-1 are, which it does.  In particular, the
element with index "toIndex" is not part of the range it's testing, so
it does not need to be inside the array bounds.

In other words, the range fromIndex=5, toIndex=10 denotes the elements
5, 6, 7, 8 and 9.  It does not include element 10.  rangeCheck(10, 5, 10)
is not supposed to throw an exception, nor does it do so.

(Would it be possible to also stop crossposting to all the unrelated
groups?)
"

Now it's becoming a computer programming language issue.

What is the definition of "range".

You cannot simply redefine the meaning of "range". As you did by writing 
"inclusive" and then "exclusive" and flipping flopping whenever it suits 
you.

The programming language known as C probably introduced the "curly brace 
language".

Java is based on C and also uses the "curly brace language".

Since Java seems to be based of off C and is actually implemented in C it's 
safe to say that the word known as "range" in computer language follows the 
same meaning as it has in C.

Wikipedia is pretty clear about what "range" means in the programming 
language C:

http://en.wikipedia.org/wiki/Range_(computer_programming)

Range is always inclusive unless otherwise stated.

Therefore a programmer seeing a prototype of "rangeCheck" without actually 
seeing the body of the code should be safe to assume that range encompanses 
all of the indexes, being inclusive.

Thus calling rangeCheck( 10, 0, 10 ) would include index 10 to be checked 
for out of bounds.

In this case it would be out of bounds, yet no exception is raised, thus 
from any point of view the function is flawed.

Bye,
  Skybuck. 

[toc] | [prev] | [next] | [standalone]


#14692

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-05-20 18:32 -0400
Message-ID<4fb97103$0$293$14726298@news.sunsite.dk>
In reply to#14593
On 5/17/2012 5:16 PM, Skybuck Flying wrote:
> Now it's becoming a computer programming language issue.
>
> What is the definition of "range".
>
> You cannot simply redefine the meaning of "range". As you did by writing
> "inclusive" and then "exclusive" and flipping flopping whenever it suits
> you.
>
> The programming language known as C probably introduced the "curly brace
> language".
>
> Java is based on C and also uses the "curly brace language".
>
> Since Java seems to be based of off C and is actually implemented in C
> it's safe to say that the word known as "range" in computer language
> follows the same meaning as it has in C.
>
> Wikipedia is pretty clear about what "range" means in the programming
> language C:
>
> http://en.wikipedia.org/wiki/Range_(computer_programming)
>
> Range is always inclusive unless otherwise stated.

But it was otherwise stated in the Java docs, so ....

> Therefore a programmer seeing a prototype of "rangeCheck" without
> actually seeing the body of the code should be safe to assume that range
> encompanses all of the indexes, being inclusive.

A programmer would read the docs and understand what the code does.

Arne

[toc] | [prev] | [next] | [standalone]


#14721

From"Skybuck Flying" <Windows7IsOK@DreamPC2006.com>
Date2012-05-21 09:40 +0200
Message-ID<2fedf$4fb9fc61$5419acc3$22636@cache1.tilbu1.nb.home.nl>
In reply to#14692

"Arne Vajhøj"  wrote in message 
news:4fb97103$0$293$14726298@news.sunsite.dk...

On 5/17/2012 5:16 PM, Skybuck Flying wrote:
> Now it's becoming a computer programming language issue.
>
> What is the definition of "range".
>
> You cannot simply redefine the meaning of "range". As you did by writing
> "inclusive" and then "exclusive" and flipping flopping whenever it suits
> you.
>
> The programming language known as C probably introduced the "curly brace
> language".
>
> Java is based on C and also uses the "curly brace language".
>
> Since Java seems to be based of off C and is actually implemented in C
> it's safe to say that the word known as "range" in computer language
> follows the same meaning as it has in C.
>
> Wikipedia is pretty clear about what "range" means in the programming
> language C:
>
> http://en.wikipedia.org/wiki/Range_(computer_programming)
>
> Range is always inclusive unless otherwise stated.

"
But it was otherwise stated in the Java docs, so ....
"

It would be weird to expect a programmer to read a document about something 
as common and obvious as "range".

It's like programming a method called "Red" and then in the document it 
says: "Red is actually blue".

> Therefore a programmer seeing a prototype of "rangeCheck" without
> actually seeing the body of the code should be safe to assume that range
> encompanses all of the indexes, being inclusive.

"
A programmer would read the docs and understand what the code does.

Arne
"

Not necessarily, only if the programmer was being very thorough and has the 
time to do so.

The programmer might skip over things which he/she thinks are obvious.

Bye,
  Skybuck. 

[toc] | [prev] | [next] | [standalone]


#14736

FromJoshua Cranmer <Pidgeot18@verizon.invalid>
Date2012-05-21 10:05 -0400
Message-ID<jpdi31$ore$1@dont-email.me>
In reply to#14721
On 5/21/2012 3:40 AM, Skybuck Flying wrote:
> Not necessarily, only if the programmer was being very thorough and has
> the time to do so.
>
> The programmer might skip over things which he/she thinks are obvious.

Ranges having an inclusive start and an exclusive end are the most 
common type of range in languages with 0-based arrays.

-- 
Beware of bugs in the above code; I have only proved it correct, not 
tried it. -- Donald E. Knuth

[toc] | [prev] | [next] | [standalone]


#14678

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-05-20 14:41 -0400
Message-ID<4fb93ad3$0$294$14726298@news.sunsite.dk>
In reply to#14578
On 5/17/2012 11:26 AM, Skybuck Flying wrote:
> "Fred K" wrote in message
> news:29308868.1994.1337265697084.JavaMail.geo-discussion-forums@pbcuc6...
> On Thursday, May 17, 2012 6:09:23 AM UTC-7, Skybuck Flying wrote:
>> Hello,
>>
>> My hypothesis that a human being cannot write 10 lines of code without
>> making a mistake has been confirmed by either oracle or google or both
>> depending on what you believe ;)
>>
>> The lawsuit apperently mentions these 9 lines of code:
>>
>> "
>> private static void rangeCheck(int arrayLen, int fromIndex, int
>> toIndex) {
>> if (fromIndex > toIndex)
>> throw new IllegalArgumentException("fromIndex(" + fromIndex +
>> ") > toIndex(" + toIndex+")");
>
> "
> This is not C.
> "
>
> It's a curly brace language

That does not make it C.

Arne

[toc] | [prev] | [next] | [standalone]


#14685

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-05-20 18:12 -0400
Message-ID<4fb96c52$0$283$14726298@news.sunsite.dk>
In reply to#14578
On 5/17/2012 11:26 AM, Skybuck Flying wrote:
> This code is a nice example oh how not to program.
>
> Apperently only a skilled coder/debugger like me seems to be able to
> spot the fallacies in this way too debug-complex code.

You mean that only a complete clueless coder/debugger
would claim some code contains a bug without reading
the documentation for how it should work.

Arne

[toc] | [prev] | [next] | [standalone]


#14695

FromKeith Thompson <kst-u@mib.org>
Date2012-05-20 16:38 -0700
Message-ID<lnipfqjue6.fsf@nuthaus.mib.org>
In reply to#14685
Arne Vajhøj <arne@vajhoej.dk> writes:
> On 5/17/2012 11:26 AM, Skybuck Flying wrote:
>> This code is a nice example oh how not to program.
>>
>> Apperently only a skilled coder/debugger like me seems to be able to
>> spot the fallacies in this way too debug-complex code.
>
> You mean that only a complete clueless coder/debugger
> would claim some code contains a bug without reading
> the documentation for how it should work.

Arne, years of experience have shown that arguing with "Skybuck Flying"
is a waste of time.  Feel free to waste your time, but please don't
waste ours.

Thank you.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
    Will write code for food.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

[toc] | [prev] | [next] | [standalone]


#14696

FromLew <noone@lewscanon.com>
Date2012-05-20 18:52 -0700
Message-ID<jpc74s$et2$1@news.albasani.net>
In reply to#14695
Keith Thompson wrote:
> Arne Vajhøj writes:
>> Skybuck Flying wrote:
>>> This code is a nice example oh how not to program.
>>>
>>> Apperently only a skilled coder/debugger like me seems to be able to
>>> spot the fallacies in this way too debug-complex code.
>>
>> You mean that only a complete clueless coder/debugger
>> would claim some code contains a bug without reading
>> the documentation for how it should work.
>
> Arne, years of experience have shown that arguing with "Skybuck Flying"
> is a waste of time.  Feel free to waste your time, but please don't
> waste ours.

How is he to know what wastes your time? That's a judgment only you can make.

He is free to post any response to any poster he chooses. If you don't wish to 
"waste" your time, you don't have to read his responses to that poster. Any 
decent newsreader will organize your view into conversations so that you will 
know which of Arne's posts are likely to, in your own, personal, private 
judgment, waste your time. It is not Arne's job to judge posts on your behalf, 
nor your right to curtail his right to respond.

-- 
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

[toc] | [prev] | [next] | [standalone]


#14699

FromKeith Thompson <kst-u@mib.org>
Date2012-05-20 19:21 -0700
Message-ID<lnehqejmtw.fsf@nuthaus.mib.org>
In reply to#14696
Lew <noone@lewscanon.com> writes:
[...]
>                            It is not Arne's job to judge posts on your behalf, 
> nor your right to curtail his right to respond.

I'm not curtailing anybody's right to do anything.  I am *asking* someone
not to feed a troll.  And with that, I'm done here.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
    Will write code for food.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

[toc] | [prev] | [next] | [standalone]


#14717

Fromgazelle@shell.xmission.com (Kenny McCormack)
Date2012-05-21 08:24 +0000
Message-ID<jpcu3h$622$2@news.xmission.com>
In reply to#14699
In article <lnehqejmtw.fsf@nuthaus.mib.org>,
Keith Thompson  <kst-u@mib.org> wrote:
>Lew <noone@lewscanon.com> writes:
>[...]
>>                            It is not Arne's job to judge posts on your
>behalf, 
>> nor your right to curtail his right to respond.
>
>I'm not curtailing anybody's right to do anything.  I am *asking* someone
>not to feed a troll.  And with that, I'm done here.

Don't let the door hit your ass as you go.

Keith - you have to accept that, as the undisputed leader of this group,
when you "ask" someone not to do something, it carries significant weight.
It has the effect of being a ruling from on high.  Whether you intend so or
not, the fact is that people fall in line with your wishes.

-- 
"The anti-regulation business ethos is based on the charmingly naive notion
that people will not do unspeakable things for money." - Dana Carpender

Quoted by Paul Ciszek (pciszek at panix dot com).  But what I want to know
is why is this diet/low-carb food author doing making pithy political/economic
statements?

Nevertheless, the above quote is dead-on, because, the thing is - business
in one breath tells us they don't need to be regulated (which is to say:
that they can morally self-regulate), then in the next breath tells us that
corporations are amoral entities which have no obligations to anyone except
their officers and shareholders, then in the next breath they tell us they
don't need to be regulated (that they can morally self-regulate) ...

[toc] | [prev] | [next] | [standalone]


#14758

From"Bill Leary" <Bill_Leary@msn.com>
Date2012-05-23 14:34 -0400
Message-ID<Mb-dnYD9_8pFsCDSnZ2dnUVZ_qqdnZ2d@giganews.com>
In reply to#14717
"Kenny McCormack"  wrote in message news:jpcu3h$622$2@news.xmission.com...
> Keith - you have to accept that, as the undisputed leader of this group,

I'll dispute that.  I've never considered him (or anyone else) to be "the 
leader."  And still don't.

I'm sure you meant comp.lang.c, but one might be inclined to ask "which 
group."  I note there are three on the "Newsgroups..." line of my reader.

> when you "ask" someone not to do something, it carries significant weight.

On issues related to C, I'll grant you this is probably true.

> It has the effect of being a ruling from on high.  Whether you intend so 
> or
> not, the fact is that people fall in line with your wishes.

But no, I never felt any impulse to "fall in line" with his wishes.

    - Bill

[toc] | [prev] | [next] | [standalone]


#14709

FromJoe Pfeiffer <pfeiffer@cs.nmsu.edu>
Date2012-05-20 21:46 -0600
Message-ID<1behqep563.fsf@pfeifferfamily.net>
In reply to#14696
Lew <noone@lewscanon.com> writes:

> Keith Thompson wrote:
>> Arne Vajhøj writes:
>>> Skybuck Flying wrote:
>>>> This code is a nice example oh how not to program.
>>>>
>>>> Apperently only a skilled coder/debugger like me seems to be able to
>>>> spot the fallacies in this way too debug-complex code.
>>>
>>> You mean that only a complete clueless coder/debugger
>>> would claim some code contains a bug without reading
>>> the documentation for how it should work.
>>
>> Arne, years of experience have shown that arguing with "Skybuck Flying"
>> is a waste of time.  Feel free to waste your time, but please don't
>> waste ours.
>
> How is he to know what wastes your time? That's a judgment only you can make.
>
> He is free to post any response to any poster he chooses. If you don't
> wish to "waste" your time, you don't have to read his responses to
> that poster. Any decent newsreader will organize your view into
> conversations so that you will know which of Arne's posts are likely
> to, in your own, personal, private judgment, waste your time. It is
> not Arne's job to judge posts on your behalf, nor your right to
> curtail his right to respond.

Sadly, it seems every new person who encounters Skybuck feels the need
to respond to him for a while before finally learning his lesson.  And
for reasons that escape me, trying to clue somebody in on what they can
expect is taken as being a Net Cop.

[toc] | [prev] | [next] | [standalone]


#14714

FromLew <noone@lewscanon.com>
Date2012-05-21 00:04 -0700
Message-ID<jpcpdk$iea$1@news.albasani.net>
In reply to#14709
Joe Pfeiffer wrote:
> Lew writes:
>> Keith Thompson wrote:
>>> Arne Vajhøj writes:
>>>> Skybuck Flying wrote:
>>>>> This code is a nice example oh how not to program.
>>>>>
>>>>> Apperently only a skilled coder/debugger like me seems to be able to
>>>>> spot the fallacies in this way too debug-complex code.
>>>>
>>>> You mean that only a complete clueless coder/debugger
>>>> would claim some code contains a bug without reading
>>>> the documentation for how it should work.
>>>
>>> Arne, years of experience have shown that arguing with "Skybuck Flying"
>>> is a waste of time.  Feel free to waste your time, but please don't
>>> waste ours.
>>
>> How is he to know what wastes your time? That's a judgment only you can make.
>>
>> He is free to post any response to any poster he chooses. If you don't
>> wish to "waste" your time, you don't have to read his responses to
>> that poster. Any decent newsreader will organize your view into
>> conversations so that you will know which of Arne's posts are likely
>> to, in your own, personal, private judgment, waste your time. It is
>> not Arne's job to judge posts on your behalf, nor your right to
>> curtail his right to respond.
>
> Sadly, it seems every new person who encounters Skybuck feels the need
> to respond to him for a while before finally learning his lesson.  And
> for reasons that escape me, trying to clue somebody in on what they can
> expect is taken as being a Net Cop.

Keith didn't try to "clue somebody in", he asked Arne to stop posting because 
he (Keith) claimed that Arne's responses were wasting his (Keith's) time. 
There was nothing in Keith's message to suggest that he was offering advice to 
benefit Arne. So your comment is not relevant.

If Keith had evinced any concern whatsoever for Arne, that would have been a 
different story. Ditto you - I don't see you showing any concern for Arne 
either, just whining about how people thing someone is a "Net Cop".

Furthermore, there are others who read the newsgroup who may benefit from 
answers to Skyfreak, even if Skyfreak itself does not. So let Arne post what 
he will. Please.

-- 
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

[toc] | [prev] | [next] | [standalone]


#14718

Fromgazelle@shell.xmission.com (Kenny McCormack)
Date2012-05-21 08:25 +0000
Message-ID<jpcu6d$622$3@news.xmission.com>
In reply to#14696
In article <jpc74s$et2$1@news.albasani.net>, Lew  <noone@lewscanon.com> wrote:
>Keith Thompson wrote:
>> Arne Vajhøj writes:
>>> Skybuck Flying wrote:
>>>> This code is a nice example oh how not to program.
>>>>
>>>> Apperently only a skilled coder/debugger like me seems to be able to
>>>> spot the fallacies in this way too debug-complex code.
>>>
>>> You mean that only a complete clueless coder/debugger
>>> would claim some code contains a bug without reading
>>> the documentation for how it should work.
>>
>> Arne, years of experience have shown that arguing with "Skybuck Flying"
>> is a waste of time.  Feel free to waste your time, but please don't
>> waste ours.
>
>How is he to know what wastes your time? That's a judgment only you can make.
>
>He is free to post any response to any poster he chooses. If you don't wish to 
>"waste" your time, you don't have to read his responses to that poster. Any 
>decent newsreader will organize your view into conversations so that you will 
>know which of Arne's posts are likely to, in your own, personal, private 
>judgment, waste your time. It is not Arne's job to judge posts on your behalf, 
>nor your right to curtail his right to respond.

Well said, sir!

Pretty much Usenet 101 stuff, but you are to be commended for speaking truth
to power.

-- 

First of all, I do not appreciate your playing stupid here at all.

	- Thomas 'PointedEars' Lahn -

[toc] | [prev] | [next] | [standalone]


#14722

From"Skybuck Flying" <Windows7IsOK@DreamPC2006.com>
Date2012-05-21 09:46 +0200
Message-ID<3cc87$4fb9fc61$5419acc3$22636@cache1.tilbu1.nb.home.nl>
In reply to#14685

"Arne Vajhøj"  wrote in message 
news:4fb96c52$0$283$14726298@news.sunsite.dk...

On 5/17/2012 11:26 AM, Skybuck Flying wrote:
> This code is a nice example oh how not to program.
>
> Apperently only a skilled coder/debugger like me seems to be able to
> spot the fallacies in this way too debug-complex code.

"
You mean that only a complete clueless coder/debugger
would claim some code contains a bug without reading
the documentation for how it should work.

Arne
"

No my remarks were remarks aimed at general coding practices. It was about 
creating unnecessary branch dependencies.

The more dependencies a piece of code has the harder it becomes to debug or 
even modify it.

The phenomenon of: "changing something here, and something else somewhere 
else breaks" <- this is caused by dependencies.

Less dependencies make code easier to debug, easier to garantuee that it 
will work, and easier to modify/keep it flexible.

Furthermore I suspect C/C++ programmers have less time to debug because of 
slow compilers, so they less experienced with it, don't care, "bill gates 
don't care" and see it as a chore, thus they fail to learn what their coding 
practices/dependencies are causing... : a big, buggy, complex, inflexible 
mess ;) :)

Bye,
  Skybuck.





[toc] | [prev] | [next] | [standalone]


#14584

Fromjacob navia <jacob@spamsink.net>
Date2012-05-17 18:54 +0200
Message-ID<jp3afv$d6i$1@speranza.aioe.org>
In reply to#14576
I think you are 100% right. Human beings are just too stupid.

Let's get rid of them, starting with you.

[toc] | [prev] | [next] | [standalone]


Page 3 of 6 — ← Prev page 1 2 [3] 4 5 6  Next page →

Back to top | Article view | comp.lang.java.programmer


csiph-web