Re: Casting, again - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: Casting, again
Date
Msg-id Pine.LNX.4.21.0005151731040.349-100000@localhost.localdomain
Whole thread Raw
List 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@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Proposal for fixing numeric type-resolution issues
Next
From: Peter Eisentraut
Date:
Subject: Re: Cast of numeric()