Re: PL/pgSQL 'i = i + 1' Syntax - Mailing list pgsql-hackers

From Hannu Krosing
Subject Re: PL/pgSQL 'i = i + 1' Syntax
Date
Msg-id 1147900699.3889.28.camel@localhost.localdomain
Whole thread Raw
In response to Re: PL/pgSQL 'i = i + 1' Syntax  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: PL/pgSQL 'i = i + 1' Syntax
List 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
assignmentis just that SQL lacks assignment.
 
* weather = is assignment statement or comparison operator is always clear from position, that is pl/pgsql does not
haveresult for assignment statement, so everywhere the value of "A = B" is used,  it must be comparison operator,
whereaswhen 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




pgsql-hackers by date:

Previous
From: "Jim C. Nasby"
Date:
Subject: Cross-version dumps (was: [DOCS] Mention pg_dump version portability)
Next
From: "Andrew Dunstan"
Date:
Subject: Re: PL/pgSQL 'i = i + 1' Syntax