Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
abichinger committed Nov 20, 2023
1 parent 7fd00a3 commit 37762a9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ Fields are accessed in a similar way. Assuming `foo` has a field called "Length"

"foo.Length > 9000"

Accessors can be nested to any depth, like the following
The values of a `map` are accessed in the same way. Assuming the parameter `foo` is `map[string]int{ "bar": 1 }`

"foo.Bar.Baz.SomeFunction()"
"foo.bar == 1"

However it is not _currently_ supported to access values in `map`s. So the following will not work
Accessors can be nested to any depth, like the following

"foo.SomeMap['key']"
"foo.Bar.Baz.SomeFunction()"

This may be convenient, but note that using accessors involves a _lot_ of reflection. This makes the expression about four times slower than just using a parameter (consult the benchmarks for more precise measurements on your system).
If at all reasonable, the author recommends extracting the values you care about into a parameter map beforehand, or defining a struct that implements the `Parameters` interface, and which grabs fields as required. If there are functions you want to use, it's better to pass them as expression functions (see the above section). These approaches use no reflection, and are designed to be fast and clean.
Expand Down

0 comments on commit 37762a9

Please sign in to comment.