Stack Element Lists

AutoCAD AutoLISP & Visual LISP

 
Stack Element Lists
 
 
 

A stack element is an individual record or line-item history within a trace stack. There are five kinds of elements that may appear within a stack:

  • Function call frames show one individual function invocation. Each function call frame appears in the following format:

    level (function-name {argument1}...)

    Arguments within this listing are displayed not by their local parameter name, but by the values that were actually passed to the function.

  • Keyword frames are displayed at the very top and bottom of a trace stack. They are displayed in the following form:

    level :keyword - {optional-data}

    The keyword indicates the type of the frame. The optional-data displays additional information relating to the state of the program.

  • Top forms indicate an action that was initiated by typing an expression at the top-level Console window, or from the invocation of a function that was triggered during the loading of a file or selection within a VLISP editor window.
  • Lambda forms are placed within a stack whenever a lambda function is encountered within your program.
  • Special forms display the invocation of the foreach and repeat functions. The arguments for these functions are not displayed. They appear as:

    level (function-form ...)

Function call frames and keyword frames are discussed in more detail in the following sections. These sections use the following code to demonstrate the trace stack. If you wish, you can copy this code into a VLISP editor window, set a breakpoint as indicated in the code comments, and run this sample:

(defun stack-tracing (indexVal maxVal)
   (princ "At the top of the stack-tracing function, indexVal = ")
   (princ indexVal)
   (if (< indexVal maxVal)
      (stack-tracing (1+ indexVal) maxVal)
      (princ "Reached the maximum depth.") ; place a breakpoint
                                          ; at the beginning of
                                          ; this line
   )
)
(defun c:trace-10-deep ()
   (terpri)
   (stack-tracing 1 10)
)