Sort operator
Following yesterday's post about the 'variables in queries' optimisation, It seems that Philip prefers the 'other conceptually rather nicer' solution to the problem. I was pretty much about to change my mind and follow that path anyway because the 'brute force' method was really becoming nasty. However, to implement the moving declaration optimisation nicely, it would be useful to change slightly the representation of the AST. But since the AST might change anyway if a new Church-style internal representation is used, I decided to do something different for now.
This is why I came back to the 'sort' operator (a standalone sort operator, not the sort option for queries), and started working on a way to optimise the sorting to queries. It isn't ready yet, but shouldn't take too long.