- To: mathgroup at smc.vnet.net
- Subject: [mg6210] contexts,packages,names: again!
- From: murray at math.umass.edu (Murray Eisenberg)
- Date: Thu, 27 Feb 1997 02:55:01 -0500
- Sender: owner-wri-mathgroup at wolfram.com
In several recent postings I've asked about separate aspects of getting a
package to work, and I've received quite a few instructive replies.
But when I try to put everything together, I seem to get nowhere.
Let me try to describe what I need to do in as simple a form as I can
get it without omitting essential aspects. Then perhaps someone can
tell me what will really work!
The user of the package will evaluate some expressions like:
CheckMe = "8923";
f[x_] := g[x, 2];
g[x_, y_] : = .....
Then the user will load my package. Here's what my package must do:
0. NOT yet create a new context.
1. Test whether the user has given a value to CheckMe, and whether
that value satisfies certain criteria. If not, use Message to issue
appropriate error messages -- still not yet creating a new context.
fname = "f";
3. Test whether the user has created a function named f. If not, use
Message t issue appropriate error messages -- still not yet creating a
4. If, and only if, the tests in 1. and 3. have been satisfied,
actually create a context via BeginPackage[...] and Begin["Private`"]
within which the following steps are performed:
a. Define various other functions and constants, some of which may
depend on the value of CheckMe.
b. Using those constants and functions, evaluate the user's f with
arguments some of the constants or functions created in a. (And, of
course, print the results.)
However, the code here cannot explicitly contain f, but only
refer to it indirectly via its name stored in fname. (This is to
allow as much of the package to be recyclable without in-place editing
each time I need to reconstitute the package for a different function
named by fname.)
Note that the package does NOT export anything!
5. After 4.a and 4.b, use End and EndPackage, together with any other
relevant steps, be sure to leave no trace of any of the names
introduced in the package or any of the functions, etc., defined in
the package's file before the BeginPackage.
To me, this doesn't sound like it should be at all hard. I'm a very
experienced programmer in several languages in which I've done this
sort of thing. But doing it in Mathematica has me utterly stumped.
That's why I'm asking for such a whole solution -- I simply cannot
make progress on it.
Thank you for your indulgence.
Murray Eisenberg Internet: murray at math.umass.edu
Mathematics & Statistics Dept. Voice: 413-545-2859 (W)
University of Massachusetts 413-549-1020 (H)
Amherst, MA 01003 Fax: 413-545-1801
Prev by Date:
names, symbols, and contexts
Next by Date:
Re: Information about non-symbol heads
Previous by thread:
Re: names, symbols, and contexts
Next by thread:
Re: contexts,packages,names: again!