1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Terminology question: nested vs. recursive

Discussion in 'Support' started by dcantor, Jan 30, 2009.

  1. dcantor

    Joined:
    May 29, 2008
    Messages:
    507
    Likes Received:
    3
    This question is inspired by a recent note by Samintz, where Scott said,
    I had never used that before, and prior to seeing this description, I had thought that nested variable expansion meant expanding something like
    Code:
    set x=4
    set x4=four
    echo %[x%x]
    
    I found that with SETDOS /X-4 and with SETDOS /X4 (or /X0) the result of the above code fragment is "four", and SETDOS /X-4 does not disable this. This is what I thought nested variables were.

    Well it turns out that what SETDOS /X-4 affects is the expansion of a variable whose resultant string contains a % sign. I would have called that recursive or iterative variable expansion.

    I would like to see the distinction between these two different cases made clear in the help, especially in the SETDOS /X help, and perhaps some index entry in the help file to find the section on the %[x%x] form. (I'm sure it's there, but I couldn't find an index entry to find it.)

    (I was thinking of asking for a way to disable the %[x%x] form in SETDOS /X, but I can't think of what good that would do anybody.)

    Compare nested variable expansion to nested function evaluation.

    Nested function: %@eval[3 + %@date[1980-1-1]] Yes.
    Nested variable? %[x%x] No.
     

Share This Page