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

MathGroup Archive 1994

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

Search the Archive

Options and Contexts

  • To: mathgroup at yoda.physics.unc.edu (mathgroup)
  • Subject: Options and Contexts
  • From: gt9397a at prism.gatech.edu (Daryl S. Reece)
  • Date: Thu, 14 Apr 1994 00:57:24 -0400 (EDT)

Dear Mathgroupers-
 
    Can anyone help me with this problem.
 
I have a function that I want to define in its own context.
I want to assign options to this function within its own context.
I then want to be able to call the function from the Global
context with options and not have to differentiate between
the context of options assigned at the global level
and the default values.  An example will help.
 
BeginPackage["Test`"];
Tester::usage = "Tester[opts___] acts based on options.";
Opt1::usage = "Option for Tester.";
Begin["Test`Private`"];
Options[Tester] = {Opt1->A};
Tester[opts___] := 
Module[{opt1},
  opt1 = Opt1/.{opts}/.Options[Tester];
  Print["Equality of option and A ", opt1===A];
  Print["Equality of option and B ", opt1===B];
]
End[];
EndPackage[];
 
Tester[]
Equality of option and A True
Equality of option and B False
 
Tester[Opt1->B]
Equality of option and A False
Equality of option and B False
 
Tester[Opt1->Test`Private`B]
Equality of option and A False
Equality of option and B True
 
These last two examples show that any options assigned at
the global level cannot be compared within the Private contexts
without specifically declaring their contexts.  This is a problem 
since I would like to be able to call the package from any context
and have it behave the same.  Thanks ahead of time for the help.
-- 
Daryl Reece

Internet: dreece at cad.gatech.edu  or gt9397a at prism.gatech.edu
Compuserve: 71620,1262

(404) 894-9568(office), (404) 888-0426(home), (404) 894-9313(fax)

School of Aerospace Engineering
Georgia Institute of Technology
Atlanta, GA 30332-0150





  • Prev by Date: Summer course on quantum mechanics and Mathemtica
  • Next by Date: Mathematica World - April
  • Previous by thread: Summer course on quantum mechanics and Mathemtica
  • Next by thread: Re: Options and Contexts