Message Boards Message Boards

0
|
3584 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Why can't package call imported association list?

Posted 7 years ago

This is a bit convoluted, and I've attached 4 files that are a simple example.

The issue is this: 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.

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.

Due to package use, I can't really put runnable code here, but this is what I see:

error

Attachments:
POSTED BY: David Keith
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract