1. When we have a loop and a second loop inside it, how do you refer to the outer loop and the inner loop?

    Which one would you call the "embedded" loop, and which one the "nested" loop?

    Which one would you call the "embedding" loop, and which one the "nesting" loop?

    Is it correct to say that the outer loop nests the inner loop, and the inner loop is embedded in the outer loop?

  2. Another example from a book in database

    A nested query is a query that has another query embedded within it.

    The embedded query can be a nested query itself; thus queries that have very deeply nested structures are possible.

    I guess the author means the outer query by the "nested" query, and the inner query the "embedded" query. However, I feel both the "nested" query and the "embedded" query should refer to the inner query wrt the outer query.

    why not call the outer query the "nesting" query, and the inner query both the "nested" query and the "embedded" query?


  • There are few technical terms programmers can really agree on. You'll find different definitions in every shop.
    – corsiKa
    Oct 27 '14 at 19:22
  • Outer loop, inner loop, nested loop, nested query, embedded object are all frequently used. But neither embedding nor nesting is a term-of-art that means 'that which embeds|nests something inside itself'. Oct 28 '14 at 15:58

The main difference is that nested is much more likely to be used when one X is contained within another, "higher-level" X. Whereas an embedded X simply means an X which is within something - not necessarily another X (and in fact probably not, since if it was, we'd probably have used nested).

Thus in programming contexts we often refer to nested loops/queries (within higher-level loops/queries). But a gif graphic image within an email (as opposed to an email attachment) is an embedded image.

I'm sure you'd be understood if you referred to the nesting loop/query, but outer is the standard term (or sometimes, containing).


As a AmE programmer, I use the words "nested" and "embedded" as you describe in #2: "Nested functions contain embedded loops."

Using the "ed" is the correct adjective form instead of "nesting". An example would be "Please use the nested function getIt()" rather than saying "Use the nesting function getIt()". Another example would be "You will probably need to write a nested loop here to implement that algorithm." Otherwise it sounds a bit odd, like a bird "nesting" on a tree branch.

There is also the connotation that the function is "complete", so, the function is "already" nested, not just sitting there "nesting".

http://en.wikipedia.org/wiki/Nesting_%28computing%29 http://en.wikipedia.org/wiki/Nested_function


why not call the outer query the "nesting" query, and the inner query both the "nested" query and the "embedded" query?

The reason why the outer loop (mutatis mutandis, outer query) is not called a nesting loop is that the verb nest is intransitive. It does not mean "to enclose in a nest" but "to be in a nest".

The reason why the container is not called the embedding object is because "embed" is a transitive verb that means "to put something in something else". The container does not put the object inside itself. Rather, some other thing puts the object in the container.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .