Implement Singleton Types Using the <wrapper> Mechanism #2499
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allows definition of methods on objects. This supersedes #2486 for the definition of methods on words using
M: \ some-word some-generic ...but is implemented arguably in a much more intrusive way, since any object can be dispatched on now. This also allows CLOS-like eql-specializers for arbitrary objects. For convenience, a new set of "escaping" words is introduced that creates "anonymous" classes when used in a classoid position:
(EDIT: updated above example to illustrate the difference between dispatching on classes vs. their values)
<wrapper>objects are part of the class algebra with this change, and behave kind of like predicate classes that only dispatch one value. Dependency and definition handling should work correctly, but should probably be tested much more thoroughly...EDIT:
Updated to work with
UNION:classes. Also allowsUNION: foo \ foo ;It is possible though to introduce dependency issues when sorting tests a predicate class against a possibly matching singleton type in the same compilation unit. This is kind of error is caught. The workaround is as usual: Put the first definition into a different or nested compilation unit.
Alternatively, the ability to test class intersection of predicate classes against singleton types could be removed, but then method sorting becomes less convenient.
EDIT2:
There is probably no reason this should specifically make use of the
<wrapper>mechanism, except that it is already there and kind of makes sense to me...