RackSec / desdemona

Data-backed security operations
Eclipse Public License 1.0
2 stars 7 forks source link

Free variables in the query should be an ordered set, not just a set #116

Open lvh opened 8 years ago

lvh commented 8 years ago

Free variables in the query as returned by find-free-vars is currently a regular set. It should be a set (because if a free variable occurs n > 1 times in an expression it is still a single free variable), but it should be an ordered set because we're splicing it into fresh so you need to know the order in order to know what your results mean.

Since we don't touch the set once we created it, this may not be a problem since (seq free-vars) will always return a consistent value. However, having an ordered set would be nice because that makes that requirement explicit. Secondly, that would mean that (ideally) variables are returned in the order they appear in the query, which is nice.

Unfortunately it appears ordered types are only available externally (e.g. flatland/ordered) and not in the stdlib. This is problematic because it appears that library is not available for ClojureScript. Perhaps an acceptable return value for find-free-vars would even be an arbitrary seq; just with duplicate values removed; in which case we can just use distinct.