I've long since known that define
is scary and should be used with caution unless you know for sure how your implementation handles it. Out of interest, I recently opened up R7RS and read all that I could find about define
and nothing gave me the impression that any of it is implementation dependent. Have I missed something or is define
no longer implementation-dependent in R7RS?
You seem to be reading something into the answer you linked which isn’t there.
define
has always been well defined, just as well-defined as let
is. Most people choose to use define
only at the top level of modules to create top-level bindings, but that’s a stylistic choice — it’s also capable of creating local bindings, like let
is, if you use it inside and at the top of an ‘internal’ body, such as inside a procedure or a let
or similar. Multiple define
s in such a context are technically equivalent to letrec*
, as another answer noted.