Thread: C++-Language Function/Process List

C++-Language Function/Process List

From
Kelly Burkhart
Date:
I've written a simple function to return a list of processes running on
the server.  The function uses the Linux /proc filesystem, so is not
portable.  Usage is like this:

tradebot01@ [local] => select * from tb_ps() where command like
'%post%';
  pid  | username |                    command
-------+----------+------------------------------------------------
  3597 | root     | /usr/lib/postfix/master
 23671 | postgres | /usr/bin/postmaster -i -D /var/lib/pgsql/data
 23677 | postgres | postgres: stats buffer process
 23678 | postgres | postgres: stats collector process
 23738 | postgres | postgres: tradebot tradebot01 [local]: SELECT
(5 rows)


I used C++ and noticed that some Postgres headers contain C++ keywords.
Is there any interest among PG developers in making the C-language
interface C++ clean?  Or, is there hostility to this idea?

-K

Attachment

Re: C++-Language Function/Process List

From
Douglas McNaught
Date:
Kelly Burkhart <kelly@tradebotsystems.com> writes:

> I used C++ and noticed that some Postgres headers contain C++ keywords.
> Is there any interest among PG developers in making the C-language
> interface C++ clean?  Or, is there hostility to this idea?

Postgres is written in C.  AIUI it's somewhat dangerous to link C++
functions into the backend, since PG doesn't know how to cope with
thrown exceptions and the like.

-Doug

Re: C++-Language Function/Process List

From
Martijn van Oosterhout
Date:
On Mon, May 23, 2005 at 09:13:00AM -0500, Kelly Burkhart wrote:
> I used C++ and noticed that some Postgres headers contain C++ keywords.
> Is there any interest among PG developers in making the C-language
> interface C++ clean?  Or, is there hostility to this idea?

Hmm, it seems C++ is joining the club with SQL in taking lots of
commonly used words and turning them into keywords.

I don't think it's actively being worked against, it's just that c++
has added some 50 keywords to the language, most of which are ordinary
english words. It will take time to go through and update all the
sources...

For reference, the keywords in question are using, typename and typeid.
Anyone think of any alternative names that don't lose the meaning?
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Attachment

Re: C++-Language Function/Process List

From
Tom Lane
Date:
Douglas McNaught <doug@mcnaught.org> writes:
> Kelly Burkhart <kelly@tradebotsystems.com> writes:
>> I used C++ and noticed that some Postgres headers contain C++ keywords.
>> Is there any interest among PG developers in making the C-language
>> interface C++ clean?  Or, is there hostility to this idea?

> Postgres is written in C.  AIUI it's somewhat dangerous to link C++
> functions into the backend, since PG doesn't know how to cope with
> thrown exceptions and the like.

However, as long as you avoid constructs like throw that require C++
library support, you can in principle use C++ as "a better C".  (Now
that we have PG_TRY it might even be interesting to see if that could
be integrated with C++ throw ...)

Avoiding C++ keywords has been discussed before, and my recollection is
that we decided the changes would be more invasive than the value would
justify.  But that was a long time ago and the situation may have
changed.  I'd suggest spending enough time to work up a rough list of
what would need to be changed, and putting it up for discussion in the
-hackers list.

            regards, tom lane