| libxexpr Reference Manual |
|---|
The <define> function creates a new function in the environment in which it is invoked. This is different than the <set> function which will modify the definition of an existing function if such exists. Only if no such function is defined in any of the active environments will <set> create a new function (and then in the outermost, or global, environment).
We know from the examples in the specification (eg., in section 45) that <subtract> changes the definition of its first argument in at least the grandfather environment. It makes sense that <set> should do the same. When we come to <define>, however, we know from section 3 that it is equivalent to an attribute on the parent element and so it makes sense that it should create a variable in the parent environment.