You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deferred connections were invented to solve the problem that caused by constant implementation - New component is infinite emitter. As a result everywhere where constants are used we need to somehow limit them. To avoid explicit Lock bloat we added -> (...) syntax. This however has some problems:
It makes (manual) analysis of a program (tracing) harder because of lots virtual of lock:sig and lock:data entities moving data around
This technique really defers receiving, not sending, that's one of the reasons we can't have buffered channels by default, see $const can fill the buffer real quick #681 for details
Another form of connection exist, that also makes programs a bit more noisy. (As a counterpart - deferred connections might still remain because they are solving their own problem, that is mostly critical for constants, but not exclusively existing with them)
Solution
At least for constants consider usage of chained connections instead of deferred. Instead of x -> (y -> z) write x -> y -> z where y is constant reference or message literal.
Before
:foo -> (42 -> :bar)
Translates to:
const s = 'definitely not a valid URL'
// ...
#bind(s)
send42 New
---
:foo -> lock:sig
send42 -> lock:data
lock:data -> :bar
Trace:
sent | :foo | {}
send | send42 | 42
recv | lock:sig | {}
recv | lock:data | 42
sent | send42 | 42 // at least 1 more time in this case
sent | lock:data | 42
recv | :bar | 42
After
:foo -> 42 -> :bar
Translates to:
const s = 'definitely not a valid URL'
// ...
#bind(s)
send42 NewV2
---
:foo -> newV2:sig
newV2:data -> :bar
Trace:
sent | :foo | {}
recv | send42 | {}
sent | send42 | 42 // exactly 1 time in this case
recv | :bar | 42
Benefits
No () noise (especially good for nested defers)
No sent | __newXXX__ and __lockXXX__ noise in trace logs
Less channels and function calls, less message passing (better performance and memory consumption)
Ability to add automatic buffers
No () noise
Maybe especially good when defer and chain are combined:
Please note that #617 must be implemented for this
Steps To Implement
Implement NewV2 (with obviously better name)
Make changes to desugarer to support chained connections with const refs / msg literals
Consider removing deferred connections (must be thought of very carefully, this is still powerful feature - they solve real problem and they are universal in a way that they can infinitely nest!)
The text was updated successfully, but these errors were encountered:
emil14
changed the title
Deferred Connections 2.0 (Simplified with Trigger semantics)
Constants as triggers (reduce deferred connection usage)
Oct 20, 2024
Problem
Deferred connections were invented to solve the problem that caused by constant implementation -
New
component is infinite emitter. As a result everywhere where constants are used we need to somehow limit them. To avoid explicitLock
bloat we added-> (...)
syntax. This however has some problems:lock:sig
andlock:data
entities moving data around$const
can fill the buffer real quick #681 for detailsSolution
At least for constants consider usage of chained connections instead of deferred. Instead of
x -> (y -> z)
writex -> y -> z
wherey
is constant reference or message literal.Before
Translates to:
Trace:
After
Translates to:
Trace:
Benefits
()
noise (especially good for nested defers)sent | __newXXX__
and__lockXXX__
noise in trace logsMaybe especially good when defer and chain are combined:
Please note that #617 must be implemented for this
Steps To Implement
NewV2
(with obviously better name)The text was updated successfully, but these errors were encountered: