Is define implementation dependent in R7RS?

229 Views Asked by At

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?

2

There are 2 best solutions below

3
Daphne Preston-Kendal On BEST ANSWER

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 defines in such a context are technically equivalent to letrec*, as another answer noted.

2
alinsoar 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.