Peter Eisentraut <peter_e@gmx.net> writes:
> OK, let's look at these more closely:
>> array_push(anyarray, anyelement) returns anyarray
> The standard spelling for that appears to be
> somearray || ARRAY[element]
> which also has the nice property that it is commutative.
Sure ... but that just means that || is the operator name for the
underlying array_push function. We still need a way to declare this
operation as a function.
>> array_pop(anyarray) returns anyelement
> That appears to mean that you return somearray[0] and alter the array as a
> side effect. How do you plan to do that?
Yeah, I wasn't thinking very clearly there...
>> array_subscript(anyarray, int) yields anyelement
> That's just somearray[x], no?
Yes. But the fact that we can now represent the semantics of [] as a
function seems to me to indicate that we're on the right track in terms
of generalizing the capabilities of functions.
regards, tom lane