MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Context Problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109419] Re: Context Problem
  • From: Ingolf Dahl <ingolf.dahl at telia.com>
  • Date: Mon, 26 Apr 2010 07:32:00 -0400 (EDT)
  • Organization: University of Gothenburg
  • References: <201004260851.EAA12424@smc.vnet.net>
  • Reply-to: <ingolf.dahl at physics.gu.se>

To David,

Try with 

BeginPackage["PackageContext`"];
Rule1::usage = "Rule1 is a test exported rule.";
Begin["`Private`"];
Rule1 = Cos[Global`x_]^2 + Sin[Global`x_]^2 -> 1;
End[];
EndPackage[];

In the Global` context, Rule1 will display as

Cos[x_]^2+Sin[x_]^2->1

Ingolf Dahl
Sweden

-----Original Message-----
From: David Park [mailto:djmpark at comcast.net] 
Sent: den 26 april 2010 10:51
To: mathgroup at smc.vnet.net
Subject: [mg109419] [mg109417] Context Problem

I would like to export rules from a package in such a way that the pattern
symbols did not include any contexts and in which I also did not have to
export the symbols used in the pattern. In addition, If possible, I would
like this to work even if the package was loaded from a notebook that had
something other than the Global` context.

 

Here is a sample package and exported rule:

 

BeginPackage["PackageContext`"];  

 

Rule1::usage = "Rule1 is a test exported rule.";  

 

Begin["`Private`"]; 

 

Rule1 = Cos[x_]^2 + Sin[x_]^2 -> 1; 

 

End[];  

 

EndPackage[]; 

 

Then, if we evaluate Rule1 we obtain a very clumsy version of the rule,
although I suppose it will work. 

 

Rule1 

Cos[PackageContext`Private`x_]^2 + Sin[PackageContext`Private`x_]^2 ->  1

 

What I would like is the rule as written in the package. Is there a way to
do this?

 

 

David Park

djmpark at comcast.net

 <http://home.comcast.net/~djmpark> http://home.comcast.net/~djmpark/  

 



  • Prev by Date: Re: problems with NMinimize
  • Next by Date: Re: Dynamic evaluation of layered networks
  • Previous by thread: Re: Context Problem
  • Next by thread: Re: Context Problem