Re: Casting, again

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Casting, again
Date: 2000-05-15 18:57:27
Message-ID: Pine.LNX.4.21.0005151731040.349-100000@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane writes:

> I've noticed in other cases that it's willing to do implicit
> conversion to text from practically anything. That strikes me as a
> bug, or at least pretty darn unintuitive. Is this behavior
> intentional, and if so what's the rationale?

Well, I'm sure you know my stance on these things by now, but let me add
one last thing: What I'm missing from the type system is a governing
strategy. On the one hand there is strong typing, on the other hand
implicit casting across the board, but not when you would actually want
it. This is usually where programming language paradigms clash, but note
that programming language design in the last two decades has clearly been
moving to one of two things: either strong and strict typing or no typing
at all. I'm not saying I like strict like Java were you can't pass a
literal `5' as a `short int' argument without complaints but strict as in
a string is a string, a date is a date, a point is a point, a number is a
number.

I would go as far as saying that if you try to insert a 5 in a text field
then this should be an error, you must write '5'. Surely some might claim
that this is an inconvenience. Indeed, this is inconveniencing me because
possible errors in string processing or even system logic are silently
dropped under the table. Nobody ever got carpal tunnel syndrome because of
two extra quotes, and if the SQL is machine-generated then fixing the
program is the best thing in the long run anyway.

The previous paragraph agrees with SQL (see section 9.2).

--
Peter Eisentraut Sernanders väg 10:115
peter_e(at)gmx(dot)net 75262 Uppsala
http://yi.org/peter-e/ Sweden

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2000-05-15 18:58:31 Re: Cast of numeric()
Previous Message Peter Eisentraut 2000-05-15 18:56:51 Re: Proposal for fixing numeric type-resolution issues