Re: PSQL commands: \quit_if, \quit_unless - Mailing list pgsql-hackers

From Fabien COELHO
Subject Re: PSQL commands: \quit_if, \quit_unless
Date
Msg-id alpine.DEB.2.20.1611300828580.13369@lancre
Whole thread Raw
In response to Re: PSQL commands: \quit_if, \quit_unless  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hello Tom,

> But really, \fi is something that could only be loved by a certain 
> academic breed of hackers.

Ah ah:-) I'll take that as a compliment:-)

> I'd go for \endif, probably. That still doesn't relate well with 
> \unless, so +1 for \if, \ifnot, \else, and \endif.

Ok, that is a clear opinion.

> I'm not really convinced that we need an \elseif at this point.
> It could be added later if people find it compelling, but I'm
> having a hard time believing that it's essential.

My experience with cpp is that #elif is quite useful in some cases, 
typically with alternate implementations depending on dependences, to 
avoid this:
 #ifdef HAVE_XXX   ... #else #ifdef HAVE_YYY   ... #else #ifdef HAVE ZZZ   ... #else #error "oops!" #endif // HAVE_ZZZ
#endif// HAVE_YYY #endif // HAVE_XXX
 

I think that some realistic use cases examples for psql would be great...

If the else-if is a common pattern then it should be at least in the 
design, even if not implemented right away. Also ISTM that having else-if 
is not too compatible with multiplying \if* because it leads to pretty 
ugly \el*if* variants which are quite hard to parse and understand, so 
there is an impact on the design.

-- 
Fabien.



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Random number generation, take two
Next
From: Michael Paquier
Date:
Subject: Re: pgsql: Add putenv support for msvcrt from Visual Studio 2013