Re: OneStepTopReduction in System` Context in
- To: mathgroup at smc.vnet.net
- Subject: [mg108516] Re: OneStepTopReduction in System` Context in
- From: danl at wolfram.com
- Date: Sun, 21 Mar 2010 02:06:37 -0500 (EST)
> Hello, > > I'd like to understand the behaviour of the following program foo.m. > It seems to have different semantics in Mathematica 5.2 vs. Mathematica > 6/7. > > ---rhxBEGIN foo.m > Print["Context0: ", $Context]; > Print["ContextPath0: ", $ContextPath]; > BeginPackage["A`"]; > Foo::usage = "blah blah"; > Begin["`Private`"]; > Foo[] := Module[ > {method} > , > Print["Context: ", $Context]; > Print["ContextPath: ", $ContextPath]; > Print["0: ", Options[RowReduce]]; > method = Options[RowReduce, Method]; > Print["1: ", method]; > SetOptions[RowReduce, Method -> OneStepRowReduction]; > Print["2: ", Options[RowReduce]]; > ]; > End[]; > EndPackage[]; > ---rhxEND foo.m > > When I execute that in Mathematica 5.2, I get > > ================================ > Mathematica 5.2 for Linux > Copyright 1988-2005 Wolfram Research, Inc. > -- Motif graphics initialized -- > > In[1]:= <<foo.m > Context0: Global` > ContextPath0: {Global`, System`} > > In[2]:= Foo[] > Context: Global` > ContextPath: {A`, Global`, System`} > 0: {Method -> Automatic, Modulus -> 0, Tolerance -> Automatic, > >> ZeroTest -> Automatic} > 1: {Method -> Automatic} > 2: {Method -> OneStepRowReduction, Modulus -> 0, Tolerance -> > Automatic, > >> ZeroTest -> Automatic} > ================================================ > > However, in Mathematica 6 and 7 t's like this: > > ================================================ > Mathematica 6.0 for Linux x86 (32-bit) > Copyright 1988-2007 Wolfram Research, Inc. > > In[1]:= <<foo.m > Context0: Global` > ContextPath0: {WebServices`, System`, Global`} > > In[2]:= Foo[] > Context: Global` > ContextPath: {A`, WebServices`, System`, Global`} > 0: {Method -> Automatic, Modulus -> 0, Tolerance -> Automatic, > >> ZeroTest -> Automatic} > 1: {Method -> Automatic} > 2: {Method -> A`Private`OneStepRowReduction, Modulus -> 0, > >> Tolerance -> Automatic, ZeroTest -> Automatic} > ================================================ > > The difference is in the line starting with "2:". > Only when I replace OneStepTopReduction in foo.m by > System`OneStepTopReduction then the output in Mathematica 6 and 7 will be > identical to what Mathematica 5.2 says. Why? > > OneStepTopReduction lives in the System` context (I guess). So, since > the $ContexPath includes System`, Mathematica should find that symbol > there > and not create it in A`Private`. What's wrong here? > > Ralf Sorry, I probably forgot this detail. In the lead-up to version 6 we replaced several of Mathematica's more obscure option settings by strings. We also had code in place that allows them to be passed as symbols even if that is no longer the documented mode (and to make matters worse, documentation may not have kept up with all these changes). OneStepRowReduction is one of those values. So the correct setting is now Method->"OneStepRowReduction" but it will still work if passed as a symbol rather than a string. Among other implications, this means if it is first used as a symbol in some non-system context in versions >=6, then it will live as a symbol in that context. Should work just fine, but it may look a bit weird. Daniel Lichtblau Wolfram Research