Ah! I knew Andrew would have put in some way to do it in Jsonata
It is probably slightly more readable, IMO, yes.
Would you mind me asking why what I attempted to do is not possible?
flow.bar[flow.foo]
I suspect the answer is that JS doesn’t work like that... but my question is really, why doesn’t it work like that? It feels like a reasonable syntactic choice!
(TBH flow.bar.flow.foo or flow.bar(flow.foo) feels even better, but probably good reasons they aren’t good!)
Well it's all down to context again (in the wider programming sense). If there was an object called flow that was accessible then yes you could do that... in fact if you had it all stored on the msg then you could have. As flow. (and global.) have to be special (so flow properties are indeed per flow (or subflow)), then they are not simple objects so flow.bar is not the same as flow.get("bar") . The reason for using .get and .set is so that these methods can be extended to external storage for persistence.