MathGroup Archive 2011

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

Search the Archive

Re: multiple contexts in package

  • To: mathgroup at smc.vnet.net
  • Subject: [mg117997] Re: multiple contexts in package
  • From: Sebastian Hofer <sebhofer at gmail.com>
  • Date: Fri, 8 Apr 2011 04:12:57 -0400 (EDT)
  • Reply-to: comp.soft-sys.math.mathematica at googlegroups.com

On Thursday, April 7, 2011 2:07:26 PM UTC+2, David Bailey wrote:
> On 06/04/2011 10:12, Sebastian Hofer wrote:
> > I'd like to create a context for semi-hidden symbols (i.e. only provided if explicitly loaded) in one of my packages. How can I achieve such a thing?
> > My best bet was the following (inspired by looking at the Parallel package):
> >
> > BeginPackage["Package`"]
> > (*visible symbols*)
> >
> > BeginPackage["Package`Hidden`"]
> > (*semi hidden symbols*)
> > EndPackage[]
> >
> > Begin["`Private`"]
> > (*hidden symbolds*)
> > End[]
> > EndPackage[]
> >
> > Trying to load Package`Hidden` does not load anything though. Where am I going wrong?
> >
> > Best regards,
> > Sebastian
> >
>
> Maybe this is obvious to you already, but you can always create symbols
> in contexts with arbitrary names, just by typing the full name:
>
> In[624]:= Foo`fred=0
>
> Out[624]= 0
>
> In[625]:= ?Foo`*
>
> Foo`fred
>
> Foo`fred=0
>
> David Bailey
> http://www.dbaileyconsultancy.co.uk


Yes I knew that, but I am not quite sure how it should help.
I think I misstated my problem:
I have a package which uses (internally) a function f, which should normally be in the private context. But sometimes I want it to be visible. Is it possible to create some kind of sub-context in the package which makes f visible only if I load the package in a certain way? Maybe my original approach was just totally wrong...


  • Prev by Date: Normalize[] gives incorrect answer for some norm functions
  • Next by Date: Re: Coefficents of terms in an expression containing the matching string
  • Previous by thread: Re: multiple contexts in package
  • Next by thread: Re: multiple contexts in package