Re: patch: to_string, to_array functions - Mailing list pgsql-hackers
From | Pavel Stehule |
---|---|
Subject | Re: patch: to_string, to_array functions |
Date | |
Msg-id | AANLkTilnHfCVK8hzryW_v0tvo3_DUgrY8f-uI8z9xyvj@mail.gmail.com Whole thread Raw |
In response to | Re: patch: to_string, to_array functions (Robert Haas <robertmhaas@gmail.com>) |
Responses |
Re: patch: to_string, to_array functions
|
List | pgsql-hackers |
2010/7/21 Robert Haas <robertmhaas@gmail.com>: > On Wed, Jul 21, 2010 at 12:08 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote: >>>> I am thinking so we have to do decision about string_to_array and >>>> array_to_string deprecation first. If these function will be >>>> deprecated, then we can use a similar names (and probably we should to >>>> use a similar names) - so text_to_array or array_to_string can be >>>> acceptable. If not, then this discus is needless - then to_string and >>>> to_array have to be maximally in contrib - stringfunc is good idea - >>>> and maybe we don't need thinking about new names. >>> >>> Well, -1 from me for deprecating string_to_array and array_to_string. >>> >>> I am not in favor of the names to_string and to_array even if we put >>> them in contrib, though. The problem with string_to_array and >>> array_to_string is that they aren't descriptive enough, and >>> to_string/to_array is even less so. >> >> I am not a English native speaker, so I have a different feeling. >> These functions do array_serialisation and array_deseralisation, but >> this names are too long. I have not idea about better names - it is >> descriptive well (for me) text->array, array->text - and these names >> shows very cleanly symmetry between functions. I have to repeat - it >> is very clean for not native speaker. > > Well, the problem is that array_to_string(), for example, tells you > that an array is being converted to a string, but not how. And > to_string() tells you that you're getting a string, but it doesn't > tell you either what you're getting it from or how you're getting it. > We already have a function to_char() which can be used to format a > whole bunch of different types as strings; I can't see adding a new > function with almost the same name that does something completely > different. > > array_split() and array_join(), following Perl? array_implode() and > array_explode(), along the lines suggested by Brendan? I have a problem with array_split - because there string is split. I looked on net - and languages usually uses a "split" or "join". split is method of str class in Java. So when I am following Perl, I feel better with just only "split" and "join", but "join" is keyword :( - step back, maybe string_split X array_join ? select string_split('1,2,3,4',','); select array_join(array[1,2,3,4],','); so my preferences: 1. split, join - I checked - we are able to create "join" function 2. split, array_join - when only "join" can be a problem 3. string_split, array_join - there are not clean symmetry, but it respect wide used a semantics - string.split, array.join 4. explode, implode 5. array_explode, array_implode -- I cannot to like array_split - it is contradiction for me. Pavel p.s. It is typical use case for packages - with it, we can have the functions string.split() and array.join() > > -- > Robert Haas > EnterpriseDB: http://www.enterprisedb.com > The Enterprise Postgres Company >
pgsql-hackers by date: