Namespace issues

From: Don Y <pgsql(at)DakotaCom(dot)Net>
To: pgsql-general(at)postgresql(dot)org
Subject: Namespace issues
Date: 2006-05-16 17:29:27
Message-ID: 446A0BF7.5020009@DakotaCom.Net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Don Y 2006-05-16 17:30:16 Re: error handling in cast functions for user defined types
Previous Message Tom Lane 2006-05-16 17:01:51 Re: Weird ..... (a=1 or a=2) <> (a=2 or a=1)