Last modified: 2011-03-13 18:04:28 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T20199, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 18199 - Provide the ternary operator (condition ? then : else)
Provide the ternary operator (condition ? then : else)
Status: RESOLVED WONTFIX
Product: MediaWiki extensions
Classification: Unclassified
ParserFunctions (Other open bugs)
unspecified
All All
: Lowest enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, patch-need-review
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-03-27 15:40 UTC by René Kijewski
Modified: 2011-03-13 18:04 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Includes ?: and sgn (3.91 KB, patch)
2009-03-27 15:59 UTC, René Kijewski
Details

Description René Kijewski 2009-03-27 15:40:37 UTC
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.
Comment 1 René Kijewski 2009-03-27 15:59:43 UTC
Created attachment 5966 [details]
Includes ?: and sgn

I forgot to upload the diff ... please read the first post.
Comment 2 Chad H. 2010-01-08 15:00:33 UTC
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.
Comment 3 Max Semenik 2010-01-08 15:06:36 UTC
Amen. Additionally, this operator would have been particulary grave offender against readability and clarity for non-programmers.
Comment 4 Platonides 2010-01-08 15:12:40 UTC
You already have #if, #ifeq wich take if and else "branches".

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links