git @ Cat's Eye Technologies Robin / c920b96
Explain about picking the first semantically equivalent definition. Chris Pressey 5 years ago
2 changed file(s) with 29 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
44 ---------
55
66 * The meaning of multiple `define`s of the same symbol
7 has changed: it is allowed for the purposes of
8 providing multiple equivalent definitions of a symbol.
9 The implementation is allowed to (but not required to)
10 try to disprove the definitions are equivalent. This
11 obviates the need for `define-if-absent`, which has
7 has changed: it is allowed for the purposes of providing
8 multiple semantically equivalent definitions of a symbol.
9 The implementation is allowed to (but not required to) try
10 to disprove the definitions are semantically equivalent.
11 This obviates the need for `define-if-absent`, which has
1212 been removed.
1313 * Two macro values are now considered equal if their
1414 definitions are exactly equal (intensional equality
1919
2020 * There are now QuickCheck tests that check whether
2121 the multiple definitions for a symbol, when given,
22 are equivalent.
22 are semantically equivalent.
2323 * `error` is no longer used anywhere in the source.
2424
2525 Robin 0.6
642642 ? unbound-identifier
643643
644644 A name may be defined multiple times. The meaning of this is that
645 several _equivalent definitions_ are being given for the name.
645 several _semantically equivalent definitions_ are being given for the
646 name. In this context, "semantically equivalent" means that given the
647 same arguments in the same environment, the two defintions will always
648 evaluate to the same value.
646649
647650 | (define true #t)
648651 | (define true #t)
650653 = #t
651654
652655 An implementation is allowed to check that the definitions are
653 equivalent, and object with an error condition if it can prove
654 that they are not equivalent. So, for example, the following
655 is allowed to be considered an error:
656 semantically equivalent, and object with an error condition if it can
657 prove that they are not semantically equivalent. So, for example, the
658 following is allowed to be considered an error:
656659
657660 (define true #t)
658661 (define true #f)
659662
660663 An implementation should not, however, object with an error condition
661 if it cannot prove the inequivalence (although it is certainly free
662 to produce a warning in this case). A good example of this would
664 if it cannot prove the semantic inequivalence (although it is certainly
665 free to produce a warning in this case). A good example of this would
663666 perhaps be a definition of a function that goes through a Collatz
664667 sequence and evaluates to `#t`, and a function that simply always
665668 evaluates to `#t`.
666669
667670 An implementation is also allowed to simply take it on faith that
668 the definitions are equivalent. (This is not the best example.)
671 the definitions are semantically equivalent. (The following example
672 is perhaps not the best example.)
669673
670674 | (define true #t)
671675 | (define true ((macro (self args env) #t)))
672676 | (display true)
673677 = #t
674678
675 If they are not genuinely equivalent, of course, that is a bug,
676 like any other bug — the semantics of Robin's `define` do not
677 excuse the programmer from exercising their own diligence. The
678 question of which definition Robin picks in this instance is not
679 a sensible question, because the definitions are *supposed* to
680 be equivalent.
679 If they are not genuinely equivalent, of course, that is a programmer
680 error like any programmer error — the semantics of Robin's `define`
681 do not excuse the programmer from exercising their own diligence.
682
683 Since the definitions are supposed to be equivalent, which definition
684 the implementation chooses, is ultimately up to the implementation.
685 The implementation could even choose to use different definitions in
686 different places. However, the current convention is that the
687 definition that is generally preferred because it is the most efficient
688 will be given first (perhaps as a built-in provided by the implementation),
689 so implementations would do well to support choosing the first definition
690 for each symbol that has multiple definitions.
681691
682692 ### `reactor` ###
683693