Andrew Dunstan <and...@dunslane.net> writes: > On 7/29/21 3:01 AM, Peter Smith wrote: >> I've seen lots of code like this where I may have been tempted to use >> a ternary operator for readability, so I was wondering is there a PG >> convention to avoid such ternary operator assignments, or is it simply >> a personal taste thing, or is there some other reason?
> A simple grep on the sources should disabuse you of any idea that there > is such a convention. The code is littered with examples of the ?: operator. Yeah. I happened not to write it that way here, but if I'd been reviewing someone else's code and they'd done it that way, I'd not have objected. In the case at hand, I'd personally avoid a ternary op for the first assignment because then the line would run over 80 characters, and you'd have to make decisions about where to break it. (We don't have a standardized convention about that, and none of the alternatives look very good to my eye.) Then it seemed to make sense to also write the second step as an "if" not a ternary op. regards, tom lane