Namespace issues - Mailing list pgsql-general

From Don Y
Subject Namespace issues
Date
Msg-id 446A0BF7.5020009@DakotaCom.Net
Whole thread Raw
Responses Re: Namespace issues  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
Given a user defined type foo...
I've created several casts to/from foo and built-in types.
I had adopted a naming convention of:
   baz foo_to_baz(foo);
   foo foo_from_baz(baz);

But:

   ...it is recommended that you continue to follow this old
   convention of naming cast implementation functions after
   the target data type. Many users are used to being able to
   cast data types using a function-style notation, that is
   typename(x). This notation is in fact nothing more nor less
   than a call of the cast implementation function; it is not
   specially treated as a cast. If your conversion functions
   are not named to support this convention then you will have
   surprised users. Since PostgreSQL allows overloading of the
   same function name with different argument types, there is no
   difficulty in having multiple conversion functions from
   different types that all use the target type’s name.

This suggests:
   baz baz(foo);
   foo foo(baz);

I don't see how I can do this in my declarations.  E.g.,
if I have
   baz = {int4, text, float8, ...}
then I end up with several (C) functions all named foo()
but each taking a different argument type (baz).  Since
C doesn't support more than a single namespace for functions,
this just won't work.

What am I failing to see, here?

Thanks!
--don

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Weird ..... (a=1 or a=2) <> (a=2 or a=1)
Next
From: Don Y
Date:
Subject: Re: error handling in cast functions for user defined types