HASHes [was Re: [HACKERS] Calling PL functions with named parameters]

2004-08-16 Thread David Fetter
On Fri, Aug 13, 2004 at 07:12:14PM -0400, Tom Lane wrote: Jim C. Nasby [EMAIL PROTECTED] writes: IOW, their function resolution code treats a(int, int default 0) as being equivalent to a(int) and a(int, int). So you are willing to prohibit a(int) from existing in parallel with a(int,

Re: HASHes [was Re: [HACKERS] Calling PL functions with named parameters]

2004-08-16 Thread Tom Lane
David Fetter [EMAIL PROTECTED] writes: What about making HASHes a first-class object? I see less than zero value in this. You'd have to serialize the contents to ship it to the client anyway, so there is no particular point in inventing a random new representation for row.

Re: [HACKERS] Calling PL functions with named parameters

2004-08-16 Thread Josh Berkus
Tom, I agree however with Andrew's nearby point that this is completely unrelated to named parameters to functions/procedures, or to defaults for parameters. I think that was Peter's point, not Andrew's.Andrew agreed with me. I do think, though, that we should hammer out the parameters,

Re: [HACKERS] Calling PL functions with named parameters

2004-08-16 Thread Tom Lane
Josh Berkus [EMAIL PROTECTED] writes: Tom, just to be perfectly clear about why I see Procedures as a way of resolving parameter ambiguity, my idea is that: FUNCTIONS will support overloading but will not support named parameter calling; PROCEDURES will support named parameter calling but

Re: [HACKERS] Calling PL functions with named parameters

2004-08-16 Thread Josh Berkus
Tom, Understood, but this seems like a bad design to me, because it's non-orthogonal. Or just a natural consequence of our having loaded Functions down with all of the functionality usually assigned to Procedures over the years. I think that named params would have no significant extra cost

Re: [HACKERS] Calling PL functions with named parameters

2004-08-14 Thread Gaetano Mendola
Oliver Jowett wrote: Tom Lane wrote: On a related note, it would also be nice to have default parameters and some way to say to use them. That is fundamentally not ever going to happen, because it blows overloaded-function resolution out of the water: there is no way to choose whether foo(42,

Re: [HACKERS] Calling PL functions with named parameters

2004-08-14 Thread Gaetano Mendola
Oliver Jowett wrote: Gaetano Mendola wrote: Oliver Jowett wrote: David Fetter wrote: Dennis has pointed out that mixing the call-with-named-parameter interface with call-by-order-of-parameters one would cause confusion, Python's equivalent syntax allows you to mix the two forms so long as all

Re: [HACKERS] Calling PL functions with named parameters

2004-08-14 Thread Peter Eisentraut
David Fetter wrote: I'd like to be able to create functions with named parameters that could be called with the names in any order. For example, CREATE OR REPLACE FUNCTION foo_func(name TEXT, val INTEGER) AS ... SELECT foo_func(val AS 23, name AS 'Name goes here'); When that was brought up

Re: [HACKERS] Calling PL functions with named parameters

2004-08-14 Thread Oliver Jowett
Gaetano Mendola wrote: C++ manages to solve this problem, although I can't remember the exact mechanics (and C++ is usually not a good example to follow anyway ;) Your're wrong: try to compile this: [...] a.cpp:6: error: call of overloaded `foo(int, double)' is ambiguous a.cpp:1: error:

Re: [HACKERS] Calling PL functions with named parameters

2004-08-14 Thread Oliver Jowett
Gaetano Mendola wrote: Oliver Jowett wrote: Gaetano Mendola wrote: Oliver Jowett wrote: David Fetter wrote: Dennis has pointed out that mixing the call-with-named-parameter interface with call-by-order-of-parameters one would cause confusion, Python's equivalent syntax allows you to mix the two

Re: [HACKERS] Calling PL functions with named parameters

2004-08-14 Thread Harald Fuchs
In article [EMAIL PROTECTED], Oliver Jowett [EMAIL PROTECTED] writes: I think you just made my point for me. C++ allows default parameters and resolves the ambiguity by disallowing ambiguous calls when they happen. I'm not sure why C++ doesn't disallow it at declaration time off the top of

Re: [HACKERS] Calling PL functions with named parameters

2004-08-14 Thread Oliver Jowett
Gaetano Mendola wrote: Oliver Jowett wrote: David Fetter wrote: Dennis has pointed out that mixing the call-with-named-parameter interface with call-by-order-of-parameters one would cause confusion, Python's equivalent syntax allows you to mix the two forms so long as all the

Re: [HACKERS] Calling PL functions with named parameters

2004-08-14 Thread Gaetano Mendola
Harald Fuchs wrote: In article [EMAIL PROTECTED], Oliver Jowett [EMAIL PROTECTED] writes: I think you just made my point for me. C++ allows default parameters and resolves the ambiguity by disallowing ambiguous calls when they happen. I'm not sure why C++ doesn't disallow it at declaration time

Re: [HACKERS] Calling PL functions with named parameters

2004-08-14 Thread Gaetano Mendola
Oliver Jowett wrote: Gaetano Mendola wrote: Oliver Jowett wrote: Gaetano Mendola wrote: Oliver Jowett wrote: David Fetter wrote: Dennis has pointed out that mixing the call-with-named-parameter interface with call-by-order-of-parameters one would cause confusion, Python's

Re: [HACKERS] Calling PL functions with named parameters

2004-08-14 Thread Gaetano Mendola
Oliver Jowett wrote: Gaetano Mendola wrote: Oliver Jowett wrote: David Fetter wrote: Dennis has pointed out that mixing the call-with-named-parameter interface with call-by-order-of-parameters one would cause confusion, Python's equivalent syntax allows you to mix the two forms so

Re: [HACKERS] Calling PL functions with named parameters

2004-08-14 Thread Andreas Pflug
Tom Lane wrote: David Fetter [EMAIL PROTECTED] writes: CREATE OR REPLACE FUNCTION foo_func(name TEXT, val INTEGER) AS ... SELECT foo_func(val AS 23, name AS 'Name goes here'); I don't think that syntax will work. You could possibly do it the other way round: SELECT foo_func(23 AS val, 'Name

Re: [HACKERS] Calling PL functions with named parameters

2004-08-14 Thread Josh Berkus
David, Dennis has pointed out that mixing the call-with-named-parameter interface with call-by-order-of-parameters one would cause confusion, and I think it would be OK to disallow this type mixing, so As we've discussed on IRC, this should be the difference between a FUNCTION and a

Re: [HACKERS] Calling PL functions with named parameters

2004-08-14 Thread Peter Eisentraut
Josh Berkus wrote: Dennis has pointed out that mixing the call-with-named-parameter interface with call-by-order-of-parameters one would cause confusion, and I think it would be OK to disallow this type mixing, so As we've discussed on IRC, this should be the difference between a

Re: [HACKERS] Calling PL functions with named parameters

2004-08-14 Thread Andrew Dunstan
Peter Eisentraut wrote: Josh Berkus wrote: Dennis has pointed out that mixing the call-with-named-parameter interface with call-by-order-of-parameters one would cause confusion, and I think it would be OK to disallow this type mixing, so As we've discussed on IRC, this should be the

Re: [HACKERS] Calling PL functions with named parameters

2004-08-14 Thread Tom Lane
Peter Eisentraut [EMAIL PROTECTED] writes: Josh Berkus wrote: b) Procedures are not automatically transactional; that is, transactions within procedures must/can be explicit. Among other things, this would allow procedures to run maintainence tasks. I certainly want all my maintenance tasks

[HACKERS] Calling PL functions with named parameters

2004-08-13 Thread David Fetter
Kind people, I've brought this up before, and with Dennis Bjőrklund's help, would like to bring it up again. Here's the idea: I'd like to be able to create functions with named parameters that could be called with the names in any order. For example, CREATE OR REPLACE FUNCTION foo_func(name

Re: [HACKERS] Calling PL functions with named parameters

2004-08-13 Thread Tom Lane
David Fetter [EMAIL PROTECTED] writes: CREATE OR REPLACE FUNCTION foo_func(name TEXT, val INTEGER) AS ... SELECT foo_func(val AS 23, name AS 'Name goes here'); I don't think that syntax will work. You could possibly do it the other way round: SELECT foo_func(23 AS val, 'Name goes here' AS

Re: [HACKERS] Calling PL functions with named parameters

2004-08-13 Thread Oliver Jowett
David Fetter wrote: Dennis has pointed out that mixing the call-with-named-parameter interface with call-by-order-of-parameters one would cause confusion, and I think it would be OK to disallow this type mixing, so SELECT foo_func(name AS 'yet another name', 35); would be disallowed. Python's

Re: [HACKERS] Calling PL functions with named parameters

2004-08-13 Thread Jim C. Nasby
I would personally find this useful, but I would suggest using Oracle's syntax of SELECT func(a=2, b='b', ...); Having said that, having the concept of DEFAULT for parameters wolud be even more useful, ie: CREATE FUNCTION blah ( a int , b int DEFAULT 0 ); SELECT blah(1,0); and SELECT

Re: [HACKERS] Calling PL functions with named parameters

2004-08-13 Thread Jim C. Nasby
On Fri, Aug 13, 2004 at 06:22:25PM -0400, Tom Lane wrote: On a related note, it would also be nice to have default parameters and some way to say to use them. That is fundamentally not ever going to happen, because it blows overloaded-function resolution out of the water: there is no way

Re: [HACKERS] Calling PL functions with named parameters

2004-08-13 Thread Tom Lane
Jim C. Nasby [EMAIL PROTECTED] writes: IOW, their function resolution code treats a(int, int default 0) as being equivalent to a(int) and a(int, int). So you are willing to prohibit a(int) from existing in parallel with a(int, int-with-a-default) ? I'll be interested to see the unique-index

Re: [HACKERS] Calling PL functions with named parameters

2004-08-13 Thread Oliver Jowett
Tom Lane wrote: On a related note, it would also be nice to have default parameters and some way to say to use them. That is fundamentally not ever going to happen, because it blows overloaded-function resolution out of the water: there is no way to choose whether foo(42, 2.5) matches foo(int,

Re: [HACKERS] Calling PL functions with named parameters

2004-08-13 Thread Oliver Jowett
Gaetano Mendola wrote: Oliver Jowett wrote: David Fetter wrote: Dennis has pointed out that mixing the call-with-named-parameter interface with call-by-order-of-parameters one would cause confusion, Python's equivalent syntax allows you to mix the two forms so long as all the by-position

Re: [HACKERS] Calling PL functions with named parameters

2004-08-13 Thread Gaetano Mendola
Oliver Jowett wrote: David Fetter wrote: Dennis has pointed out that mixing the call-with-named-parameter interface with call-by-order-of-parameters one would cause confusion, and I think it would be OK to disallow this type mixing, so SELECT foo_func(name AS 'yet another name', 35); would be

Re: [HACKERS] Calling PL functions with named parameters

2004-08-13 Thread Robert Treat
Would it be any better to allow SELECT blah(1,DEFAULT); ? Robert Treat On Friday 13 August 2004 18:49, Jim C. Nasby wrote: I would personally find this useful, but I would suggest using Oracle's syntax of SELECT func(a=2, b='b', ...); Having said that, having the concept of DEFAULT for

Re: [HACKERS] Calling PL functions with named parameters

2004-08-13 Thread Tom Lane
Robert Treat [EMAIL PROTECTED] writes: Would it be any better to allow SELECT blah(1,DEFAULT); Not a lot. If there is more than one 2-parameter blah(), how do you pick? The DEFAULT gives you no clue at all about the type of the second parameter... I think if we wanted to do something like