This is question is also posted at the Wolfram site here. The files are available there as well.
I have a need to make use of a list of associations for fast lookup inside a Package implementation. To do this, I have produced the list in a notebook, saved it to the variable assoc1, and then DumpSaved that to file assoc1.mx. I have written a package assoc1Package.m saved from assoc1Package.nb. The package does two things: 1) It Gets assoc1.mx into the global context; and 2) it defines a function f[x_] as assoc1[x] and makes it available with a usage. It expects that a notebook which loads the package will be able to use f[x] to look up the value in assoc1 corresponding to the key x. This is tried in testAssoc1.nb.
What I find is that the function returns the assoc1[key] unevaluated. However, if the association list is generated within the package, rather than imported by get, it works. The fact that assoc1 is itself defined indicates the Get did work.
I realize I could just load the mx file in my notebook and use assoc1 directly. But this is a simplified example. In reality I want a lot of this inside the package available to functions defined in the package.
I have tried loading the mx file in the package both before and after Private, with the same result. When it is loaded before Private, assoc1 does appear in the global context.
Here is the code for the package and test notebook. The mx file is available at the Wolfram site.
BeginPackage["assoc1Package`"]; Get["C:\\Users\\David\\Documents\\Mathematica files\\A in P\\assoc1.mx"]; f::usage="return assoc1[x]" Begin["`Private`"]; f[x_]:=assoc1[x] End; EndPackage