Skip to content

Commit d195662

Browse files
committed
RFC #73: Use Layout.cast() when checking for matching layouts.
1 parent b2c2204 commit d195662

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

text/0073-stricter-connections.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ Currently, `lib.data.View.eq()` does no checks on the passed value and immediate
3939
(eq (sig a) (sig b))
4040
```
4141

42-
This RFC proposes adding a check to `View.eq()` that would reject direct assignments from another `View` with a non-identical layout.
43-
If such an assignment is desired, the other `View` can be explicitly passed through `Value.cast()` first.
42+
This RFC proposes adding a check to `View.eq()` that would reject direct assignments from another aggregate data structure with a non-identical layout.
43+
If such an assignment is desired, the other aggregate data structure can be explicitly passed through `Value.cast()` first.
4444

4545
Currently `lib.wiring.connect()` passes every signal through `Value.cast()` before assigning them.
4646
This results in a `ValueCastable`'s `.eq()` not being called, and thereby bypassing the check proposed above.
@@ -51,8 +51,9 @@ This RFC proposes removing the `Value.cast()` so a `ValueCastable`'s `.eq()` wil
5151
[reference-level-explanation]: #reference-level-explanation
5252

5353
Modify `lib.data.View.eq(other)` to add the following checks:
54-
- If `other` is a `View`, reject the assignment if layouts are not identical.
55-
- Otherwise, if `other` is another `ValueCastable`, reject the assignment.
54+
- If `other` is a `ValueCastable`, do `Layout.cast(other.shape())`
55+
- If a valid `Layout` is returned, reject the assignment if it doesn't match `self.shape()`.
56+
- If `Layout.cast()` raises, reject the assignment.
5657
- Otherwise, proceed as normal.
5758

5859
Modify `lib.wiring.connect()` to not pass port members through `Value.cast()`, so that a `ValueCastable`'s `.eq()` will be called, allowing it to perform compatibility checks.

0 commit comments

Comments
 (0)