Re: elementary questio about packages
- To: mathgroup at smc.vnet.net
- Subject: [mg108294] Re: elementary questio about packages
- From: Yves Klett <yves.klett at googlemail.com>
- Date: Fri, 12 Mar 2010 07:14:50 -0500 (EST)
- References: <hnakm4$5va$1@smc.vnet.net>
Hi,
two solutions:
1)quick=C2=B4n dirty: In your package code, replace "z1" with "Global`z1"
etc. in situ. Quite prone to errors, oversights etc.
2) make your private variable known to the global context by adding a
usage comment before entering the private context, e.g.
z1::usage="z1 is used for blabla..."
This has the advantage that you can ask about z1 with Information[z1],
which returns said usage message. It also encourages proper
documentation on the package level.
As always, have a look at any number of published packages to learn how
it's done...
Regards,
Yves
Am 11.03.2010 12:37, schrieb Francisco Gutierrez:
> 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
>