Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg56730] Re: how call a function by same name in 2 different contexts?
  • From: David Bailey <dave at Remove_Thisdbailey.co.uk>
  • Date: Thu, 5 May 2005 06:01:14 -0400 (EDT)
  • References: <d59lb7$6hf$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

steve wrote:
> 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
> 
If you execute:

Unprotect[FourierTransform];
Remove[FourierTransform]

that will remove the built-in version, so then if you load the package 
you should be able to see the other version.

David Bailey
http://www.dbaileyconsultancy.co.uk


  • Prev by Date: Re: Cases and Nonatomic expression
  • Next by Date: Re: named pattern variable scoped as global, should be local
  • Previous by thread: Re: how call a function by same name in 2 different contexts?
  • Next by thread: Re: how call a function by same name in 2 different contexts?