MathGroup Archive 2011

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

Search the Archive

Odd (to me) Context issue with Packages?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg115379] Odd (to me) Context issue with Packages?
  • From: Jason Ledbetter <jasonbrent at gmail.com>
  • Date: Sun, 9 Jan 2011 02:20:29 -0500 (EST)

Folk,

I have two (small, ~20KB and ~17KB) notebooks at the following URIs that are
working demonstrate my current Mathematica 8 frustrations.

1) http://forever.broked.net/~jason/demo_fail2.nb

This notebook is the same code from the next example with a package and
exported function wrapper around in. In this example, there are two input
cells that need to be executed in order for the failure to appear.

After "genInfo2[]" is executed in the second cell, a simple manipulate
appears and both of the functions Covariance and Correlation fail because
some of the variables are apparently in a different Context than I expect.
e.g., they "cpu" variable that is shown in the output cell from the
Manipulate appears to be in Global` instead of Huh`Private` as I'd expect.

There *IS* a Huh`Private`cpu variable that gets created here, but apparently
it isn't what is getting passed through the Manipulate and into the
Covariance and Correlation functions.

(Execute Remove["Huh`*"] to clean up what this adds to your M environment)

2) http://forever.broked.net/~jason/demo_fail.nb

This is the same code as in demo_fail2.nb, but without the package wrapper
around it. THIS code works exactly as I'm expecting.

I've been beating my head against #1 for too many hours now.

Can someone shed some light into what is going on here and how to fix this
apparent context failure?

Note: If you execute demo_fail.nb before demo_fail2.nb, the failure will not
occur. This appears to be because demo_fail2.nb's requirements are satisfied
by variables in Global` context at that point.

-jbl


  • Follow-Ups:
  • Prev by Date: Re: about the use of button
  • Next by Date: Re: Mathematica will be a new feature of HTML6
  • Previous by thread: Re: Mathematica how to call and run hspice program which is a EDA software
  • Next by thread: Units question