<p>Thank you for your question, Johannes.</p>

<p>Array and object lookup with dynamic function calls was introduced in very early versions of JSONiq, which started as an extension of XQuery. It is common practice in language design to try to reuse existing machinery in early investigations, before extending the data model and syntax.</p>

<p>Since objects and arrays can be seen as "extensional functions" that explicitly list the input-output pairs, (ab)using dynamic function calls for object and array lookup is quite natural. This approach was also taken in XQuery 3.1.</p>

<p>Syntactic extensions came later. In the "pure JSONiq" syntax, we opted for <code>.Expr</code> for objects and <code>[]</code> as well as <code>[[Expr]]</code> for arrays (double  <code>[[]]</code> to not confuse with predicates). XQuery 3.1 also adds a convenient syntax with <code>?</code> for both objects and arrays.</p>

<p>For FLWOR expressions I recommend looking into <a href="http://rumbledb.org" rel="nofollow noreferrer">Rumble</a>, which pretty much does pipelines in that way already. The paper is <a href="https://arxiv.org/abs/1910.11582" rel="nofollow noreferrer">here</a>.</p>
Array and object lookups in JSONiq
<p>I'm currently working on improving JSON querying capabilities with Brackit[1] and [2], which is an XQuery engine with additional arrays and "records". I'm now basically following the same XDM as JSONiq uses, but I'm sadly no XQuery expert. I guess I've more or less taken over the project from Sebastian and especially added temporal enhancements.</p>

<p>Brackit uses a dereferencing operator <code>=&gt;</code> for records / objects to get the value for a name.</p>

<p>Additionally it uses <code>[[expr()]]</code> for array index lookups, I guess just like the pure JSONiq specification.</p>

<p>I'm sure you have good reasons to do the dynamic function calls instead, so I might have to change it. However, I thing that the dereferencing operator might work in all cases, which is in my opinion a nicer syntax.</p>

<p>I think this vision is great to have a query compiler for semi-structured data with proven optimizations for use in data stores: <a href="http://wwwlgis.informatik.uni-kl.de/cms/dbis/projects/brackit/mission/" rel="nofollow noreferrer">http://wwwlgis.informatik.uni-kl.de/cms/dbis/projects/brackit/mission/</a></p>

<p>One of the decisive features of Brackit might be the pipelining of FLOWR expressions for set-oriented processing.</p>

<p>kind regards</p>

<p>Johannes</p>

<p>[1] <a href="https://github.com/sirixdb/brackit" rel="nofollow noreferrer">https://github.com/sirixdb/brackit</a></p>

<p>[2] <a href="http://wwwlgis.informatik.uni-kl.de/cms/fileadmin/publications/2013/Dissertation-Baechle.pdf" rel="nofollow noreferrer">http://wwwlgis.informatik.uni-kl.de/cms/fileadmin/publications/2013/Dissertation-Baechle.pdf</a></p>