Re: PL/pgSQL 'i = i + 1' Syntax

From: Hannu Krosing <hannu(at)skype(dot)net>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: josh(at)agliodbs(dot)com, pgsql-hackers(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, all(at)adv(dot)magwien(dot)gv(dot)at
Subject: Re: PL/pgSQL 'i = i + 1' Syntax
Date: 2006-05-17 21:18:19
Message-ID: 1147900699.3889.28.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Ühel kenal päeval, K, 2006-05-17 kell 16:31, kirjutas Andrew Dunstan:
> Hannu Krosing wrote:
> >> I don't think too many people are using that functionality intentionally; I
> >> probably write more PL/pgSQL than anyone and would regard any assignment
> >> without ":=" as a bug.
> >>
> >
> > I do occasionally write some pl/pgSQL, and have at some points written a
> > lot of it. And most of it uses = instead of := , including all code
> > written during last 1.5 years.
> >
> > Once I found out that = works for assignment, i completely stopped
> > using := .I have treated := as "deprecated" for some time already.
> >
> > So allowing only := for assignment would make me very sad .
> >
>
> I can only comment that that seems crazy.
>
> := is
> . documented
> . consistent with pl/sql and ancestors

OTOH
* = is used in CONST declaration in PASCAL, whereas pl/pgSQL
documents := (i.e. ASSIGNMENT) for const declaration
* = is used by everybody else for assignment. It can be argued that the
reason it is not used in pure SQL for assignment is just that SQL
lacks assignment.
* weather = is assignment statement or comparison operator is always
clear from position, that is pl/pgsql does not have result for
assignment statement, so everywhere the value of "A = B" is used,
it must be comparison operator, whereas when its
value is not used it must be statement. So no disambiguity.

> Even C doesn't use the same operator for assignment and comparison.

It can't, as in C both assignment and comparison are operators, so it
allows you to use result of both as boolean.

> Sometimes I wonder if large parts of the IT world is trying to pretend
> that the Algol family never existed.

And even bigger part is trying to pretend that LISP and Prolog never
existed ;) And don't forget about QUEL and PostQUEL either.

--
----------------
Hannu Krosing
Database Architect
Skype Technologies OÜ
Akadeemia tee 21 F, Tallinn, 12618, Estonia

Skype me: callto:hkrosing
Get Skype for free: http://www.skype.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2006-05-17 21:44:22 Re: Compression and on-disk sorting
Previous Message Andrew Dunstan 2006-05-17 21:03:54 Re: PL/pgSQL 'i = i + 1' Syntax