diagonalworks / diagonal-b6

b6: Diagonal's geospatial analysis engine.
Apache License 2.0
24 stars 3 forks source link

Investigate and document shell execution inconsistencies #334

Open silky opened 1 month ago

silky commented 1 month ago

The shell interface doesn't seem perfectly specified, and this results in significant confusion about how to run expressions.

For example, the following Python returns all things in the world:

w(b6.find(b6.all()))

But it doesn't seem possible to run this query in the UI:

find all

Gives:

Error:find: expected b6.Query, found *api.goCall

But the documentation for for find indicates that it does take a Query; which is what all is.

There are probably many more examples of this problem; so this issue is related to #283 in terms of documenting precisely how to use this feature.

The main outcome to seek here is clear indications of what is possible. Maybe we only want to support tag-based querying ( cc @gacafe ) , in which case queries like the above should be rejected, and not just result in a type error.

andreweland commented 1 month ago

all is a function that returns a query, not a query, so to find everything, you need to say find (all)

Semantically, a function is only called implicitly if the symbol appears as the first argument in a (potentially nested) sequence of tokens, so in find all the function bound to the find symbol is called, and passed the function bound to the all symbol as an argument. In find (all), the function bound to the all symbol is first called with no arguments, and the result (a query that matches anything indexed) is passed to find

silky commented 1 month ago

Ah great; thanks for the clarification!

Can confirm that find (all) does exactly what I expected :)