Re: Re: elementary questio about packages
- To: mathgroup at smc.vnet.net
- Subject: [mg108263] Re: [mg108251] Re: [mg108238] elementary questio about packages
- From: Leonid Shifrin <lshifr at gmail.com>
- Date: Fri, 12 Mar 2010 07:09:08 -0500 (EST)
- References: <201003111137.GAA06115@smc.vnet.net>
Hi Francisco, Depending on the circumstances, another possibility would be to create the needed symbols (z1,z2,etc) in the context they will be used (Global`, say), before the BeginPackage command, and import this context publicly into your package in BeginPackage. This is not as clean a solution as Patrick's (since it couples contexts and assumes a specific work context), but it may be sometimes more convenient - you won't then see the annoying shadowing messages every time when you create z1, z2 in Global` (or whatever is your working context) before loading your package. I guess you can also combine the two approaches: rather than explicitly creating the symbols say in Global` before BeginPackage, you can simply import Global` (or whatever you working context) in BeginPackage, but give these symbols the usage messages in your package anyway. Then, if they don't exist in the target one (Global` here), they will be created in your package and exported just as Patrick suggested. If they exist, usage messages will be added to them in your working context, which I think is also a good thing. Regards, Leonid On Thu, Mar 11, 2010 at 3:48 PM, Patrick Scheibe < pscheibe at trm.uni-leipzig.de> wrote: > Hi, > > like your function-symbols, the symbols z1, z2, ... need > to be exported by giving them a usage. > > Cheers > Patrick > > On Thu, 2010-03-11 at 06:37 -0500, Francisco Gutierrez wrote: > > Dear List: > > I made a package with a function that has a minimization. The > minimization > > returns, as should be, the value of the optimization, and then the values > > of the variables, in the form {z1->10,z2->20,z3->50}. > > > > In the notebook, this works perfectly well. In the package, however, the > function throws back the variables in the form > {contextname`z1->10,contextname`z2->20}. > > This is obnoxious, and makes the result much harder to utilize. How can I > avoid this? I tried deleting > > Begin["`Private`"], but then I got a completely crazy result. > > What should I do? > > Fg > > > > >
- References:
- elementary questio about packages
- From: Francisco Gutierrez <fgutiers2002@yahoo.com>
- elementary questio about packages