top | item 29159733

(no title)

danellis | 4 years ago

Curious syntax. Why does it require sigils? Why does assignment need both `let` and `:=`?

discuss

order

emmanueloga_|4 years ago

The look and feel of this language is due to its close relationship with XQuery and the XML world, including the syntax.

From [1]:

XQuery 3.1 was designed with the goal to support additional data structures (maps, arrays) in memory. These structures are mapped to JSON for input and output. XQuery 3.1 has been a W3C recommendation since March 2017.

JSONiq was designed with the goal of querying and updating JSON in settings such as document stores. It was also designed by members of the XML Query working group (disclaimer: I am one of them) while investigating various possibilities to support JSON.

1: https://stackoverflow.com/questions/44919443/what-are-the-di...

ghislainfourny|4 years ago

Thank you for your question.

This is, in fact, not an assignment, but a variable binding that is highly optimizable by an execution engine. The let clause is part of the FLWOR expression, works in orchestration with for, where, group by, order by, count, return; the ability to bind variables while doing relational algebra is a feature that is often missed in SQL.

JSONiq is functional and, in its core (non scripting) version, does not allow modifying variable values.

oever|4 years ago

It's derived from XQuery, a functional language for querying and creating XML and JSON. (I realize that that's not an answer to your question.)