Jump to content

英文维基 | 中文维基 | 日文维基 | 草榴社区

Template talk:Qif

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Making parameter "else" optional?

[edit]

The template code for this template looks dammed (sexy) simple! That's pure KISS (Keep It Simple and Stupid). I like that. But how much more complicated would it be to just allow the parameter else to be optional? (I think this is the most important optional use case.) – Ligulem | Talk 20:25, 27 November 2005 (UTC)[reply]

  • I think that would be worth it. If parameter else would be optional we could use qif directly in {{web reference}}. By the way, if this would be a help, I think it would be ok to state that the behaviour of qif is not defined when parameters test or then are missing. "Not defined" means that qif would be allowed to behave totally strange. As an example, the term "undefined behaviour" is also used in language definitions like C++:
"Behavior, such as might arise upon use of an erroneous program construct or erroneous data, for which this International Standard imposes no requirements. Undefined behavior may also be expected when this International Standard omits the description of any explicit definition of behavior. [Note: permissible undefined behavior ranges from ignoring the situation completely with unpredictable results, to behaving during translation or program execution in a documented manner characteristic of the environment (with or without the issuance of a diagnostic message), to terminating a translation or execution (with the issuance of a diagnostic message). Many erroneous program constructs do not engender undefined behavior; they are required to be diagnosed." (Chapter 1.3.12 "Undefined behaviour", Programming languages — C++: INTERNATIONAL STANDARD, ISO/IEC 14882, First edition, 1998-09-01).

Then/Else same summary

[edit]

The summary says both "then" and "else" need "code if true or empty". Some clarification is needed. (SEWilco 03:47, 30 November 2005 (UTC))[reply]

You're right. I've updated the "Documentation" trying to clarify. Thanks! – Ligulem | Talk 08:50, 30 November 2005 (UTC)[reply]

Logic templates on WP:AUM

[edit]

See the discussion on Wikipedia_talk:Avoid_using_meta-templates#Logic_templates. – Ligulem | Talk 15:49, 9 December 2005 (UTC)[reply]

Protecting

[edit]

It has been proposed to protect qif against changes [1]. Would you agree? I do. (I can't do that, I'm not an admin, maybe Phil)? I would propose to wait on AzaToth's ok and then protect. – Ligulem | Talk 09:13, 13 December 2005 (UTC)[reply]

  • I could protect these templates, but we need a good reason from policy to do so. Also remember, you'll have to either ask an admin or become an admin to make an alteration! A while back, {{if}} was vandalised: it had a really horrible effect. --Gareth Hughes 00:29, 16 December 2005 (UTC)[reply]
  • Why not protect just qif as a first step (I think this one is really stable), and see how we can live with that. Yes, I know that we need an admin. I think this is not that of a problem. We can ask. It's not that bad if someone keeps an eye on what happens. – Ligulem | Talk 09:19, 16 December 2005 (UTC)[reply]

Undefined MediaWiki behavior?

[edit]

Please identify where the functionalty being exploited here and by the component parts being used to implement this is documented in the wikitext markup specification - particularly in the master specifications in the minds of Brion and Tim. Will it, for example, continue to work if a C parser or partial parser is used for efficiency and all supported features are kept? Jamesday 20:55, 17 December 2005 (UTC)[reply]

Many thanks for having a look at this here. Re "the component parts being used to implement this": qif does not use any other template. It's atomic. The mechanics behind the implementation are described at m:Help:Parameter default.
"Undefined behaviour" means that users of qif should not expect any specific behavior if they use qif in stupid ways (ways that fall under "undefined bahviour" as per the documentation above). Maybe it would be better not to use that term at all, as qif is now stable and we are certainly able to specify how qif exactly behaves on all call patterns. This has been done for the qif eqivalent on meta (m:Template talk:If). But I would recommend not to specify all stupid call patterns (for example {{Qif|test=x||else=y}}) to keep users off from relying on specific behaviour in stupid cases and to make the implementation simpler. That's the idea behind "undefined behaviour".
I think we can expect that qif will be implemented in the Wikimedia software in the future. So qif should be seen as temporary solution as this is clearly not efficient for the servers. – Ligulem | Talk 22:34, 17 December 2005 (UTC)[reply]
"Undefined behavior" in this context means "exploiting the undocumented behavior of a specific implementation of MediaWiki which could change at any moment without warning or fault and break all existing uses of the behavior". My intent was to question whether ANY use of qif would work tomorrow, whether it's as described on this page or not. The qif documentation is irrelevant. I'm talking about MediaWiki, a change to which could break qif without notice. You can document a bug or accidental feature of MediaWiki all you want but it could still go away tomorrow if it's not a deliberately supported feature. I've changed the section title to more unambiguously say this.
Unless it is relying only on documented and supported MediaWiki features, qif can never be "stable". Jamesday 20:19, 18 December 2005 (UTC)[reply]
Could you give a pointer to the document "wikitext markup specification" (internal link, URL)? – Ligulem | Talk 22:54, 17 December 2005 (UTC)[reply]
See mediawiki.org and the brains of Brion and Tim Starling. Note that changing what is at mediawiki.org without changing those brains would just result in inaccurate documentation. Jamesday 20:19, 18 December 2005 (UTC)[reply]
I went to http://mediawiki.org and eventually ended up at the meta page referred to above: m:Help:Parameter default. Is there anywhere else I should be looking? Phil | Talk 15:47, 19 December 2005 (UTC)[reply]
Hehe, it's rather funny, that page was written after this template and it's documentation was written :) AzaToth 15:56, 19 December 2005 (UTC)[reply]
qif depends on the patch bugzilla:364 --Ligulem 19:49, 23 January 2006 (UTC)[reply]
{{tlx|Qif|test=x|else=y}} can make sense, it may save using a "not" template.--Patrick 23:47, 17 December 2005 (UTC)[reply]
You're right. Maybe I should better refrain from using the word "stupid". Thanks! – Ligulem | Talk 00:04, 18 December 2005 (UTC)[reply]

