Re: Returning rules from functions inside a package context

*To*: mathgroup at smc.vnet.net*Subject*: [mg82473] Re: Returning rules from functions inside a package context*From*: Vince Virgilio <blueschi at gmail.com>*Date*: Sat, 20 Oct 2007 22:20:37 -0400 (EDT)*References*: <ff9rjl$4mv$1@smc.vnet.net>

On Oct 19, 4:58 am, Art <grenan... at gmail.com> wrote: > The following question has been asked and answered in a variety of > ways in this forum, but I am new to Mathematica and am still not sure what is > best practice after doing Trace of various trivial statements for the > past few hours. > > For example, I would like f[] below to return {a->1.}, not > {A`Private`a->1.}. > > BeginPackage["A`"] > f::usage = "" > Begin["`Private`"] > > f[] := FindFit[{{0, 0}, {1, 1}}, a x, {a}, x] > > End[] > > EndPackage[] > > The use of Rule[] in different scoping constructs is confusing. > > Thanks. First scope a and x appropriately, as others in this thread have advised. But then try strings; return the value with the definition f["a"] = 1, or if you need rules, perhaps f["a"] = {"a" -> 1}. I think it's prudent to keep the symbols to a minimum; they too easily introduce difficult dependencies into larger packages. Vince Virgilio