Thread: [GENERAL] Functions and Parentheses

[GENERAL] Functions and Parentheses

From
"Igal @ Lucee.org"
Date:

Hi,

Is current_date a function?  It's a bit puzzling to me since there are no parentheses after it, i.e.

  SELECT current_date;

And not

  SELECT current_date();  -- syntax error

How come `current_date` has no parenthesis but `clock_timestamp()` does?

Thanks,

Igal Sapir
Lucee Core Developer
Lucee.org

Re: [GENERAL] Functions and Parentheses

From
"David G. Johnston"
Date:
On Fri, Oct 6, 2017 at 2:18 PM, Igal @ Lucee.org <igal@lucee.org> wrote:

Hi,

Is current_date a function?  It's a bit puzzling to me since there are no parentheses after it, i.e.

  SELECT current_date;

And not

  SELECT current_date();  -- syntax error

It, and the others like it, behave as functions.  They don't require parentheses because the SQL standard​
​ defines them without parentheses.

How come `current_date` has no parenthesis but `clock_timestamp()` does?

clock_timestamp isn't standard defined and unless the standard forces us to do otherwise function invocation requires parentheses.


David J.

Re: [GENERAL] Functions and Parentheses

From
Tom Lane
Date:
"Igal @ Lucee.org" <igal@lucee.org> writes:
> How come `current_date` has no parenthesis but `clock_timestamp()` does?

Because the SQL standard says that CURRENT_DATE doesn't have parentheses.
It is a function by any other measure, though.

(AFAICT, the SQL committee is unacquainted with any principles of
programming language syntax design that emerged later than the COBOL
era.  Their capacity to invent new and non-orthogonal syntax for every
new feature seems boundless.)
        regards, tom lane


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Functions and Parentheses

From
"Joshua D. Drake"
Date:
On 10/06/2017 02:33 PM, Tom Lane wrote:
> "Igal @ Lucee.org" <igal@lucee.org> writes:
>> How come `current_date` has no parenthesis but `clock_timestamp()` does?
> 
> Because the SQL standard says that CURRENT_DATE doesn't have parentheses.
> It is a function by any other measure, though.
> 
> (AFAICT, the SQL committee is unacquainted with any principles of
> programming language syntax design that emerged later than the COBOL
> era.  Their capacity to invent new and non-orthogonal syntax for every
> new feature seems boundless.)

This is the best statement I have read all week.

JD


> 
>             regards, tom lane
> 
> 


-- 
Command Prompt, Inc. || http://the.postgres.company/ || @cmdpromptinc

PostgreSQL Centered full stack support, consulting and development.
Advocate: @amplifypostgres || Learn: https://pgconf.us
*****     Unless otherwise stated, opinions are my own.   *****


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Functions and Parentheses

From
"Igal @ Lucee.org"
Date:
On 10/6/2017 3:10 PM, Joshua D. Drake wrote:
On 10/06/2017 02:33 PM, Tom Lane wrote:
"Igal @ Lucee.org" <igal@lucee.org> writes:
How come `current_date` has no parenthesis but `clock_timestamp()` does?

Because the SQL standard says that CURRENT_DATE doesn't have parentheses.
It is a function by any other measure, though.

(AFAICT, the SQL committee is unacquainted with any principles of
programming language syntax design that emerged later than the COBOL
era.  Their capacity to invent new and non-orthogonal syntax for every
new feature seems boundless.)

This is the best statement I have read all week.

+1

I also want to say that I'm using many different open source projects, but Postgres has by far the best community support of all, not to mention a product that is far superior to the many commercial alternatives in the market.

It's kind of like -- I can use Postgres for free, or I can spend a lot of money and get an inferior product with inferior support.

If Postgres had been written in Java then I'd be much more involved, but my C/C++ skills are rather limited.

Anyway, great job guys!  And Thank you!

Igal Sapir
Lucee Core Developer
Lucee.org