This is a problem which troubled me for a while and I discovered it might potentially be a rather major issue.
When adding a mutation, it is necessary to declare ports. We declare a port as an argument, as things are set up currently, either as an IOPort or as a WritablePort. They are, then, handled differently in recordDeps: either as dependency or precedence to the mutation.
|
if (a instanceof IOPort) { |
|
this._dependencyGraph.addEdge( |
|
a, |
|
reaction as unknown as Reaction<Variable[]> |
|
); |
|
sources.add(a); |
|
} else if (a instanceof MultiPort) { |
|
} else if (a instanceof WritablePort) { |
|
this._dependencyGraph.addEdge( |
|
reaction as unknown as Reaction<Variable[]>, |
|
a.getPort() |
|
); |
|
effects.add(a.getPort()); |
|
} else if (a instanceof WritableMultiPort) { |
The issue is, they are able to be converted to one another inside of the mutation (by using this.getReactor().writable(port), or (port as unknown as WritablePort<number>).getPort()), and potentially create a causality loop. Unfortunately to do connection inside of a mutation, it appears that IOPort version is required, and if we want to connect AND write to a port then conversion is necessary (either pass in an WritablePort and convert to IOPort when connecting, or pass in an IOPort and convert to WritablePort).
This is a problem which troubled me for a while and I discovered it might potentially be a rather major issue.
When adding a mutation, it is necessary to declare ports. We declare a port as an argument, as things are set up currently, either as an
IOPortor as aWritablePort. They are, then, handled differently inrecordDeps: either as dependency or precedence to the mutation.reactor-ts/src/core/reactor.ts
Lines 659 to 665 in f5c195f
reactor-ts/src/core/reactor.ts
Lines 689 to 695 in f5c195f
The issue is, they are able to be converted to one another inside of the mutation (by using
this.getReactor().writable(port), or(port as unknown as WritablePort<number>).getPort()), and potentially create a causality loop. Unfortunately to do connection inside of a mutation, it appears thatIOPortversion is required, and if we want to connect AND write to a port then conversion is necessary (either pass in anWritablePortand convert toIOPortwhen connecting, or pass in anIOPortand convert toWritablePort).