Nesting (computing)

From Seo Wiki - Search Engine Optimization and Programming Languages
Jump to navigationJump to search

In computing science and informatics, nesting is the practice of making successive calls to different functions or instructions, one depending on another.

This can be achieved through the use of different levels of parentheses (or braces), or by writing blocks of source code inside other ones (usually with the visual help of indentation). For instance, there can be nested program loops, which means a loop within a loop.[1] Nesting loops can be used, for instance, to print a two-dimensional table or print the average mark of several exams.[2] Brace matching is sometimes used to help keep track on what is going on in a complicated nesting arrangement. Nesting can also be used for information hiding.

In spreadsheets

In a spreadsheet functions can be nested one into another, making complex formulas. The function wizard of the OpenOffice.org Calc application allows to navigate through multiple levels of nesting, letting the user to edit (and possibly correct) each one of them separately. Although it may be somehow surprising, its rival Microsoft Excel doesn't support this interesting feature, which is particularly useful when working with big sheets.

Naturally, to allow the mathematical resolution of these chained (or better: nested) formulas, the inner expressions must be previously evaluated, and this outward direction is essential because the results that the internal functions return are temporarily used as entry data for the external ones.

Due to the potential accumulation of parentheses in only one code line, editing and error detecting (or debugging) can became somehow awkward. That is why modern programming environments -as well as spreadsheet programs- highlight in bold type the pair corresponding to the current editing position. The (automatic) balancing control of the opening and closing parenthesis known as brace match checking.

In programming

In structured programming languages, nesting is related to the enclosing of control structures one into another, usually indicated through different indentation levels within the source code, as it is shown in this simple BASIC function:

function LookupCode(code as string) as integer
dim sLine, path as string
dim return_value as integer

path="C:\Test.csv"
if FileExists(path) then
  open path for input as #1
  do while not EOF(1)
    line input #1, sLine
    if left(sLine, 3)=code then
     'Action(s) to be carried out
    End if
  loop
  close #1
  LookupCode=return_value
end function

In this small and simple example, the conditional block “if... then... end if” is nested inside the “do while... loop” one.

References

See also

es: Anidamiento (informática) it:Annidamento

If you like SEOmastering Site, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...