       • To: mathgroup at christensen.cybernetics.net
• Subject: [mg523] Confused about contexts ...
• From: Paul E Howland <PEHOWLAND at taz.dra.hmg.gb>
• Date: Wed, 8 Mar 1995 15:40:34 +0200 (IST)

```Dear Mathgroup,

I think I'm getting my contexts in a muddle.  Can you help me with the

Consider the following simple package:

BeginPackage["Example`"]
test::usage = "Test function"
Begin["`Private`"]
test[a_] := Module[{}, z=Sin[x];Function[x,z]]
End[]
EndPackage[]

I'm trying to code a function "test" that returns a function as its argument.
Thus, _what_I'd_like_to_happen_ is this:

In :=
<<Package.m
In :=
f = test[a]
Out :=
Function[x,Sin[x]]
In :=
f[theta]
Out :=
Sin[theta]

However, what actually happens is this:

In :=
<<Package.m
In :=
f = test[a]
Out :=
Function[Example`Private`x, Example`Private`z]
In :=
f[theta]
Out :=
Sin[Example`Private`x]

Of course, in reality my function is much more complicated than Sin[x],
and has to be calculated by the function "test".  "test" takes in data
(represented by the variable "a" in the example above) in order to try to
calculate this function.

What am I doing wrong?

Many thanks,

Paul E Howland

Long Range Ground Radar Systems Section               tel. +44 (0)1684 895767
CSS2 Division, Room BY209                             fax. +44 (0)1684 896315
Defence Research Agency                           email: PEHOWLAND at DRA.HMG.GB
Malvern, Worcs, WR14 3PS, UK.
-----------------------------------------------------------------------------

```

• Prev by Date: How to identify equations
• Next by Date: Vote NO!!!!!!!!!
• Previous by thread: How to identify equations