Skip to content
This repository was archived by the owner on Nov 7, 2018. It is now read-only.

Commit bdaeacf

Browse files
committed
sketch out class syntax, oo type extensions, and overloading
1 parent 3a4ec92 commit bdaeacf

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

Diff for: classsyntax.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
This is just a sketch, but the idea is to extend class type syntax to
44
integrate with typed objects.
55

6+
*WARNING:* This is *very* preliminary and not fully thought through.
7+
68
## Field types
79

810
Allow users to declare field types. If any field types exist, this

Diff for: ootypes.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Extensions to describe object-oriented languages
22

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.
45

56
## Typed object references
67

Diff for: overloading.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+

0 commit comments

Comments
 (0)