Is something like this possible? (description below)
// library.typ
#let UseDict(key) = {
extern MyDict // Sudocode
let val = MyDict.at(key)
// ... use val ...
}
// file-a.typ
#import "library.typ": *
#let MyDict = (
"a": "x",
"b": "y",
)
#UseDict("a") // uses value "x"; Doesn't need to pass MyDict.
// file-b.typ
#import "library.typ": *
#let MyDict = (
"a": "foo",
"b": "bar",
)
#UseDict("a") // uses value "foo"; Doesn't need to pass MyDict.
The goal is to be able to include that library file, define the required dictionary, and then use the function 'UseDict' without having to pass it in every call.
I know that I could create a wrapper function: #let MyUseDict(key) = UseDict(key, MyDict), but then I would have to do it in every file that has this pattern. It's not a huge deal but, if I could avoid it, then I would.