Dynamic messages creation/building (builder, recorder, from record) #413
Replies: 8 comments
-
Union messages probably should not be able to be created. This should only be a parameter. Even-though you can do so in TS |
Beta Was this translation helpful? Give feedback.
-
Naive implementation of the recorder (record/struct builder)func recorder(m map[string]struct{}{}, io core.IO) error {
outport, err := io.Outort("v")
if err != nil {
return err
}
inports := make(map[string]chan core.Msg, m)
for k := range m {
port, err := io.Inport(k)
if err != nil {
return err
}
inports[k] = port
}
wg := sync.WaitGroup{}
for {
v := make(map[string]core.Msg, len(m)) // check
for k, in := range inports {
wg.Add(1)
go func(k string) {
v[k] = <- in
wg.Done()
}(k)
}
wg.Wait()
outport<-v
}
} Then having a The reason why it can't be a componentIs that type system doesn't have ability to say "this component will have these ports corresponding to this record" |
Beta Was this translation helpful? Give feedback.
-
"From record" featureAdd a feature called "from record" that will allow to create inports based on given record field. It **should not be part of a type-system" because type system doesn't known anything about ports (and components) which is a good thing. So this should be implemented at compiler level
So it should be possible to say f = foo<{a int, b str}>
ff = f.in(2 '3')
// ff == {a: 2, b: '3'} IIPs (static ports)Maybe this feature can be used to implement IIPs
It's not clear whether this adds something good or not Problem
Arr portsIs it possible to make array ports be converted into regular arrays? Related #170 |
Beta Was this translation helpful? Give feedback.
-
possible solutions are:
|
Beta Was this translation helpful? Give feedback.
-
Constructor and destructor
typings via ProblemIt's not clear if we need destructor since network manager can select fields |
Beta Was this translation helpful? Give feedback.
-
Let's think it solved with #149 (comment) for now |
Beta Was this translation helpful? Give feedback.
-
I have a bad feeling about this. Not sure if it's closed really |
Beta Was this translation helpful? Give feedback.
-
While it's clear how to use static messages (via IIPs) it's not clear how one should dynamically create messages, especially of composite types;
-. Scalars looks simple: you have operators that returns scalar values
-. What about composite types: arrays, records, vectors, maps?
There's at least 2 directions to investigate that are:
Solution 1 seems like an ad-hoc (like a generators from #106), but could add more compile-time safety. E.g. it could be possible to check that
array builder
can only have as much inport slots as size in corresponding array type. This is however must be investigated. On the other hand, maybe type system itself could be more complex to allow to program such things like "this component can have N inport slots for that inport, where N depends on some X"Beta Was this translation helpful? Give feedback.
All reactions