|
[Date Index]
[Thread Index]
[Author Index]
Re: Context Problem
- To: mathgroup at smc.vnet.net
- Subject: [mg109443] Re: Context Problem
- From: Rui <rui.rojo at gmail.com>
- Date: Tue, 27 Apr 2010 07:40:55 -0400 (EDT)
- References: <hr3k5q$c44$1@smc.vnet.net>
On Apr 26, 5:51 am, "David Park" <djmp... at comcast.net> wrote:
> 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
>
> djmp... at comcast.net
>
> <http://home.comcast.net/~djmpark>http://home.comcast.net/~djmpark/
I'd try something like:
BeginPackage["PackageContext`"];
Rule1::usage = "Rule1 is a test exported rule.";
Begin["`Private`"];
Rule1 := (Cos[x_]^2 + Sin[x_]^2 -> 1)/.x->Unique["x"];
End[];
EndPackage[];
so you get something like
Rule1
Cos[x1_]^2 + Sin[x1_]^2 -> 1
cause the symbol is created only when the Rule1 is evaluated
Prev by Date:
Re: how uncouple dynamic objects?
Next by Date:
Re: Precision of calculations
Previous by thread:
Re: Context Problem
Next by thread:
Re: Context Problem
|