Code

[edit]

Carl (aka AzaToth) has started work for implementing logic in code. See m:user:AzaToth/Logic (talk). Many thanks to Carl! – Ligulem | Talk 00:12, 18 December 2005 (UTC)[reply]

Status check

[edit]

How is the move to deprecate this template going? Phil Sandifer 20:41, 28 December 2005 (UTC)[reply]

According to the what links here of qif – namespace main of this wiki is free of qif (no page in main depends on qif). Lots of templates that now use #if: have been added to Category:Templates using ParserFunctions. --Ligulem 21:58, 26 April 2006 (UTC)[reply]

Parameter default

[edit]

See User talk:Ævar Arnfjörð Bjarmason#Regarding template default parameters and nesting. I assume this would break qif (see als bugzilla:364). Ligulem 08:35, 29 December 2005 (UTC)[reply]

tfd

[edit]
  • Despite this please note that using qif is in violation of WP:AUM and qif is thus now phased out in an orderly manner. I hereby call all participants to help remove uses of qif in an orderly non-disruptive manner. --Ligulem 22:09, 14 January 2006 (UTC)[reply]
  • You are working for weeks now under that "quickly" banner. It would actually happen much faster if you would cooperate with the people around each template instead of constantly wasting your and the Wikipedians time in warring for your preferred replacements. People are actually implementing WP:AUM and it would be wise to help them and instruct them how to do it in a friendly and calm manner (as you finally did on template:book reference by providing a fully functional WP:AUM compliant replacement – something which you would have been able to do much earlier instead of threatening people with the needless partial destruction or even removal of template calls). Please leave the crusade mode now. It's no longer needed. WP:AUM stands and is implemented by Wikipedians. --Ligulem 12:11, 15 January 2006 (UTC)[reply]
See also Brion VIBBER's newest statement on WP:AUM. It's no longer a policy. --Ligulem 16:54, 21 January 2006 (UTC)[reply]
Brions comment has been moved to Wikipedia talk:Avoid using meta-templates#Brion's comment. --Ligulem 18:22, 21 January 2006 (UTC)[reply]

CSS hiddenStructure

[edit]

See also Wikipedia:HiddenStructure for an alternate hack to suppress text on the client side (has accessibility problems, see respective talk). --Ligulem 16:26, 27 January 2006 (UTC)[reply]

Server load?

[edit]

I was told that qif is heavy on the servers and its use is not recommended. Is that true? Thanks. — AdiJapan  10:23, 28 February 2006 (UTC)[reply]

It depends on who you ask. See the whole story on WT:AUM (warning: long). See also user talk:Brion VIBBER#The future of qif. Brion wrote to me in PM that "qif is an ugly piece of crap" (But he did not say why). But it's the best piece of crap we have at the moment (the alternatives like weeble code or Wikipedia:hiddenStructure do have their own drawbacks). Best thing would be to have a conditonal function in Media-Wiki Software, as Brion suggests. I use qif until then. --Ligulem 10:43, 28 February 2006 (UTC)[reply]
As Ligulem says, see WP:AUM (and the talk page WT:AUM). If you absolutely must have conditionals in templates though, this is the best option available right now. —Locke Coletc 10:00, 2 March 2006 (UTC)[reply]
Okay guys, thanks for explaining. For now I managed to remove the conditional in a template by making two separate templates, although it's not as easy to use as a flexible one. I look forward to having conditionals, booleans and some mathematical functions implemented in the software. Cheers. — AdiJapan  14:51, 2 March 2006 (UTC)[reply]

