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?
Is define implementation dependent in R7RS?
229 Views Asked by J. Mini At
2
There are 2 best solutions below
2
On
The most common interpretation of define is to replace it with letrec*.
But this problem has indeed many possible interpretations and the language does not impose any. Any interpretation is valid from the viewpoint of the language.
You seem to be reading something into the answer you linked which isn’t there.
definehas always been well defined, just as well-defined asletis. Most people choose to usedefineonly 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, likeletis, if you use it inside and at the top of an ‘internal’ body, such as inside a procedure or aletor similar. Multipledefines in such a context are technically equivalent toletrec*, as another answer noted.