Nested QuotesWe've already covered
quotes in Exercise 3 (see page 3 of this topic), but let's take a look at
nested quotes. These are typically quotes of other people who also quoted other people.
For example, if I were quoting Al who had quoted Bill who had quoted Carl, it might look like this:
Here's my quote of Al which includes the nested quotes of Bill and Carl:
Al wrote:Hi Bob,
I just heard from Bill that he and Carl might be flying this weekend. Here's what I got from Bill:
Bill wrote:Hi Al,
Carl and I are thinking of flying Saturday or Sunday. Are you up for it? Here are the details from Carl:
Carl wrote:Hi Bill,
The forecast looks good this weekend. What do you think about a bunch of us heading out around noon on either day?
Your friend in flight,
Carl
Carl has a good track record of picking good days, so I think I'm in.
If Bill can go, then I'm leaning toward joining them. How about you?
Al
As you can see from this example, the use of nested quotes is very helpful to show who said what to who. This is similar to what happens in a long chain of email messages where each person had quoted the message they got which included other messages as well.
The concept of one thing being
completely within another thing is often called "nesting". To help make this clear, here's an animation of properly nested dolls:
- Nested_Dolls_500.gif (1.67 MiB) Viewed 1060 times
You'll notice that each newly exposed doll was
completely inside of the previous doll. It would be difficult to imagine one of the dolls being physically both inside and outside of any of the other dolls at the same time ... without breaking them. So proper nesting is fairly natural in the real world. But we have to remember to do it in the computer programming world ... or unexpected things can happen.
We also find nesting in mathematics when using paired symbols to group the parts of an expression into different levels. Here's a simple example:
42 × { [ x × 3 ] + [ (2 + y) ÷ (7 - z) ] }
You'll notice that each pair of grouping symbols - { }, [ ], ( ) - are
properly nested in that example. Here's an example where the symbols are
NOT properly nested:
You'll notice in that example that neither the "(...)" grouping nor the "[...]" grouping are completely within the other. This is
improper nesting, and you can see that it's much easier to do in the "computer world" than to improperly nest dolls in the physical world. So we have to pay attention to keep from doing it by accident.
Another example is in BBCode itself. We should generally properly nest all of our pairs of tags so that one pair is
completely inside another pair:
[b] [u] Hello! [/u] [/b] <--- Properly Nested
[b] [u] Hello! [/b] [/u] <--- Not Properly Nested
You'll notice in the first (properly nested) example, the underline codes ([u] and [/u]) are completely inside the bold codes ([b] and [/b]). In most computer "languages" (including BBCode and HTML) we want everything to be properly nested so the computer knows what we want.
Now let's probe the depths of nested quotes on this forum. Here are 10 quotes:
As you can see, the software cycles through 3 colors and then gets stuck. I personally think that's a bug (even with only three colors, they could be recycled), but it's what we have. Here's the BBCode that will produce that series of deeply nested quotes:
[quote="Al"]
[quote="Bill"]
[quote="Carl"]
[quote="Dan"]
[quote="Earl"]
[quote="Frank"]
[quote="Gus"]
[quote="Hal"]
[quote="Irv"]
[quote="Joe"]
Hi!
[/quote]
[/quote]
[/quote]
[/quote]
[/quote]
[/quote]
[/quote]
[/quote]
[/quote]
[/quote]
For clarity, I've indented each pair of matching [quote] and [/quote] tags at the same "nesting" level. So the top [quote] matches the bottom [/quote] and encloses everything in between. That happens at each level to create a properly nested structure.
OK, here's an exercise for anyone who wants to give it a try:
Exercise 6: Post a series of nested quotes about anything related to hang gliding.