MathGroup Archive 2006

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

Search the Archive

Re: namespace collision [bug]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68710] Re: namespace collision [bug]
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Thu, 17 Aug 2006 04:18:16 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <ebujoc$6k9$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Chris Chiasson wrote:
> As far as I know, a named pattern created inside the A`Private`
> context should not interfere with the definition of a symbol with the
> same name from B`. Will someone verify this as a bug? Will someone
> please provide a workaround?
> 
> In[1]:=
> BeginPackage["A`"];
> funA::usage="";
> Begin["Private`"];
> funA[funB_]:=funB!;
> End[];
> EndPackage[];
> BeginPackage["B`"];
> Off[General::spell1];
> funB::usage="";
> funC::usage="";
> Begin["Private`"];
> funB[_]:="you called funB";
> funC[_]:="you called funC";
> End[];
> EndPackage[];
> 
> In[16]:=
> funB[5]
> 
> Out[16]=
> funB[5]
> 
> In[17]:=
> funC[5]
> 
> Out[17]=
> you called funC
> 
> In[18]:=
> $Version
> 
> Out[18]=
> 5.2 for Microsoft Windows (June 20, 2005)
> 
Hi Chris,

As a workaround, reverse the order of your packages:

In[1]:=
BeginPackage["B`"];
Off[General::spell1];
funB::usage = "";
funC::usage = "";
Begin["Private`"];
funB[_] := "you called funB";
funC[_] := "you called funC";
End[];
EndPackage[];
BeginPackage["A`"];
funA::usage = "";
Begin["Private`"];
funA[funB_] := funB!;
End[];
EndPackage[];

In[16]:=
funB[5]

Out[16]=
"you called funB"

In[17]:=
funC[5]

Out[17]=
"you called funC"

In[18]:=
funA[5]

Out[18]=
120

In[19]:=
$Version

Out[19]=
"5.2 for Microsoft Windows (June 20, 2005)"

Best regards,
Jean-Marc


  • Prev by Date: Re: position lists
  • Next by Date: Re: Equal represented as HTML HEX entity number 63449 - is that correct?
  • Previous by thread: Re: namespace collision [bug]
  • Next by thread: perplexed by blank sequence in pattern replacement