MathGroup Archive 2005

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

Search the Archive

how call a function by same name in 2 different contexts?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg56715] how call a function by same name in 2 different contexts?
  • From: "steve" <nma124 at hotmail.com>
  • Date: Wed, 4 May 2005 00:34:23 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

There is a function called FourierTransform that is part of standard
Mathematica.

When I load the SignalProcessing package (a standalone Mathematica
application), it also comes with its own version of FourierTransform
function.

The question is how can I, after loading the SignalProcessing package,
specify explicitly which function I wish to call?

I found that I could do the above as follows.

To call the standard function type

           System`FourierTransform[Sin[t],t,w]

To call the function in SignalProcessing package, do

      Needs["SignalProcessing`"]
      SignalProcessing`Support`SigProc`FourierTransform[Sin[t],t,w]

The problem with the above solution is that I had to know before
hand inside which context the FourierTransform function lived in
the SignalProcessing package, by typing the command

Context[FourierTransform]
SignalProcessing`Support`SigProc`

Is there a better way to do this? Why can't I just say
something like "Call the FourierTransform function which
is part of the SignalProcessing package" without having
to know the full contextPath?

But the bigger problem is that after I loaded the SignalProcessing
package, the Context[FourierTransform] does NOT list the
System`FourierTransform any more, even though I call
still access this context as follows

           System`FourierTransform[Sin[t],t,w]

It seems that loading the SignalProcessing package hides the
context of the FourierTransform function in the System package
as you can see:

     Context["FourierTransform"]
          System`

     Needs["SignalProcessing`"]
     Context["FourierTransform"]
          SignalProcessing`Support`SigProc`


I was expecting this output

     Context["FourierTransform"]
           SignalProcessing`Support`SigProc`
           System`

So that I can see where each function is and then call any one
I want without ambiguity.

Any idea how to handle all of this stuff? I do not think it is nice
that one package hides away another function of the same name in
different package. The whole idea of using packages is so that this
sort of thing should not happen !

Is there a way to unload a specific package after loading it without
having to restart Mathematica to clean things out?

Thank you for any insight into this issue
nma124


  • Prev by Date: Re: managing order of magnitude instead of numbers
  • Next by Date: Re: Reading from a file.
  • Previous by thread: Re: Cases and Nonatomic expression
  • Next by thread: Re: how call a function by same name in 2 different contexts?