da-h/miniflask

state caches fuzzy_names but does not remember when name does not exist

da-h opened this issue · 1 comments

da-h commented

Note: Maybe, state should only allow predefined variables?

da-h commented

The behavior, namely disabled caching for in-calls if the variable is not existent should not change.

Note: A change would be possible but would require a more complicated procedure on state changes. (See below).

Example that shows why this behavior is intended:

  • The module moduleCaller asks for "var" in state, but the variable is created in another module AFTER moduleCaller asks for it. So let's assume that moduleSetter calls state["var"] = 42 sometime later.
  • Since moduleCaller asked for state["var"] before setting the variable, moduleCaller caches that the variable does not exist. Any further seach in the form "var" in state would always return false with caching enabled, unless each state change makes sure that ALL module-state-caches are adapted.
  • alternatively, caching is always off if the variable was not found. (as it is now)