Page MenuHomePhabricator

Provide the ternary operator (condition ? then : else)
Closed, DeclinedPublic

Description

Author: rene.kijewski

Description:
It would be nice if there would be a ternary operator ([[?:]]) for #expr like the most programming languages have.
I wrote a little patch that would provide this operator. And since it would be needful, I inserted a sign function (e.g. sgn -2 == -1), too.
There are two new messages ("unserved_question_mark" and "missing_question_mark") that need to be added in the i18n.


Version: unspecified
Severity: enhancement

Details

Reference
bz18199

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 10:33 PM
bzimport added a project: ParserFunctions.
bzimport set Reference to bz18199.
bzimport added a subscriber: Unknown Object (MLST).

rene.kijewski wrote:

Includes ?: and sgn

I forgot to upload the diff ... please read the first post.

Attached:

Suggest WONTFIX. We've turned down proposals to expand programmatic features into ParserFunctions before, and I think this falls under that.

Could possibly be (if it isn't already) implemented in the Lua extension, and would probably be included in the "one day eventual rewrite of template syntax" we toss around from time to time.

Amen. Additionally, this operator would have been particulary grave offender against readability and clarity for non-programmers.

You already have #if, #ifeq wich take if and else "branches".