AUM not policy

[edit]

AUM is not policy; many of the assertions it makes about server load are specious and have been contested by a broad range of Wikipedians. Suggest we not judge {qif} by this "standard". John Reid 00:29, 13 March 2006 (UTC)[reply]

Agreed. —Locke Coletc 00:45, 13 March 2006 (UTC)[reply]
Please note the CTO Brion Vibber explicitly asked not to care about server load at a policy level if that load is required to improve this Encyclopedia and editors agree that a solution is less ugly than anything else. qif serves quite well as a stop gap measure and it is not as brittle as some might fear. But it is not the best solution for all times. We should get a Mediawiki built-in replacement rather sooner than later. qif is definitely better than WP:HIDE. It is ridiculous how some people invest their time to hinder things like a simple hiding function to find their way into the Mediawiki software. Templates and especially a conditional function help building a better Encyclopedia. Sure we can do everything without templates if we are forced to. But we also could write all pages in html ourselves. But we don't. qif uses current straightforward functionality of the Mediawiki software. It doesn't matter that the inventors of the underlying Mediawiki functions did not expect that those features can be used like done in qif. It is not a hack, despite the lack of documentation for the used features. It uses template inclusion with parameters and parameter default. Sure, if the devs remove that, it will break. But it would be better they announce that in advance, as removing existing functionality from a life system should be coordinated with its use. --Ligulem 08:21, 13 March 2006 (UTC)[reply]
I suspect it will play out like this: templates using broken methods to hide data (like WP:HIDE) will get temporarily ported to qif. When conditionals are added to the software, we'll use Special:Whatlinkshere to find and replace all uses of qif. Then, assuming there's still a reason to "break" qif, the developers will do whatever it is they have planned to break it (but at this point it should be irrelevant because we won't need qif anymore). Anyways, well said and agreed. =) —Locke Coletc 08:32, 13 March 2006 (UTC)[reply]

Doesn't work when substed?

[edit]

Is that correct? {{subst:qif|test=foo|then=bar|else=baz}} produces bar, and {{subst:qif|test=|then=bar|else=baz}} produces baz. That seems like working to me. —Simetrical (talk • contribs) 04:16, 27 March 2006 (UTC)[reply]

The resultant wikicode in the first case (namely {{{elsefoo|{{{testfoo|bar}}}}}}) does look a bit odd, granted. Anyway, correct me if I'm wrong, wasn't this whole problem with substing fixed with a software update that allowed substed parameters to be handled correctly? —Simetrical (talk • contribs) 04:17, 27 March 2006 (UTC)[reply]

[Wikitech-l] Mathematical expressions and conditional constructs, now implemented

[edit]

(Wikitech-l) Mathematical expressions and conditional constructs, now implemented. --Ligulem 15:44, 5 April 2006 (UTC)[reply]

Definite improvement over the current situation, but I made some suggestions on the meta talk page linked in there. Primary concern is that it uses '|' and thus would presumably have the same difficulties with table markup that 'qif' does. --CBDunkerson 16:13, 5 April 2006 (UTC)[reply]
In short, {{Qif|test=A|then=B|else=C}} can be replaced with {{#if:A|B|C}}. In fact, the wiki code of Template:Qif can itself be replaced with
{{#if:{{{test|}}}|{{{then|}}}|{{{else|}}}}}
I suggest doing that. Then Qif can very easily be converted to the new syntax: just replace {{Qif|whatever}} with {{subst:qif|whatever}} and save! User:dbenbenn 22:55, 18 April 2006 (UTC)[reply]
No please no changes to qif. Replace the calls to qif, this is easy. Don't change qif. --Ligulem 23:00, 18 April 2006 (UTC)[reply]
Why not? Changing Qif makes it easy to replace, by simply substing. I guess you're worried about the servers having trouble updating this high-use template? Oh well. User:dbenbenn 23:18, 18 April 2006 (UTC)[reply]
I have other reasons too. But I'm tired to elaborate in detail. Trust me. Don't change qif. --Ligulem 23:30, 18 April 2006 (UTC)[reply]
See WP:AUM. While this policy was rejected, the discussion of it covers the reasons why we should avoid using templates within templates. The main purpose of introducing #if was to allow us to eliminate {{qif}}, so that templates can have conditional functionality without using a template within another template. (I haven't looked into it, but I gather {{#if:}} doesn't count as a "template" for this purpose.--Srleffler 22:36, 19 April 2006 (UTC)[reply]
See also category:Templates using ParserFunctions --Ligulem 11:05, 17 April 2006 (UTC)[reply]
Would changing qif's code cause problems with qif itself, or would the mere server load cause too many problems? I definitely agree with the server issue, but if that could be overcome, then changing the code would work well, in my opinion. I doubt that the server issue could be fixed, however. Would adding a "depricated" notice to the < noinclude > cause any server issues? - it would help users to see that it has been replaced. -Xol 20:08, 23 April 2006 (UTC)[reply]
Please don't touch qif. There is no need to change anything. We don't need a deprecate notice in noincludes either. May I remind you that qif is still in active use? And implementing qif by using #if is just a very bad idea. We gain nothing by this. But we loose an option in case there is a problem with ParserFunctions. qif works as it is. Don't fix it if it ain't broken. --Ligulem 20:42, 23 April 2006 (UTC)[reply]
I'm interested in keeping it around for historical purposes. Leave it protected, blank it when we've orphaned it, and let people see what we used to use (for the curious). And as Ligulem says, let's make sure #if isn't taken away for some reason. —Locke Coletc 21:13, 23 April 2006 (UTC)[reply]
Yes, we should keep it in case, and for historical purposes. It's not a big deal to leave it the same anyways, as it appears that most usages have been changed to #if. -Xol 21:15, 26 April 2006 (UTC)[reply]

help with this template

[edit]

I need some help with qif. I'm trying to set it up for a personal template so if I put something in parameter {{{1}}}, it shows up, but if I don't, it doesn't. I tried reading the examples, but they didn't really explain. please help.--Ac1983fan (talkcontribs) 20:33, 17 April 2006 (UTC)[reply]

Hi. qif does not use "numbered" (or "unnamed") template parameters. qif uses only "named" parameters ("test", "then" and "else"). Could you explain a bit more what you want to do? May I ask you to post on my talk page, (if you like and need more help)? I'll promise to help you building the template you are up to. --Ligulem 20:46, 17 April 2006 (UTC)[reply]
Try this: {{{1|}}}. The | after 1 causes it to default as nothing. For example: {{{1|OneIsNotDefined}}} will show OneIsNotDefined if there isn't any {{{1}}}. {{{1|}}} will default blank if there is nothing in {{{1}}}. -Xol 20:01, 23 April 2006 (UTC)[reply]

Please don't delete this template until MW 1.7 is released

[edit]

I just set up my own MediaWiki wiki and wanted to use parserfunctions. Unfortunately no release of MW currently officially available has parserfunctions, so I am having to use qif on my wiki for the time being. If this template were deleted, I would've had nowhere to copy the implementation from. THanks. Pcb21 Pete 11:12, 8 May 2006 (UTC)[reply]

Currently the consensus is to retain this indefinitely for historical purposes. For your wiki you might want to rename it to 'Template:if:' and replace the named parameters with numbered ones for the time being. The '#' is an illegal character for a page name and thus can't be used in advance, but those changes would simplify eventual conversion from the template to the ParserFunction. --CBDunkerson 11:52, 8 May 2006 (UTC)[reply]
I strongly recommend not to use numbered params, for various reasons (one is potential problems if a param contains an "=" sign). Use it as it is (beside the name, which is irrelevant, but qif is easy to find in text). See also m:Help:Parameter default, [2]. --Ligulem 12:03, 8 May 2006 (UTC)[reply]
MediaWiki development is such that what's in SVN is generally stable. As I understand it, the various releases that are made are generally done on a schedule (unless a bug creeps into one, of course). Also, if you use SVN you can check out the code once, then update fairly easily by executing "svn up" from the directory containing your installation. —Locke Coletc 13:08, 8 May 2006 (UTC)[reply]
Yes I think I will do that - best to stay in line with the Wikipedia version which is bound to be the best supported, even if not "official". However my original points stands - the regular joe MediaWiki installer is told to install 1.6.5 on all the various install/help pages and how is he to know better?
To the others, yes I called it "if" rather than "qif", but have stuck with named parameters. Pcb21 Pete 14:14, 8 May 2006 (UTC)[reply]
Not all of us have PHP5 access, either. — ceejayoz talk 03:41, 1 June 2006 (UTC)[reply]

Template includes category that's being deleted

[edit]

Please delete [[Category:Pages containing deprecated templates]] in the first line of the template and Adds pages to [[:Category:Pages containing deprecated templates]] near the end of the template. That category is being deleted pursuant to Wikipedia:Categories for deletion/Log/2006 November 29. Thanks.DomBot talk ; Chidom talk, owner/operator. 06:12, 11 December 2006 (UTC)[reply]

Done. EVula // talk // // 23:41, 11 December 2006 (UTC)[reply]
A thousand thanks. Have good days.DomBot talk ; Chidom talk, owner/operator. 07:50, 12 December 2006 (UTC)[reply]

Last occurance of qif?

[edit]

Substed out [3] here. A historic moment? Rich Farmbrough, 13:05, 1 October 2009 (UTC).[reply]