Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL)

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL)
Date: 2013-04-03 18:51:07
Message-ID: 20130403185107.GE27856@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2013-04-04 07:42:36 +1300, Gavin Flower wrote:
> On 04/04/13 05:21, Pavel Stehule wrote:
> >
> >>
> >> Pavel
> >>
> > ALOGOL 60 was zero based by default, as I remember
> > deliberately setting the lower bound to 1, I managed to avoid
> > PASCAL and I only glanced at ADA.
> >
> >
> > http://en.wikipedia.org/wiki/Comparison_of_programming_languages_%28array%29
> >
> >
> >In Pascal and similar languages (Wirth family) is possible to define lower
> >bound - any value (like PL/pgSQL). Depends on a school - but lot of people
> >used 1.
> >
> >I remember - it was one argument for in Pascal/C flame war.
> >
> >Regards
> >
> >Pavel
> >
> [...]
>
> At the time (just over 40 years ago!) I was adamant that arrays should start
> with an index of one, now I much prefer zero. Probably I prefer zero in
> part, because now I understand what is happening at the machine code level,
> and partly because zero is the default for the main languages I use.
>
> Wasting time on Google (I have 'more' important things I 'should' be
> doing!), I find ALGOL 60 did not appear to have a default value for the
> lower index - not only that, but one could make it negative! see:
> http://www.csci.csusb.edu/dick/samples/algol60.syntax.html
>
> Anyhow, I think we should standardise on zero as the initial index to be as
> consistent as practicable. However, not with a religious zeal at the
> expense of practical considerations!

Changing this now, rather than on a green field, strikes me as a pretty
absurd exercise in frustrating users by breaking queries subtly. Since 1
is a value index that won't always break visible.

-1

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Gavin Flower 2013-04-03 18:53:05 Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL)
Previous Message Gavin Flower 2013-04-03 18:42:36 Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL)