From: | Mark Dilger <pgsql(at)markdilger(dot)com> |
---|---|
To: | Douglas McNaught <doug(at)mcnaught(dot)org> |
Subject: | Re: PL/pgSQL 'i = i + 1' Syntax |
Date: | 2006-05-19 00:44:47 |
Message-ID: | 446D14FF.4030207@markdilger.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Douglas McNaught wrote:
> Mark Dilger <pgsql(at)markdilger(dot)com> writes:
>
>
>>Tom Lane wrote:
>>
>>>No it isn't. The plpgsql scanner treats := and = as *the same token*.
>>>They can be interchanged freely. This has nothing to do with the case
>>>of modifying a loop variable in particular.
>>
>>I disagree. If the scanner treated them the same, then
>>
>> if i := 1 then ...
>>
>>would work, but it doesn't. The := is rejected in a conditional. Try the
>>following code if you don't believe me:
>
>
> That's because (AIUI) all expressions to be evaluated are handed off
> to the SQL parser (why re-implement all that logic and have subtle and
> annoying differences?) plpgsql only handles the statements, loops, etc.
> So it doesn't care about the difference but SQL does...
Ok, ten out of ten for technical accuracy; the error occurs at a lower level.
But that really doesn't matter, does it? If the syntax results in an error,
then the argument that '=' and ':=' are interchangeable is wrong.
As a coder, if you notice that using ':=' within a conditional fails, wouldn't
you think that implied that ':=' is for assignment and '=' is for comparison?
mark
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2006-05-19 00:54:12 | Re: text_position worst case runtime |
Previous Message | Douglas McNaught | 2006-05-19 00:40:04 | Re: PL/pgSQL 'i = i + 1' Syntax |