Re: What happened to the is_ family of functions
proposal?
От | Darren Duncan |
---|---|
Тема | Re: What happened to the is_ |
Дата | |
Msg-id | 4C9DAD2C.7070404@darrenduncan.net обсуждение исходный текст |
Ответ на |
Re: What happened to the is_ |
Список | pgsql-hackers |
Craig Ringer wrote: > On 25/09/2010 11:51 AM, Darren Duncan wrote: >> There should just be a single syntax that works for all types, in the >> general case, for testing whether a value is a member of that type, or >> alternately whether a value can be cast to a particular type. <snip> >> Pg already gets it right in this regard by having a single general >> syntax for type casting, the "<value>::<type-name>" and value membership >> of a type should be likewise. > > or the standard: > > CAST(value AS typename) Indeed. The exact syntax doesn't matter to me but the point is that the type name is its own lexical element, conceptually a function argument, rather than being a substring of another one. >> Maybe to test if a value can be cast as a type, you can continue the :: >> mnemonic, say adding a "?" for yes and a "!" for no. >> >> For example, "<value>?::<type-name>" tests if the value can be cast as >> the type and "<value>!::<type-name>" or "not <value>?::<type-name>" >> tests the opposite. An expression like this results in a boolean. > > Personal opinion here: Blech, if I wanted to use Perl6 I'd do so ;-) I see that someone has been paying attention. Yes, the idea of using ? or ! to derive a boolean expression from some other expression did indeed come from Perl 6. The ? means "is so", ! means "is not". A very useful mnemonic in general. > Good shorthand, I guess, but a CAST syntax extension or alternate CAST > version would be a bonus for readability. Well, sure. But something consistent with cast syntax that Pg provides. -- Darren Duncan
В списке pgsql-hackers по дате отправления: