In a lexically scoped system, X is bound to LEXICAL and then F is bound to a function returning X in the lexical context where X=LEXICAL. Then (another) X is bound to DYNAMIC and finally F is applied. The value that F returns is the value that X had in the lexical/spatial context of the definition of F.
In a dynamically scoped system, F is bound to a function that returns the value that X is currently bound to. Before the function is defined, X is bound to LEXICAL and later the same X is bound to a different value, DYNAMIC. The value returned by F is the value that X has at the time of the function application.
To try this in a dynamically scoped LISP, use may have to use
In a dynamically scoped system, F is bound to a function that returns the value that X is currently bound to. Before the function is defined, X is bound to LEXICAL and later the same X is bound to a different value, DYNAMIC. The value returned by F is the value that X has at the time of the function application.
To try this in a dynamically scoped LISP, use may have to use
instead of (f) in the last line of the example.