This repository was archived by the owner on Nov 7, 2018. It is now read-only.
File tree 3 files changed +36
-1
lines changed
3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 3
3
This is just a sketch, but the idea is to extend class type syntax to
4
4
integrate with typed objects.
5
5
6
+ * WARNING:* This is * very* preliminary and not fully thought through.
7
+
6
8
## Field types
7
9
8
10
Allow users to declare field types. If any field types exist, this
Original file line number Diff line number Diff line change 1
1
# Extensions to describe object-oriented languages
2
2
3
- This is just a sketch rather than a detailed writeup.
3
+ This is just a sketch rather than a detailed writeup. The ideas are
4
+ preliminary.
4
5
5
6
## Typed object references
6
7
Original file line number Diff line number Diff line change
1
+ # Operator overloading
2
+
3
+ To make value types usable, it should be possible to override the
4
+ operators that are used with them. The system I sketch out here is not
5
+ specific to value types, however. It is based on Brendan's ideas for
6
+ multidispatch.
7
+
8
+ * WARNING:* This is * very* preliminary and * not even close* to thought
9
+ through.
10
+
11
+ The idea is to employ multidispatch. The correct function to apply is
12
+ based on the prototype of both the left and right hand sides (note
13
+ that the prototype of value operands is obtained via the registry
14
+ described in the [ value type] ( valuetypes.md ) proposal). There is some
15
+ form of operator registry that lets you add pairs of prototypes and,
16
+ when an operator is applied, the most specific one is chosen.
17
+ Ideally, the existing coercion rules would be subsumed under this
18
+ registry.
19
+
20
+ We might wish to guarantee that adding prototype pairs to the registry
21
+ never disturbs existing pairs (that is, the registry grows
22
+ monotonically). Alternatively, maybe allow users to freeze prototype
23
+ pairs.
24
+
25
+ We do not attempt to guarantee algebraic equivalence guarantees and
26
+ the like (IEEE floating point already removes most of them anyhow).
27
+
28
+ - What operators can be overloaded?
29
+ - Not ` === ` , but yes ` == `
30
+ - ` + ` , ` - ` , etc
31
+ - Not ` . ` , but what about ` [] ` ?
32
+
You can’t perform that action at this time.
0 commit comments