Шаблон:Convert/nesting

Мавод аз Википедиа — донишномаи озод
Discussed at subpage: Template_talk:Convert/nesting.

The nesting limit for the measurement converter Template:Convert depends on the nesting-levels of each page which is using Convert. For most articles or infoboxes, there is no restriction for using Convert, anywhere on a page. However, for nested infoboxes, there has been a limit of using Convert down to a 2-nested if-expression (nested as, at most, if-else-if-then-convert). Many of the subtemplates are invoked when Convert rounds the resulting value (see below: #Nested subtemplates for rounding).

Example of Convert-nesting limits[вироиши манбаъ]

Nested infoboxes are an example of reaching Convert nest-limits (in the MediaWiki markup language). In {{Infobox mountain}}, during March 2010 (when markup expressions were limited to 40-level nesting), the use of typical "elevation={{convert|97|m|ft}}" caused a problem inside a 3-nested if-expression, where the 3rd if-clause generated parser-errors. However, when the precision parameter "|0" was appended to the end (as "{{convert|97|m|ft|0}}"), then the 3-nested if-expression worked ok, because specifying precision "0" bypassed 3 of the nested Convert subtemplates, using only 16 rather than the typical 19 nested-subtemplates to compute a conversion (in March 2010). Eventually, the infobox was changed to handle the value of parameter "elevation" with a 1-level if-expression (as only if-then-convert), rather than as nested under 2 else-clauses.

Common nested subtemplates[вироиши манбаъ]

Most conversions using Template:Convert share the same multiple nested subtemplates to determine the precision/rounding of the output amount(s). For example:

If the logic of the nested subtemplates could be simplified, in terms of the levels of stacked if-expressions invoking other subtemplates, then the total nest-levels could be reduced for a typical conversion.

Nested subtemplates for rounding[вироиши манбаъ]

As of March 2010, the design of Convert has treated the input numbers as potentially huge, astronomical amounts, and therefore, has had complex, multi-nested rounding routines to determine the format as scientific notation, if needed, for the result. The typical display subtemplate {{Convert/LoffAoffSoff}} has invoked {{Convert/round}} to invoke the large-scale rounding routine {{rnd}} to handle large numbers, allowing possible scientific notation. Inside {{rnd}}, then another 4 subtemplates are usually invoked, or 8 subtemplates for numbers above a million. The total of subtemplates used to auto-round the results, when using Convert, includes:

If, instead of using {{rnd}}, then a different rounding routine were used, then 4-to-8 nested subtemplates could be avoided (for each conversion). However, the rounding would still need to handle very large numbers, such as for calculations in astrophysics and celestial mechanics.

Also see: Template_talk:Convert - for general discussion.
Also see: Template_talk:Convert/density - about density conversions.
Also see: Template_talk:Convert/updates - for requesting protected updates.