(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 6.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 108771, 3038] NotebookOptionsPosition[ 95445, 2608] NotebookOutlinePosition[ 96818, 2653] CellTagsIndexPosition[ 96564, 2644] WindowFrame->Normal ContainsDynamic->True *) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell[TextData[{ "Making interactive package development easier with \n \t\t", StyleBox["PackageManipulations`", FontWeight->"Bold", FontSlant->"Italic"], " " }], "Subtitle", CellChangeTimes->{{3.441615231458573*^9, 3.4416152651069565`*^9}, { 3.4416153789406414`*^9, 3.441615402594654*^9}, {3.441900027974229*^9, 3.4419000955213566`*^9}, {3.4419002706932416`*^9, 3.441900272986539*^9}, { 3.442077012517704*^9, 3.442077033808318*^9}, {3.4420771447378273`*^9, 3.4420771537407727`*^9}}], Cell[CellGroupData[{ Cell["\<\ Author: \t\t\tLeonid B. Shifrin \t\t\t \t\t\tleonid@mathprogramming-intro.org, \t\t\tshifrinl@hotmail.com\ \>", "Subsection", CellChangeTimes->{{3.4416153043333616`*^9, 3.441615358240877*^9}, { 3.4416175573931026`*^9, 3.441617572254472*^9}}, FontWeight->"Plain"], Cell["Package version 1.0 - January 2009", "Subsubsection", CellChangeTimes->{{3.441703718150744*^9, 3.441703747372763*^9}}, FontWeight->"Plain"], Cell[TextData[{ StyleBox["Mathematica", FontSlant->"Italic"], " version 5.0+ (untested for earlier versions) " }], "Subsubsection", CellChangeTimes->{{3.4417037513885374`*^9, 3.4417037599107924`*^9}, { 3.441703818074427*^9, 3.4417038219600143`*^9}, 3.4418064057502337`*^9, { 3.4419001043340287`*^9, 3.4419001324043922`*^9}, {3.4420770398970737`*^9, 3.4420770535667295`*^9}}, FontWeight->"Plain"] }, Open ]], Cell[CellGroupData[{ Cell["Introduction", "Section", CellChangeTimes->{{3.4420769092191677`*^9, 3.442076914156267*^9}}, FontWeight->"Plain"], Cell[TextData[{ "The present package allows one to programmatically re-load any given \ package any number of times during the interactive ", StyleBox["Mathematica", FontSlant->"Italic"], " session (or, during execution of a stand-alone program), and also to \ Remove the entire context of the package (and optionally all its \ sub-contexts) in a way consistent with general package mechanics in ", StyleBox["Mathematica. ", FontSlant->"Italic"] }], "Text", CellChangeTimes->{{3.442077684604117*^9, 3.4420779456294527`*^9}, { 3.442078017172326*^9, 3.4420781917333326`*^9}}], Cell["\<\ The main virtue of these manipulations is that one can easily substitute \ older versions of a package with newer ones without quitting the kernel, and \ this makes for much easier interactive package development. Additional \ functionality includes (optional) automatic resolving of shadowing, and the \ tracking of escaping symbols (symbols present in the user's context without \ usage messages) .\ \>", "Text", CellChangeTimes->{{3.442077684604117*^9, 3.4420779456294527`*^9}, { 3.442078017172326*^9, 3.442078194988013*^9}, {3.442081287985525*^9, 3.442081365547053*^9}, {3.4421257769769616`*^9, 3.442125784527819*^9}, 3.4421394026196737`*^9, {3.4421395211200686`*^9, 3.442139530092971*^9}}], Cell[TextData[{ "The present notebook can be considered a tutorial/illustration for the ", StyleBox["PackageManipulations`", FontWeight->"Bold", FontSlant->"Italic"], " functionality, with occasional digressions into related topics such as \ automatic package-from-code generation and shadowing." }], "Text", CellChangeTimes->{{3.442077684604117*^9, 3.4420779456294527`*^9}, { 3.442078017172326*^9, 3.442078195999467*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Illustration", "Section", CellChangeTimes->{{3.4420769029701824`*^9, 3.4420769067055535`*^9}}, FontWeight->"Plain"], Cell[CellGroupData[{ Cell["Preliminaries", "Subsection", CellChangeTimes->{{3.441995002994976*^9, 3.4419950063397856`*^9}}, FontWeight->"Plain"], Cell[CellGroupData[{ Cell["Note", "Subsubsection", CellChangeTimes->{{3.4420773246465235`*^9, 3.442077326358986*^9}}, FontWeight->"Plain"], Cell["\<\ This illustration section is written in a way that generally requires \ sequential execution of the sub - sections. It is not necessary to read them \ sequentially however - you can just as well execute closed cells, opening \ only the cell of interest. \ \>", "Text", CellChangeTimes->{{3.442077199626754*^9, 3.442077301052597*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Loading the package", "Subsubsection", CellChangeTimes->{{3.4420773386166115`*^9, 3.4420773463377137`*^9}}, FontWeight->"Plain"], Cell[TextData[{ "Let Mathematica know where to look for the package (", StyleBox["use your directory instead", FontWeight->"Bold", FontSlant->"Italic"], ") :" }], "Text", CellChangeTimes->{{3.4420658683131247`*^9, 3.442065894220378*^9}, 3.4421394085682273`*^9}], Cell[BoxData[ RowBox[{ RowBox[{"AppendTo", "[", RowBox[{ "$Path", ",", "\"\\""}], "]"}], ";"}]], "Input", CellChangeTimes->{{3.441991400735181*^9, 3.44199144031209*^9}, { 3.4419931802640176`*^9, 3.4419931818062353`*^9}}], Cell["Load the package :", "Text", CellChangeTimes->{{3.442065900259061*^9, 3.4420659037540865`*^9}}], Cell[BoxData[ RowBox[{"Needs", "[", "\"\\"", "]"}]], "Input", CellChangeTimes->{{3.4419926996028605`*^9, 3.4419927154656706`*^9}}], Cell[BoxData[ RowBox[{"PackageReload", "[", "\"\\"", "]"}]], "Input", CellChangeTimes->{{3.442131392611848*^9, 3.4421314036877747`*^9}}], Cell["These are the symbols in the user' s context :", "Text", CellChangeTimes->{{3.4420659143693504`*^9, 3.4420659261763277`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"?", "PackageManipulations`*"}]], "Input", CellChangeTimes->{{3.4420428589072237`*^9, 3.442042864945907*^9}}], Cell[CellGroupData[{ Cell[BoxData[ DynamicModuleBox[{Typeset`open$$ = True}, PaneSelectorBox[{False-> RowBox[{ OpenerBox[Dynamic[Typeset`open$$], ImageSize->Small], StyleBox["PackageManipulations`", "InfoHeading"]}], True->GridBox[{ { RowBox[{ OpenerBox[Dynamic[Typeset`open$$], ImageSize->Small], StyleBox["PackageManipulations`", "InfoHeading"]}]}, {GridBox[{ { ButtonBox["ClearQuiet", BaseStyle->"InformationLink", ButtonData:>{ "Info3442112199-7221442", "PackageManipulations`ClearQuiet"}, ButtonNote->"PackageManipulations`"], ButtonBox["PackageClearComplete", BaseStyle->"InformationLink", ButtonData:>{ "Info3442112199-7221442", "PackageManipulations`PackageClearComplete"}, ButtonNote->"PackageManipulations`"], ButtonBox["RemovePackage", BaseStyle->"InformationLink", ButtonData:>{ "Info3442112199-7221442", "PackageManipulations`RemovePackage"}, ButtonNote->"PackageManipulations`"]}, { ButtonBox["KillShadowing", BaseStyle->"InformationLink", ButtonData:>{ "Info3442112199-7221442", "PackageManipulations`KillShadowing"}, ButtonNote->"PackageManipulations`"], ButtonBox["PackageReload", BaseStyle->"InformationLink", ButtonData:>{ "Info3442112199-7221442", "PackageManipulations`PackageReload"}, ButtonNote->"PackageManipulations`"], ButtonBox["RemoveQuiet", BaseStyle->"InformationLink", ButtonData:>{ "Info3442112199-7221442", "PackageManipulations`RemoveQuiet"}, ButtonNote->"PackageManipulations`"]}, { ButtonBox["PackageClear", BaseStyle->"InformationLink", ButtonData:>{ "Info3442112199-7221442", "PackageManipulations`PackageClear"}, ButtonNote->"PackageManipulations`"], ButtonBox["PackageRemove", BaseStyle->"InformationLink", ButtonData:>{ "Info3442112199-7221442", "PackageManipulations`PackageRemove"}, ButtonNote->"PackageManipulations`"], ""} }, DefaultBaseStyle->"InfoGrid", GridBoxItemSize->{"Columns" -> {{ Scaled[0.31666666666666665`]}}}]} }, GridBoxAlignment->{"Columns" -> {{Left}}, "Rows" -> {{Baseline}}}]}, Dynamic[Typeset`open$$], ImageSize->Automatic]]], "Print", "InfoCell", CellChangeTimes->{3.442141000076704*^9}], Cell[BoxData[ StyleBox["\<\"RemoveQuiet is an option for PackageRemove. Can be used to \ switch off warnings\"\>", "MSG"]], "Print", "PrintUsage", CellTags->"Info3442112199-7221442"] }, Open ]] }, Open ]], Cell["The functions of the package are ", "Text", CellChangeTimes->{{3.442065795468379*^9, 3.442065802097912*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ "PackageClear", ",", "PackageClearComplete", ",", "PackageReload", ",", "PackageRemove"}], "}"}]], "Input", CellChangeTimes->{{3.4420658058933697`*^9, 3.442065835916541*^9}}], Cell["Other names stand for options for these functions.", "Text", CellChangeTimes->{{3.4420658390610623`*^9, 3.4420658511784863`*^9}}] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Converting code to package, and the test package", "Subsection", CellChangeTimes->{{3.4419950127490015`*^9, 3.4419950160036817`*^9}, { 3.442076811348437*^9, 3.442076821673283*^9}}, FontWeight->"Plain"], Cell[TextData[{ "The functionality we will just develop may be useful by itself, since it \ allows you to programmatically convert the interactively entered code to a \ saved package. This is done by the ", StyleBox[" PackageFromHeldCode", FontWeight->"Bold", FontSlant->"Italic"], " function below :" }], "Text", CellChangeTimes->{{3.4419923580617485`*^9, 3.4419924316575747`*^9}, { 3.4420659505213346`*^9, 3.4420659744958076`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"(*", " ", RowBox[{"Auxilliary", " ", "function"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"JoinHeld", "[", "a___Hold", "]"}], ":=", "\n", "\t", RowBox[{"Hold", "@@", RowBox[{"Replace", "[", RowBox[{ RowBox[{"Hold", "[", "a", "]"}], ",", RowBox[{ RowBox[{"Hold", "[", "x___", "]"}], ":>", RowBox[{"Sequence", "[", "x", "]"}]}], ",", RowBox[{"{", "1", "}"}]}], "]"}]}]}], ";"}]}]], "Input", CellChangeTimes->{{3.442042312601675*^9, 3.4420423175688176`*^9}, { 3.442042353861003*^9, 3.442042373649458*^9}, {3.442064860774355*^9, 3.4420648695669985`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"PackageFromHeldCode", "[", RowBox[{ RowBox[{"code", ":", RowBox[{"Hold", "[", RowBox[{"CompoundExpression", "[", "___", "]"}], "]"}]}], ",", "fname_String"}], "]"}], ":=", RowBox[{"Put", "@@", RowBox[{"JoinHeld", "[", RowBox[{ RowBox[{"Replace", "[", RowBox[{ RowBox[{"Map", "[", RowBox[{"Unevaluated", ",", RowBox[{"Replace", "[", RowBox[{"code", ",", RowBox[{"x_", "\[RuleDelayed]", RowBox[{"(", RowBox[{"x", ";"}], ")"}]}], ",", RowBox[{"{", "2", "}"}]}], "]"}], ",", RowBox[{"{", "2", "}"}]}], "]"}], ",", RowBox[{ RowBox[{ RowBox[{"Verbatim", "[", "CompoundExpression", "]"}], "[", "x___", "]"}], "\[RuleDelayed]", "x"}], ",", RowBox[{"{", "1", "}"}]}], "]"}], ",", RowBox[{"Hold", "[", "fname", "]"}]}], "]"}]}]}], ";"}]], "Input", CellChangeTimes->{{3.441991007549808*^9, 3.4419910981901426`*^9}, { 3.441991269576584*^9, 3.4419912898657584`*^9}, {3.4419913594357953`*^9, 3.4419913599665585`*^9}, {3.4419916651253552`*^9, 3.4419916942272015`*^9}, 3.441991825596101*^9, {3.4419922527002463`*^9, 3.4419922597704124`*^9}, { 3.442075496177314*^9, 3.4420754983804817`*^9}}], Cell[TextData[{ "This is a directory for our test package (", StyleBox["use your test directory here", FontWeight->"Bold", FontSlant->"Italic"], ") :" }], "Text", CellChangeTimes->{{3.441992458335936*^9, 3.4419924631528625`*^9}, { 3.441994091273986*^9, 3.441994116360058*^9}}], Cell[BoxData[ RowBox[{ RowBox[{ "myDir", " ", "=", " ", "\"\\""}], ";"}]], "Input", CellChangeTimes->{{3.441994017157411*^9, 3.4419940333306675`*^9}}], Cell["The name of the file should be this :", "Text", CellChangeTimes->{{3.441994126855149*^9, 3.4419941471443233`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"file", "=", RowBox[{"ToFileName", "[", RowBox[{"myDir", ",", "\"\\""}], "]"}]}], ";"}]], "Input", CellChangeTimes->{{3.4419911289844227`*^9, 3.4419911335409746`*^9}, { 3.4419917019182606`*^9, 3.4419917041414576`*^9}, 3.441993245648035*^9, { 3.441994028243352*^9, 3.441994061721491*^9}}], Cell["\<\ And this is the code of a very simple text - processing package. It \ intentionally has an additional dummy sub-context and an extra variable in \ `Private` sub-context.\ \>", "Text", CellChangeTimes->{{3.4419924698725247`*^9, 3.4419925036510963`*^9}, { 3.4420649003412495`*^9, 3.4420649462572737`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"code", " ", "=", "\[IndentingNewLine]", " ", RowBox[{"Hold", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"Print", "[", "\"\\"", "]"}], ";", "\[IndentingNewLine]", "\t", RowBox[{"BeginPackage", "[", "\"\\"", "]"}], ";", "\[IndentingNewLine]", "\t\t", RowBox[{ RowBox[{"Sentences", "::", "usage"}], " ", "=", "\"\\""}], ";", "\[IndentingNewLine]", "\t\t", RowBox[{ RowBox[{"Words", "::", "usage"}], " ", "=", "\[IndentingNewLine]", "\t\t\t ", "\"\ to words\>\""}], ";", "\[IndentingNewLine]", "\t\t", RowBox[{"Begin", "[", "\"\<`TestSubcontext`\>\"", "]"}], ";", "\[IndentingNewLine]", "\t\t\t", RowBox[{"testVar1", " ", "=", " ", "1"}], ";", "\[IndentingNewLine]", "\t\t", RowBox[{"End", "[", "]"}], ";", "\[IndentingNewLine]", "\t\t", RowBox[{"Begin", "[", "\"\<`Private`\>\"", "]"}], ";", "\[IndentingNewLine]", "\t\t\t", RowBox[{"testVar2", " ", "=", " ", "2"}], ";", "\[IndentingNewLine]", "\t\t\t", RowBox[{ RowBox[{"Sentences", "[", "text_String", "]"}], ":=", "\[IndentingNewLine]", "\t\t\t\t", RowBox[{"StringCases", "[", RowBox[{"text", ",", "\[IndentingNewLine]", "\t\t\t\t\t", RowBox[{"ShortestMatch", "[", "\[IndentingNewLine]", "\t\t\t\t\t\t", RowBox[{ RowBox[{"CharacterRange", "[", RowBox[{"\"\\"", ",", "\"\\""}], "]"}], "~~", "x__", "~~", "\"\<.\>\""}], "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", "\t\t\t", RowBox[{ RowBox[{"Words", "[", "text_String", "]"}], ":=", "\[IndentingNewLine]", "\t\t\t\t", RowBox[{"StringCases", "[", RowBox[{"text", ",", RowBox[{"LetterCharacter", ".."}]}], "]"}]}], ";", "\[IndentingNewLine]", "\t\t", RowBox[{"End", "[", "]"}], ";", "\[IndentingNewLine]", "\t", RowBox[{"EndPackage", "[", "]"}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", "\"\\"", "]"}]}], "\[IndentingNewLine]", "]"}]}], ";"}]], "Input", CellChangeTimes->{{3.441990186118648*^9, 3.441990187540693*^9}, { 3.441990490836811*^9, 3.4419905199186287`*^9}, {3.441990789205845*^9, 3.441990883661666*^9}, 3.441990917139805*^9, 3.44199110624172*^9, 3.4419913764903183`*^9, {3.441991451428074*^9, 3.4419915275475283`*^9}, { 3.441991569788267*^9, 3.4419916013436413`*^9}, {3.4419918043555584`*^9, 3.441991810584515*^9}, {3.4419925783384914`*^9, 3.441992579760536*^9}, { 3.441992690069152*^9, 3.4419926956972446`*^9}, {3.441993109301979*^9, 3.441993148979032*^9}, {3.441993527122776*^9, 3.4419935286449647`*^9}, 3.4419936878138385`*^9, {3.44199482467857*^9, 3.441994881440189*^9}, 3.4419952824568224`*^9, {3.4419953958298445`*^9, 3.4419954119830723`*^9}, { 3.441996140440542*^9, 3.4419961847642765`*^9}, {3.441996226424181*^9, 3.4419962291981697`*^9}, {3.4420625138596573`*^9, 3.4420626093369474`*^9}, {3.4421402097803135`*^9, 3.4421402308305826`*^9}}, FontWeight->"Plain"], Cell["We now convert this code into a package (file) :", "Text", CellChangeTimes->{{3.44206495507996*^9, 3.4420649777225184`*^9}}], Cell[BoxData[ RowBox[{"PackageFromHeldCode", "[", RowBox[{"code", ",", "file"}], "]"}]], "Input", CellChangeTimes->{{3.4419911082846575`*^9, 3.4419911428042946`*^9}, { 3.441991387416029*^9, 3.441991387876691*^9}}], Cell["\<\ You may convince yourself that the file < file > does now indeed contain the \ text of our package.\ \>", "Text", CellChangeTimes->{{3.4419950648338957`*^9, 3.4419950987025967`*^9}}] }, Closed]], Cell[CellGroupData[{ Cell["Package loading, reloading, and the shadowing problem", "Subsection", CellChangeTimes->{{3.441995059135702*^9, 3.4419950594561634`*^9}, { 3.441995112382267*^9, 3.4419951260519233`*^9}}, FontWeight->"Plain"], Cell["\<\ We now let Mathematica know where to look for our new package :\ \>", "Text", CellChangeTimes->{{3.4419925174609537`*^9, 3.441992544630021*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"AppendTo", "[", RowBox[{"$Path", ",", "myDir"}], "]"}], ";"}]], "Input", CellChangeTimes->{{3.441991400735181*^9, 3.44199144031209*^9}, { 3.441994069062046*^9, 3.4419940707745085`*^9}}], Cell["And load it :", "Text", CellChangeTimes->{{3.4419925506787186`*^9, 3.4419925548447084`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Needs", "[", "\"\\"", "]"}]], "Input", CellChangeTimes->{{3.441991443076064*^9, 3.441991444077504*^9}, 3.4419925970954623`*^9}], Cell[BoxData["\<\"The package is being loaded\"\>"], "Print", CellChangeTimes->{3.442139003876309*^9, 3.442140249417309*^9, 3.442141019885187*^9}], Cell[BoxData[ RowBox[{ RowBox[{"Sentences", "::", "\<\"shdw\"\>"}], RowBox[{ ":", " "}], "\<\"Symbol \\!\\(\\\"Sentences\\\"\\) appears in multiple \ contexts \\!\\({\\\"TextStatistics`\\\", \\\"Global`\\\"}\\); definitions in \ context \\!\\(\\\"TextStatistics`\\\"\\) may shadow or be shadowed by other \ definitions. \\!\\(\\*ButtonBox[\\\"\[RightSkeleton]\\\", \ ButtonStyle->\\\"Link\\\", ButtonFrame->None, \ ButtonData:>\\\"paclet:ref/message/General/shdw\\\", ButtonNote -> \ \\\"TextStatistics`Sentences::shdw\\\"]\\)\"\>"}]], "Message", CellChangeTimes->{3.4421390048376913`*^9, 3.4421402500582304`*^9, 3.442141020456008*^9}], Cell[BoxData[ RowBox[{ RowBox[{"Words", "::", "\<\"shdw\"\>"}], RowBox[{ ":", " "}], "\<\"Symbol \\!\\(\\\"Words\\\"\\) appears in multiple contexts \ \\!\\({\\\"TextStatistics`\\\", \\\"Global`\\\"}\\); definitions in context \ \\!\\(\\\"TextStatistics`\\\"\\) may shadow or be shadowed by other \ definitions. \\!\\(\\*ButtonBox[\\\"\[RightSkeleton]\\\", \ ButtonStyle->\\\"Link\\\", ButtonFrame->None, \ ButtonData:>\\\"paclet:ref/message/General/shdw\\\", ButtonNote -> \ \\\"TextStatistics`Words::shdw\\\"]\\)\"\>"}]], "Message", CellChangeTimes->{3.4421390048376913`*^9, 3.4421402500582304`*^9, 3.4421410209667425`*^9}], Cell[BoxData["\<\"The package has been loaded\"\>"], "Print", CellChangeTimes->{3.442139003876309*^9, 3.442140249417309*^9, 3.4421410210067997`*^9}] }, Open ]], Cell[TextData[{ "We immediately see one of the flaws of our package's code: the symbols ", StyleBox["Sentences", FontSlant->"Italic"], " and ", StyleBox["Words", FontSlant->"Italic"], " are actually shadowed! This is so because wrapping code in ", StyleBox["Hold", FontSlant->"Italic"], " does not prevent creation of symbols in the symbol table which happens at \ parse - time (that is, in this case, when we define ", StyleBox["code ", FontSlant->"Italic"], "variable). We will correct this later on the level of the code, but let me \ first demonstrate the functionality of ", StyleBox["PackageManipulations`", FontWeight->"Bold", FontSlant->"Italic"], " which can help remove shadowing symbols after shadowing took place:" }], "Text", CellChangeTimes->{{3.4419933074068403`*^9, 3.441993463150789*^9}, { 3.442041313134512*^9, 3.4420413680534816`*^9}, 3.4420649993035507`*^9, { 3.4420650300277295`*^9, 3.4420650338732595`*^9}, {3.442076544374547*^9, 3.4420765834106784`*^9}}], Cell[TextData[{ "We first attempt to reload the package by using ", StyleBox["PackageReload", FontWeight->"Bold", FontSlant->"Italic"], ":" }], "Text", CellChangeTimes->{{3.4419947095830708`*^9, 3.441994732095442*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"PackageReload", "[", "\"\\"", "]"}]], "Input", CellChangeTimes->{3.44199467503339*^9}], Cell[CellGroupData[{ Cell[BoxData["\<\"The package is being loaded\"\>"], "Print", CellChangeTimes->{3.442139073015726*^9, 3.442140252872277*^9, 3.4421410235805006`*^9}], Cell[BoxData["\<\"The package has been loaded\"\>"], "Print", CellChangeTimes->{3.442139073015726*^9, 3.442140252872277*^9, 3.442141023610544*^9}] }, Open ]] }, Open ]], Cell[TextData[{ "Printed messages indicate that the package has indeed been re-loaded. Of \ course, one could get the same messages simply by using ", StyleBox["Get", FontWeight->"Bold", FontSlant->"Italic"], ". The operation of ", StyleBox["PackageReload", FontWeight->"Bold", FontSlant->"Italic"], " is more subtle than that of ", StyleBox["Get", FontWeight->"Bold", FontSlant->"Italic"], " (which it uses internally) in several aspects. " }], "Text", CellChangeTimes->{{3.4419947384646*^9, 3.4419948181391664`*^9}, { 3.441994950389333*^9, 3.441994969757182*^9}, {3.4420413851480627`*^9, 3.442041417855093*^9}, {3.4420726811995745`*^9, 3.4420727120639553`*^9}, { 3.4420733964881086`*^9, 3.442073399141925*^9}, {3.442073484074051*^9, 3.4420735765670495`*^9}}], Cell[TextData[{ "However, the symbols ", StyleBox["Sentences", FontSlant->"Italic"], " and ", StyleBox["Words", FontSlant->"Italic"], " are still shadowed, as users of v .6.0 + can deduce from the red \ highlighting. In general, testing for shadowing is a trivial (if somewhat \ time-consuming) business:" }], "Text", CellChangeTimes->{{3.4419947384646*^9, 3.4419948181391664`*^9}, { 3.441994950389333*^9, 3.441994969757182*^9}, {3.4420413851480627`*^9, 3.442041417855093*^9}, {3.4420726811995745`*^9, 3.4420727120639553`*^9}, { 3.4420733964881086`*^9, 3.442073399141925*^9}, {3.442073484074051*^9, 3.4420735777387342`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"With", "[", RowBox[{ RowBox[{"{", RowBox[{"contextSeparator", " ", "=", " ", "\"\<`\>\""}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "shortName", "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"shortName", "[", "name_String", "]"}], ":=", "\[IndentingNewLine]", RowBox[{"StringReplace", "[", RowBox[{"name", ",", RowBox[{ RowBox[{ RowBox[{"LongestMatch", "[", RowBox[{"__", "~~", "contextSeparator"}], "]"}], "~~", "x__"}], "\[RuleDelayed]", " ", "x"}]}], "]"}]}], ";", " ", "\[IndentingNewLine]", RowBox[{ RowBox[{"shadowedQ", "[", "sym_Symbol", "]"}], ":=", "\[IndentingNewLine]", RowBox[{"With", "[", RowBox[{ RowBox[{"{", RowBox[{"contexts", " ", "=", "\[IndentingNewLine]", "\t ", RowBox[{"Select", "[", RowBox[{"$ContextPath", ",", "\[IndentingNewLine]", "\t\t", RowBox[{ RowBox[{"MemberQ", "[", RowBox[{ RowBox[{"shortName", "/@", RowBox[{"Names", "[", RowBox[{"#", "<>", "\"\<*\>\""}], "]"}]}], ",", "\[IndentingNewLine]", "\t\t\t", RowBox[{"shortName", "[", RowBox[{"ToString", "[", "sym", "]"}], "]"}]}], "]"}], "&"}]}], "]"}]}], "}"}], ",", "\[IndentingNewLine]", "\t", RowBox[{"Return", "[", RowBox[{ RowBox[{"Length", "[", "contexts", "]"}], ">", "1"}], "]"}]}], "]"}]}]}]}], "]"}]}], "]"}], ";"}]], "Input", CellChangeTimes->{{3.4420727144774256`*^9, 3.442072926271971*^9}, { 3.4420729804298463`*^9, 3.442072981671632*^9}, {3.442073057450597*^9, 3.4420732097896495`*^9}, {3.442073384170397*^9, 3.442073387675437*^9}, { 3.4420814776983185`*^9, 3.4420814997800703`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"shadowedQ", "[", "Sentences", "]"}], "//", "Timing"}]], "Input", CellChangeTimes->{{3.4420729352949457`*^9, 3.4420729469116497`*^9}, { 3.4420730870631776`*^9, 3.442073088765626*^9}, {3.4420731540595136`*^9, 3.4420731549007235`*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{"0.09000000000000007`", ",", "True"}], "}"}]], "Output", CellChangeTimes->{3.4421390846424446`*^9, 3.4421402558064957`*^9, 3.44214102651472*^9}] }, Open ]], Cell[TextData[{ "To remove shadowing symbols in other contexts, use the option ", StyleBox["KillShadowing \[Rule] True", FontWeight->"Bold", FontSlant->"Italic"] }], "Text", CellChangeTimes->{{3.4419947384646*^9, 3.4419948181391664`*^9}, { 3.441994950389333*^9, 3.441994969757182*^9}, {3.4420413851480627`*^9, 3.442041417855093*^9}, {3.4420726811995745`*^9, 3.4420726866273794`*^9}, { 3.4420732763052945`*^9, 3.4420732777573824`*^9}, 3.442076642735984*^9}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"PackageReload", "[", RowBox[{"\"\\"", ",", RowBox[{"KillShadowing", "\[Rule]", " ", "True"}]}], "]"}]], "Input", CellChangeTimes->{{3.4419934711623087`*^9, 3.441993514975309*^9}}], Cell[CellGroupData[{ Cell[BoxData["\<\"The package is being loaded\"\>"], "Print", CellChangeTimes->{3.442139088988694*^9, 3.4421402578694625`*^9, 3.442141029218608*^9}], Cell[BoxData["\<\"The package has been loaded\"\>"], "Print", CellChangeTimes->{3.442139088988694*^9, 3.4421402578694625`*^9, 3.4421410292586656`*^9}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"shadowedQ", "[", "Sentences", "]"}]], "Input", CellChangeTimes->{3.4420734253496094`*^9}], Cell[BoxData["False"], "Output", CellChangeTimes->{3.442139090901445*^9, 3.442140259461752*^9, 3.442141030169976*^9}] }, Open ]], Cell[TextData[{ "Note that the topic of shadowing and how to deal with this problem is not \ the main focus of the package. There exist specialized packages written by \ others which deal specifically with this problem: ", StyleBox["UnShadow`", FontWeight->"Bold", FontSlant->"Italic"], " and ", StyleBox["AntiShadow`", FontWeight->"Bold", FontSlant->"Italic"], "." }], "Text", CellChangeTimes->{{3.4420414318552237`*^9, 3.4420415568048925`*^9}}] }, Closed]], Cell[CellGroupData[{ Cell["Testing our toy package", "Subsection", CellChangeTimes->{{3.4419951787877536`*^9, 3.4419951827935133`*^9}, { 3.4420768340911393`*^9, 3.4420768364044657`*^9}, 3.442076946002059*^9}, FontWeight->"Plain"], Cell[TextData[{ "We can now safely use the functions. Here is our test text (excerpt from \ \"", StyleBox["Emergent design", FontSlant->"Italic"], "\" by Scott Bain) : " }], "Text", CellChangeTimes->{{3.441993534212971*^9, 3.4419935570758467`*^9}, { 3.442076686168437*^9, 3.4420767466854563`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{ "text", " ", "=", " ", "\"\\""}], ";"}]], "Input", CellChangeTimes->{{3.4419890118100753`*^9, 3.441989014744294*^9}, { 3.44198916845532*^9, 3.4419891774782944`*^9}, {3.441989551676365*^9, 3.441989552707848*^9}, {3.4419896184924417`*^9, 3.441989636778736*^9}, { 3.4419898154356318`*^9, 3.441989819811925*^9}}], Cell["We try :", "Text", CellChangeTimes->{{3.441993577224819*^9, 3.4419935795081024`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Sentences", "[", "text", "]"}]], "Input", CellChangeTimes->{{3.441993580749888*^9, 3.4419935837742367`*^9}, { 3.441993652603208*^9, 3.441993657380077*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{"\<\"Writing tests first forces me to examine my understanding of \ the purpose of the class (the question) I am about to create.\"\>", ",", "\<\"It requires exact, detailed understanding because I cannot write \ specific tests with anything less.\"\>", ",", "\<\"It is also a kind of documentation; implementation code records \ syntax and structure, but tests capture the semantics\[LongDash]not what can \ happen, but what is meant to happen under various circumstances.\"\>"}], "}"}]], "Output", CellChangeTimes->{3.4421402623058414`*^9, 3.442141033094181*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Words", "[", "text", "]"}]], "Input", CellChangeTimes->{{3.44199358646811*^9, 3.441993588711336*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{"\<\"Writing\"\>", ",", "\<\"tests\"\>", ",", "\<\"first\"\>", ",", "\<\"forces\"\>", ",", "\<\"me\"\>", ",", "\<\"to\"\>", ",", "\<\"examine\"\>", ",", "\<\"my\"\>", ",", "\<\"understanding\"\>", ",", "\<\"of\"\>", ",", "\<\"the\"\>", ",", "\<\"purpose\"\>", ",", "\<\"of\"\>", ",", "\<\"the\"\>", ",", "\<\"class\"\>", ",", "\<\"the\"\>", ",", "\<\"question\"\>", ",", "\<\"I\"\>", ",", "\<\"am\"\>", ",", "\<\"about\"\>", ",", "\<\"to\"\>", ",", "\<\"create\"\>", ",", "\<\"It\"\>", ",", "\<\"requires\"\>", ",", "\<\"exact\"\>", ",", "\<\"detailed\"\>", ",", "\<\"understanding\"\>", ",", "\<\"because\"\>", ",", "\<\"I\"\>", ",", "\<\"cannot\"\>", ",", "\<\"write\"\>", ",", "\<\"specific\"\>", ",", "\<\"tests\"\>", ",", "\<\"with\"\>", ",", "\<\"anything\"\>", ",", "\<\"less\"\>", ",", "\<\"It\"\>", ",", "\<\"is\"\>", ",", "\<\"also\"\>", ",", "\<\"a\"\>", ",", "\<\"kind\"\>", ",", "\<\"of\"\>", ",", "\<\"documentation\"\>", ",", "\<\"implementation\"\>", ",", "\<\"code\"\>", ",", "\<\"records\"\>", ",", "\<\"syntax\"\>", ",", "\<\"and\"\>", ",", "\<\"structure\"\>", ",", "\<\"but\"\>", ",", "\<\"tests\"\>", ",", "\<\"capture\"\>", ",", "\<\"the\"\>", ",", "\<\"semantics\"\>", ",", "\<\"not\"\>", ",", "\<\"what\"\>", ",", "\<\"can\"\>", ",", "\<\"happen\"\>", ",", "\<\"but\"\>", ",", "\<\"what\"\>", ",", "\<\"is\"\>", ",", "\<\"meant\"\>", ",", "\<\"to\"\>", ",", "\<\"happen\"\>", ",", "\<\"under\"\>", ",", "\<\"various\"\>", ",", "\<\"circumstances\"\>"}], "}"}]], "Output", CellChangeTimes->{3.4421402633573537`*^9, 3.4421410345462685`*^9}] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["\<\ Removing or clearing the package's main context and possibly also \ sub-contexts\ \>", "Subsection", CellChangeTimes->{{3.441995213377491*^9, 3.4419952500902815`*^9}, { 3.441996420433152*^9, 3.4419964652576065`*^9}}, FontWeight->"Plain"], Cell["\<\ First, let us remove the package' s context and all names in it form the \ symbol table :\ \>", "Text", CellChangeTimes->{{3.441993794827717*^9, 3.441993843257355*^9}, 3.4420411378524685`*^9}], Cell[BoxData[ RowBox[{"PackageRemove", "[", "\"\\"", "]"}]], "Input", CellChangeTimes->{{3.441993845460523*^9, 3.44199385560511*^9}}], Cell["Now :", "Text", CellChangeTimes->{{3.441995261316424*^9, 3.441995263139045*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Names", "[", "\"\\"", "]"}]], "Input", CellChangeTimes->{{3.441995264701291*^9, 3.441995270539686*^9}, 3.441995333670464*^9}], Cell[BoxData[ RowBox[{"{", "}"}]], "Output", CellChangeTimes->{3.442139098061741*^9, 3.4421402658609533`*^9, 3.4421410377008047`*^9}] }, Open ]], Cell[TextData[{ "We can also check that the context of the package is no longer in either ", StyleBox["$Packages", FontSlant->"Italic"], " or ", StyleBox["$ContextPath", FontSlant->"Italic"], " :" }], "Text", CellChangeTimes->{{3.44199555639072*^9, 3.441995586954669*^9}}], Cell[CellGroupData[{ Cell[BoxData["$Packages"], "Input", CellChangeTimes->{{3.441995535961344*^9, 3.4419955381044254`*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{"\<\"PackageManipulations`\"\>", ",", "\<\"JLink`\"\>", ",", "\<\"PacletManager`\"\>", ",", "\<\"WebServices`\"\>", ",", "\<\"System`\"\>", ",", "\<\"Global`\"\>"}], "}"}]], "Output", CellChangeTimes->{3.4421390991833534`*^9, 3.44214026717284*^9, 3.4421410387423024`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData["$ContextPath"], "Input", CellChangeTimes->{{3.4419955447840304`*^9, 3.4419955478884945`*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{"\<\"PackageManipulations`\"\>", ",", "\<\"PacletManager`\"\>", ",", "\<\"WebServices`\"\>", ",", "\<\"System`\"\>", ",", "\<\"Global`\"\>"}], "}"}]], "Output", CellChangeTimes->{3.4421391016869535`*^9, 3.442140268374568*^9, 3.442141040224434*^9}] }, Open ]], Cell[TextData[{ "We can perform a more mild operation with ", StyleBox["PackageClear", FontWeight->"Bold", FontSlant->"Italic"], " - clear all the names of all symbols but keep the package' s context and \ symbol names in the system :" }], "Text", CellChangeTimes->{{3.4419956512971888`*^9, 3.441995701919981*^9}, { 3.441995746534133*^9, 3.4419957508603535`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"PackageReload", "[", RowBox[{"\"\\"", ",", RowBox[{"KillShadowing", "\[Rule]", " ", "True"}]}], "]"}]], "Input", CellChangeTimes->{{3.4419957094207664`*^9, 3.4419957172119694`*^9}, { 3.4421413418882046`*^9, 3.44214134797696*^9}}], Cell[CellGroupData[{ Cell[BoxData["\<\"The package is being loaded\"\>"], "Print", CellChangeTimes->{ 3.442139110589755*^9, 3.442140270597765*^9, 3.4421410428281775`*^9, 3.4421412835242815`*^9, {3.4421413492588034`*^9, 3.4421413680458174`*^9}}],\ Cell[BoxData["\<\"The package has been loaded\"\>"], "Print", CellChangeTimes->{ 3.442139110589755*^9, 3.442140270597765*^9, 3.4421410428281775`*^9, 3.4421412835242815`*^9, {3.4421413492588034`*^9, 3.442141368075861*^9}}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"{", RowBox[{"$Packages", ",", "$ContextPath"}], "}"}]], "Input", CellChangeTimes->{{3.4419957286484146`*^9, 3.4419957357285953`*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"\<\"TextStatistics`\"\>", ",", "\<\"PackageManipulations`\"\>", ",", "\<\"JLink`\"\>", ",", "\<\"PacletManager`\"\>", ",", "\<\"WebServices`\"\>", ",", "\<\"System`\"\>", ",", "\<\"Global`\"\>"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"TextStatistics`\"\>", ",", "\<\"PackageManipulations`\"\>", ",", "\<\"PacletManager`\"\>", ",", "\<\"WebServices`\"\>", ",", "\<\"System`\"\>", ",", "\<\"Global`\"\>"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.442139112382333*^9, 3.4421402714590034`*^9, 3.4421410447709713`*^9, 3.442141285647334*^9}] }, Open ]], Cell[BoxData[ RowBox[{"PackageClear", "[", "\"\\"", "]"}]], "Input", CellChangeTimes->{{3.441995740515478*^9, 3.441995758751701*^9}}], Cell["The package' s context is still there :", "Text", CellChangeTimes->{{3.441995859256219*^9, 3.4419958692305613`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"{", RowBox[{"$Packages", ",", "$ContextPath"}], "}"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"\<\"TextStatistics`\"\>", ",", "\<\"PackageManipulations`\"\>", ",", "\<\"JLink`\"\>", ",", "\<\"PacletManager`\"\>", ",", "\<\"WebServices`\"\>", ",", "\<\"System`\"\>", ",", "\<\"Global`\"\>"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"TextStatistics`\"\>", ",", "\<\"PackageManipulations`\"\>", ",", "\<\"PacletManager`\"\>", ",", "\<\"WebServices`\"\>", ",", "\<\"System`\"\>", ",", "\<\"Global`\"\>"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.4421391153566093`*^9, 3.4421402737523007`*^9, 3.4421410476551185`*^9, 3.442141288000718*^9}] }, Open ]], Cell["And the symbols are present still:", "Text", CellChangeTimes->{{3.441995837745288*^9, 3.441995844655224*^9}, { 3.4419958754094467`*^9, 3.4419958798858833`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Names", "[", "\"\\"", "]"}]], "Input", CellChangeTimes->{{3.4419957685557985`*^9, 3.4419957808234386`*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{"\<\"Sentences\"\>", ",", "\<\"Words\"\>"}], "}"}]], "Output", CellChangeTimes->{3.442139117149187*^9, 3.442140275004101*^9, 3.4421410497381134`*^9, 3.442141290964981*^9}] }, Open ]], Cell["But they have been completely cleared :", "Text", CellChangeTimes->{{3.4419957976977024`*^9, 3.441995820400347*^9}, 3.44199585356804*^9}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"??", " ", "Sentences"}]], "Input", CellChangeTimes->{{3.4419957841281905`*^9, 3.4419958106262927`*^9}}], Cell["TextStatistics`Sentences", "Print", "PrintUsage", CellChangeTimes->{3.442141293078019*^9}, CellTags->"Info3442112492-1059804"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"??", "Words"}]], "Input", CellChangeTimes->{{3.4419957915688896`*^9, 3.4419958139310446`*^9}}], Cell["TextStatistics`Words", "Print", "PrintUsage", CellChangeTimes->{3.4421412938992*^9}, CellTags->"Info3442112493-8549421"] }, Open ]], Cell["\<\ Note however, that while we removed (or cleared) the main context, we did not \ remove (or even clear) the sub - contexts. Here they are:\ \>", "Text", CellChangeTimes->{{3.4419953510454483`*^9, 3.441995361730813*^9}, { 3.4419954636974335`*^9, 3.4419954854787536`*^9}, {3.441995892013322*^9, 3.4419958961793118`*^9}, {3.441996286550638*^9, 3.441996291567853*^9}, { 3.442141061765408*^9, 3.4421410664521475`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Select", "[", RowBox[{ RowBox[{"Contexts", "[", "]"}], ",", RowBox[{ RowBox[{"StringMatchQ", "[", RowBox[{"#", ",", RowBox[{"\"\\"", "~~", "__"}]}], "]"}], "&"}]}], "]"}]], "Input", CellChangeTimes->{3.442141264707224*^9}], Cell[BoxData[ RowBox[{"{", RowBox[{"\<\"TextStatistics`Private`\"\>", ",", "\<\"TextStatistics`TestSubcontext`\"\>"}], "}"}]], "Output", CellChangeTimes->{ 3.4421391214053073`*^9, 3.4421402789998465`*^9, {3.4421410546451693`*^9, 3.4421410696166973`*^9}, 3.442141297103808*^9, 3.4421413762375965`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Names", "[", "\"\\"", "]"}]], "Input", CellChangeTimes->{{3.441995344125498*^9, 3.441995346538968*^9}, { 3.441996329181939*^9, 3.441996333608304*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{"\<\"TextStatistics`Private`testVar2\"\>", ",", "\<\"TextStatistics`Private`text\"\>", ",", "\<\"TextStatistics`Private`x\"\>"}], "}"}]], "Output", CellChangeTimes->{3.4421391228874383`*^9, 3.442140279550638*^9, 3.4421410707282963`*^9, 3.442141380293429*^9}] }, Open ]], Cell["Moreover, some of the private variables have values :", "Text", CellChangeTimes->{{3.4419955070898285`*^9, 3.4419955234133005`*^9}, { 3.4420756249024115`*^9, 3.4420756274260397`*^9}, {3.4421315457420387`*^9, 3.442131556827979*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"ToExpression", "/@", RowBox[{"Names", "[", "\"\\"", "]"}]}]], "Input",\ CellChangeTimes->{{3.4419954937907057`*^9, 3.441995501381621*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ "2", ",", "TextStatistics`Private`text", ",", "TextStatistics`Private`x"}], "}"}]], "Output", CellChangeTimes->{3.4421391267529964`*^9, 3.442140281012741*^9, 3.442141072110283*^9, 3.4421413818456607`*^9}] }, Open ]], Cell[TextData[{ "To clear (but not remove) the context together with all sub - contexts, use \ ", StyleBox["PackageClearComplete. ", FontWeight->"Bold", FontSlant->"Italic"], "We first remove and reload the package:" }], "Text", CellChangeTimes->{{3.4419955283504*^9, 3.4419955290213647`*^9}, { 3.441995597880379*^9, 3.4419956318191805`*^9}, {3.4419959052824016`*^9, 3.4419959133840513`*^9}, {3.4420745402828045`*^9, 3.4420745558451824`*^9}}],\ Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{ RowBox[{"PackageRemove", "[", "\"\\"", "]"}], ";"}], "\[IndentingNewLine]", RowBox[{"PackageReload", "[", "\"\\"", "]"}]}], "Input", CellChangeTimes->{{3.442074490941856*^9, 3.442074501106472*^9}}], Cell[CellGroupData[{ Cell[BoxData["\<\"The package is being loaded\"\>"], "Print", CellChangeTimes->{3.442139128665747*^9, 3.442140282675131*^9, 3.4421410742533646`*^9}], Cell[BoxData["\<\"The package has been loaded\"\>"], "Print", CellChangeTimes->{3.442139128665747*^9, 3.442140282675131*^9, 3.4421410742733936`*^9}] }, Open ]] }, Open ]], Cell["Then we clear it with all sub - contexts :", "Text", CellChangeTimes->{{3.4420745581484947`*^9, 3.442074570606408*^9}}], Cell[BoxData[ RowBox[{"PackageClearComplete", "[", "\"\\"", "]"}]], "Input", CellChangeTimes->{{3.4419959287461405`*^9, 3.4419959397519665`*^9}}], Cell["Now the symbols are still there, but without any values:", "Text", CellChangeTimes->{{3.441995942576027*^9, 3.4419959432670207`*^9}, { 3.4420756498182383`*^9, 3.4420756624964685`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"ToExpression", "/@", RowBox[{"Names", "[", "\"\\"", "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ "TextStatistics`Private`testVar2", ",", "TextStatistics`Private`text", ",", "TextStatistics`Private`x"}], "}"}]], "Output", CellChangeTimes->{3.442139131439736*^9, 3.4421402849884577`*^9, 3.442141077237656*^9}] }, Open ]], Cell[TextData[{ "To remove the context and all its sub-contexts, use ", StyleBox["PackageClearComplete", FontWeight->"Bold", FontSlant->"Italic"], " with the ", StyleBox["RemovePackage -> True", FontWeight->"Bold", FontSlant->"Italic"], " option :" }], "Text", CellChangeTimes->{{3.4419959520496497`*^9, 3.4419959837352114`*^9}, 3.4421394216270046`*^9}], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{ RowBox[{"PackageRemove", "[", "\"\\"", "]"}], ";"}], "\[IndentingNewLine]", RowBox[{"PackageReload", "[", "\"\\"", "]"}]}], "Input", CellChangeTimes->{3.4420746019614944`*^9}], Cell[CellGroupData[{ Cell[BoxData["\<\"The package is being loaded\"\>"], "Print", CellChangeTimes->{3.442139134263797*^9, 3.4421402867409773`*^9, 3.4421410787298017`*^9}], Cell[BoxData["\<\"The package has been loaded\"\>"], "Print", CellChangeTimes->{3.442139134263797*^9, 3.4421402867409773`*^9, 3.4421410787498302`*^9}] }, Open ]] }, Open ]], Cell[BoxData[ RowBox[{"PackageClearComplete", "[", RowBox[{"\"\\"", ",", RowBox[{"RemovePackage", "\[Rule]", " ", "True"}]}], "]"}]], "Input", CellChangeTimes->{{3.44199601129484*^9, 3.441996018415078*^9}}], Cell["Now :", "Text", CellChangeTimes->{{3.4419960207484336`*^9, 3.4419960216998014`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"{", RowBox[{"$Packages", ",", "$ContextPath"}], "}"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"\<\"PackageManipulations`\"\>", ",", "\<\"JLink`\"\>", ",", "\<\"PacletManager`\"\>", ",", "\<\"WebServices`\"\>", ",", "\<\"System`\"\>", ",", "\<\"Global`\"\>"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"PackageManipulations`\"\>", ",", "\<\"PacletManager`\"\>", ",", "\<\"WebServices`\"\>", ",", "\<\"System`\"\>", ",", "\<\"Global`\"\>"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.4421391444484415`*^9, 3.442140289164462*^9, 3.4421410814036465`*^9}] }, Open ]], Cell["\<\ We can see in a general way that no (sub) contexts of our context are present \ :\ \>", "Text", CellChangeTimes->{{3.4419960952755985`*^9, 3.441996129294515*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Select", "[", RowBox[{ RowBox[{"Contexts", "[", "]"}], ",", RowBox[{ RowBox[{"StringMatchQ", "[", RowBox[{"#", ",", RowBox[{"\"\\"", "~~", "___"}]}], "]"}], "&"}]}], "]"}]], "Input", CellChangeTimes->{{3.4419960534053917`*^9, 3.441996101124008*^9}}], Cell[BoxData[ RowBox[{"{", "}"}]], "Output", CellChangeTimes->{3.4421391487045617`*^9, 3.4421402914477453`*^9, 3.442141083116109*^9}] }, Open ]], Cell["\<\ In particular, Needs can be called again to load the package :\ \>", "Text", CellChangeTimes->{{3.4420415958610525`*^9, 3.442041615709594*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Needs", "[", "\"\\"", "]"}]], "Input", CellChangeTimes->{{3.4420416208770237`*^9, 3.442041627055909*^9}}], Cell[CellGroupData[{ Cell[BoxData["\<\"The package is being loaded\"\>"], "Print", CellChangeTimes->{3.442139150517168*^9, 3.4421402927496176`*^9, 3.44214108459824*^9}], Cell[BoxData["\<\"The package has been loaded\"\>"], "Print", CellChangeTimes->{3.442139150517168*^9, 3.4421402927496176`*^9, 3.4421410846282835`*^9}] }, Open ]] }, Open ]], Cell[BoxData[ RowBox[{"PackageClearComplete", "[", RowBox[{"\"\\"", ",", RowBox[{"RemovePackage", "\[Rule]", " ", "True"}]}], "]"}]], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Detecting the missing usage messages", "Subsection", CellChangeTimes->{{3.442053028139862*^9, 3.4420530419096622`*^9}}, FontWeight->"Plain"], Cell[TextData[{ "The ", StyleBox["PackageManipulations`", FontWeight->"Bold", FontSlant->"Italic"], " package (specifically, ", StyleBox["PackageReload", FontWeight->"Bold", FontSlant->"Italic"], " command) incorporates the functionality similar to that provided by ", StyleBox["EscapingSymbols`", FontWeight->"Bold", FontSlant->"Italic"], " package. ", StyleBox["PackageReload", FontWeight->"Bold", FontSlant->"Italic"], " can detect: \n", StyleBox["1. ", FontWeight->"Bold"], "Symbols that were \"leaking\" into the user' s context without having usage \ messages attached\n", StyleBox["2.", FontWeight->"Bold"], " Symbols that still don't have the usage messages after the package has \ been reloaded\n", StyleBox["3.", FontWeight->"Bold"], " Symbols that did have usage messages before reloading but have them no \ longer. \n\nWhile the former 2 cases may indicate a bug (or, possibly, \ carelessness) in the original package, the latter may be a result of changing \ a public interface of the package so that some symbols are no longer used, or \ at least, no longer public. The ", StyleBox["PackageReload", FontWeight->"Bold", FontSlant->"Italic"], " does not take any action towards these symbols, but just merely reports \ them to the user." }], "Text", CellChangeTimes->{{3.442053050001298*^9, 3.442053291238179*^9}, { 3.442053333238573*^9, 3.4420533697110176`*^9}, {3.4420651214692163`*^9, 3.442065223545995*^9}, 3.442074641528389*^9}], Cell[CellGroupData[{ Cell["\<\ The case of symbols lacking usage messages in the original package\ \>", "Subsubsection", CellChangeTimes->{{3.4420538056178207`*^9, 3.442053848789899*^9}, { 3.4420633044965377`*^9, 3.4420633362421856`*^9}}, FontWeight->"Plain"], Cell[BoxData[ RowBox[{ RowBox[{"PackageClearComplete", "[", RowBox[{"\"\\"", ",", RowBox[{"RemovePackage", "\[Rule]", " ", "True"}]}], "]"}], ";"}]], "Input", CellChangeTimes->{3.442062803155645*^9}], Cell["\<\ Here we will deliberately \"forget\" the user message for one of our symbols \ but will nevertheless make the symbol visible. \ \>", "Text", CellChangeTimes->{{3.4420621025682497`*^9, 3.442062149445656*^9}, { 3.442075284833416*^9, 3.4420753261828737`*^9}, 3.442075783220061*^9}], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"code", " ", "=", "\[IndentingNewLine]", " ", RowBox[{"Hold", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"Print", "[", "\"\\"", "]"}], ";", "\[IndentingNewLine]", "\t", RowBox[{"BeginPackage", "[", "\"\\"", "]"}], ";", " ", "\[IndentingNewLine]", "\t", "Sentences", ";", " ", RowBox[{"(*", " ", RowBox[{"No", " ", "usage", " ", RowBox[{"message", "!"}]}], " ", "*)"}], "\[IndentingNewLine]", "\t", RowBox[{ RowBox[{"Words", "::", "usage"}], " ", "=", "\[IndentingNewLine]", "\t ", "\"\ to words\>\""}], ";", "\[IndentingNewLine]", "\t\t", RowBox[{"Begin", "[", "\"\<`TestSubcontext`\>\"", "]"}], ";", "\[IndentingNewLine]", "\t\t\t", RowBox[{"testVar1", " ", "=", " ", "1"}], ";", "\[IndentingNewLine]", "\t\t", RowBox[{"End", "[", "]"}], ";", "\[IndentingNewLine]", "\t\t", RowBox[{"Begin", "[", "\"\<`Private`\>\"", "]"}], ";", "\[IndentingNewLine]", "\t\t\t", RowBox[{"testVar2", " ", "=", " ", "2"}], ";", "\[IndentingNewLine]", "\t\t\t", RowBox[{ RowBox[{"Sentences", "[", "text_String", "]"}], ":=", "\[IndentingNewLine]", "\t\t\t\t", RowBox[{"StringCases", "[", RowBox[{"text", ",", "\[IndentingNewLine]", "\t\t\t\t\t", RowBox[{ "ShortestMatch", "[", "\[IndentingNewLine]", "\t\t\t\t\t\t", RowBox[{ RowBox[{"CharacterRange", "[", RowBox[{"\"\\"", ",", "\"\\""}], "]"}], "~~", "x__", "~~", "\"\<.\>\""}], "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", "\t\t\t", RowBox[{ RowBox[{"Words", "[", "text_String", "]"}], ":=", "\[IndentingNewLine]", "\t\t\t\t", RowBox[{"StringCases", "[", RowBox[{"text", ",", RowBox[{"LetterCharacter", ".."}]}], "]"}]}], ";", "\[IndentingNewLine]", "\t\t", RowBox[{"End", "[", "]"}], ";", "\[IndentingNewLine]", "\t", RowBox[{"EndPackage", "[", "]"}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", "\"\\"", "]"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], "\[IndentingNewLine]"}]], "Input",\ CellChangeTimes->{{3.441990186118648*^9, 3.441990187540693*^9}, { 3.441990490836811*^9, 3.4419905199186287`*^9}, {3.441990789205845*^9, 3.441990883661666*^9}, 3.441990917139805*^9, 3.44199110624172*^9, 3.4419913764903183`*^9, {3.441991451428074*^9, 3.4419915275475283`*^9}, { 3.441991569788267*^9, 3.4419916013436413`*^9}, {3.4419918043555584`*^9, 3.441991810584515*^9}, {3.4419925783384914`*^9, 3.441992579760536*^9}, { 3.441992690069152*^9, 3.4419926956972446`*^9}, {3.441993109301979*^9, 3.441993148979032*^9}, {3.441993527122776*^9, 3.4419935286449647`*^9}, 3.4419936878138385`*^9, {3.44199482467857*^9, 3.441994881440189*^9}, 3.4419952824568224`*^9, {3.4419953958298445`*^9, 3.4419954119830723`*^9}, { 3.441996140440542*^9, 3.4419961847642765`*^9}, {3.441996226424181*^9, 3.4419962291981697`*^9}, {3.442062182373003*^9, 3.4420623115687776`*^9}, { 3.442075330539138*^9, 3.442075345831126*^9}, {3.442075392688504*^9, 3.442075401300888*^9}, {3.4420754343484077`*^9, 3.442075452123968*^9}, { 3.4420757874060802`*^9, 3.4420757941858287`*^9}}, FontWeight->"Plain"], Cell["We prepare our package :", "Text", CellChangeTimes->{{3.4420623198306575`*^9, 3.4420623305160227`*^9}}], Cell[BoxData[ RowBox[{"PackageFromHeldCode", "[", RowBox[{"code", ",", "file"}], "]"}]], "Input", CellChangeTimes->{{3.4420749930738864`*^9, 3.442074996188365*^9}, { 3.442075350387678*^9, 3.442075382593989*^9}, {3.442075848874467*^9, 3.4420758490847692`*^9}}], Cell["And load it :", "Text", CellChangeTimes->{{3.4420623473001566`*^9, 3.442062349703613*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Needs", "[", "\"\\"", "]"}]], "Input", CellChangeTimes->{{3.442062814622133*^9, 3.4420628218525295`*^9}}], Cell[BoxData["\<\"The package is being loaded\"\>"], "Print", CellChangeTimes->{3.44213916524835*^9, 3.442140302283326*^9, 3.442141101422432*^9}], Cell[BoxData[ RowBox[{ RowBox[{"Sentences", "::", "\<\"shdw\"\>"}], RowBox[{ ":", " "}], "\<\"Symbol \\!\\(\\\"Sentences\\\"\\) appears in multiple \ contexts \\!\\({\\\"TextStatistics`\\\", \\\"Global`\\\"}\\); definitions in \ context \\!\\(\\\"TextStatistics`\\\"\\) may shadow or be shadowed by other \ definitions. \\!\\(\\*ButtonBox[\\\"\[RightSkeleton]\\\", \ ButtonStyle->\\\"Link\\\", ButtonFrame->None, \ ButtonData:>\\\"paclet:ref/message/General/shdw\\\", ButtonNote -> \ \\\"TextStatistics`Sentences::shdw\\\"]\\)\"\>"}]], "Message", CellChangeTimes->{3.4421391652783937`*^9, 3.442140302303355*^9, 3.4421411014624896`*^9}], Cell[BoxData[ RowBox[{ RowBox[{"Words", "::", "\<\"shdw\"\>"}], RowBox[{ ":", " "}], "\<\"Symbol \\!\\(\\\"Words\\\"\\) appears in multiple contexts \ \\!\\({\\\"TextStatistics`\\\", \\\"Global`\\\"}\\); definitions in context \ \\!\\(\\\"TextStatistics`\\\"\\) may shadow or be shadowed by other \ definitions. \\!\\(\\*ButtonBox[\\\"\[RightSkeleton]\\\", \ ButtonStyle->\\\"Link\\\", ButtonFrame->None, \ ButtonData:>\\\"paclet:ref/message/General/shdw\\\", ButtonNote -> \ \\\"TextStatistics`Words::shdw\\\"]\\)\"\>"}]], "Message", CellChangeTimes->{3.4421391652783937`*^9, 3.442140302303355*^9, 3.4421411015325904`*^9}], Cell[BoxData["\<\"The package has been loaded\"\>"], "Print", CellChangeTimes->{3.44213916524835*^9, 3.442140302283326*^9, 3.4421411016127057`*^9}] }, Open ]], Cell[TextData[{ " We now reload the package. Since we did not yet solve the shadowing \ problem, the option ", StyleBox["KillShadowing -> True", FontWeight->"Bold", FontSlant->"Italic"], " is again necessary here:" }], "Text", CellChangeTimes->{{3.442062832297549*^9, 3.4420629095786734`*^9}, 3.4420652633732643`*^9, {3.4420756911576815`*^9, 3.4420757257774625`*^9}, { 3.442075806153037*^9, 3.442075839601133*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"PackageReload", "[", RowBox[{"\"\\"", ",", RowBox[{"KillShadowing", "\[Rule]", " ", "True"}]}], "]"}]], "Input", CellChangeTimes->{{3.442075729703107*^9, 3.442075729923424*^9}, { 3.4420758754426703`*^9, 3.4420758808003745`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"PackageReload", "::", "\<\"unusedold\"\>"}], RowBox[{ ":", " "}], "\<\"Warning: PackageReload discovered that the following \ symbols: \\!\\({Sentences}\\) did not have usage messages (before reloading) \ \"\>"}]], "Message", CellChangeTimes->{3.442139168222627*^9, 3.44214030472684*^9, 3.4421411043165936`*^9}], Cell[CellGroupData[{ Cell[BoxData["\<\"The package is being loaded\"\>"], "Print", CellChangeTimes->{3.4421391688835773`*^9, 3.442140305357747*^9, 3.4421411049675293`*^9}], Cell[BoxData["\<\"The package has been loaded\"\>"], "Print", CellChangeTimes->{3.4421391688835773`*^9, 3.442140305357747*^9, 3.4421411050075874`*^9}] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"PackageReload", "::", "\<\"unused\"\>"}], RowBox[{ ":", " "}], "\<\"Warning: the following symbols: \\!\\({Sentences}\\) still \ don't have usage messages, after the package has been reloaded\"\>"}]], \ "Message", CellChangeTimes->{3.442139168222627*^9, 3.44214030472684*^9, 3.442141105868826*^9}] }, Open ]], Cell[TextData[{ "This time, however, one of the symbols (", StyleBox["Sentences", FontSlant->"Italic"], ") is in the user context but lacks usage message. This causes the warning \ messages. There are 2 explanations: either the symbol is rightfully in the \ user context but the developer forgot to write a usage message (our case), or \ some symbol \"leaked\" through to the user context without any right to be \ there (a real bug). In the former case, the proper usage message has to be \ added, in the latter one has to debug the package." }], "Text", CellChangeTimes->{{3.4420629219164143`*^9, 3.442062998396387*^9}, { 3.4420630889866495`*^9, 3.442063097669134*^9}, {3.442063142022912*^9, 3.4420632723903713`*^9}}] }, Closed]], Cell[CellGroupData[{ Cell["Adding a usage message", "Subsubsection", CellChangeTimes->{{3.442063364062189*^9, 3.4420633706616783`*^9}}, FontWeight->"Plain"], Cell[" We now correct this:", "Text", CellChangeTimes->{{3.4420629219164143`*^9, 3.442062998396387*^9}, { 3.4420630889866495`*^9, 3.442063097669134*^9}, {3.442063142022912*^9, 3.44206323410532*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"code", " ", "=", "\[IndentingNewLine]", " ", RowBox[{"Hold", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"Print", "[", "\"\\"", "]"}], ";", "\[IndentingNewLine]", "\t", RowBox[{"BeginPackage", "[", "\"\\"", "]"}], ";", " ", "\[IndentingNewLine]", "\t\t", RowBox[{ RowBox[{"Sentences", "::", "usage"}], " ", "=", " ", "\"\\""}], ";", "\[IndentingNewLine]", "\t\t", RowBox[{ RowBox[{"Words", "::", "usage"}], " ", "=", "\[IndentingNewLine]", "\t\t\t ", "\"\ to words\>\""}], ";", "\[IndentingNewLine]", "\t\t", RowBox[{"Begin", "[", "\"\<`TestSubcontext`\>\"", "]"}], ";", "\[IndentingNewLine]", "\t\t\t", RowBox[{"testVar1", " ", "=", " ", "1"}], ";", "\[IndentingNewLine]", "\t\t", RowBox[{"End", "[", "]"}], ";", "\[IndentingNewLine]", "\t\t", RowBox[{"Begin", "[", "\"\<`Private`\>\"", "]"}], ";", "\[IndentingNewLine]", "\t\t\t", RowBox[{"testVar2", " ", "=", " ", "2"}], ";", "\[IndentingNewLine]", "\t\t\t", RowBox[{ RowBox[{"Sentences", "[", "text_String", "]"}], ":=", "\[IndentingNewLine]", "\t\t\t\t", RowBox[{"StringCases", "[", RowBox[{"text", ",", "\[IndentingNewLine]", "\t\t\t\t\t", RowBox[{"ShortestMatch", "[", "\[IndentingNewLine]", "\t\t\t\t\t\t", RowBox[{ RowBox[{"CharacterRange", "[", RowBox[{"\"\\"", ",", "\"\\""}], "]"}], "~~", "x__", "~~", "\"\<.\>\""}], "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", "\t\t\t", RowBox[{ RowBox[{"Words", "[", "text_String", "]"}], ":=", "\[IndentingNewLine]", "\t\t\t\t", RowBox[{"StringCases", "[", RowBox[{"text", ",", RowBox[{"LetterCharacter", ".."}]}], "]"}]}], ";", "\[IndentingNewLine]", "\t\t", RowBox[{"End", "[", "]"}], ";", "\[IndentingNewLine]", "\t", RowBox[{"EndPackage", "[", "]"}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", "\"\\"", "]"}]}], "\[IndentingNewLine]", "]"}]}], ";"}]], "Input", CellChangeTimes->{{3.441990186118648*^9, 3.441990187540693*^9}, { 3.441990490836811*^9, 3.4419905199186287`*^9}, {3.441990789205845*^9, 3.441990883661666*^9}, 3.441990917139805*^9, 3.44199110624172*^9, 3.4419913764903183`*^9, {3.441991451428074*^9, 3.4419915275475283`*^9}, { 3.441991569788267*^9, 3.4419916013436413`*^9}, {3.4419918043555584`*^9, 3.441991810584515*^9}, {3.4419925783384914`*^9, 3.441992579760536*^9}, { 3.441992690069152*^9, 3.4419926956972446`*^9}, {3.441993109301979*^9, 3.441993148979032*^9}, {3.441993527122776*^9, 3.4419935286449647`*^9}, 3.4419936878138385`*^9, {3.44199482467857*^9, 3.441994881440189*^9}, 3.4419952824568224`*^9, {3.4419953958298445`*^9, 3.4419954119830723`*^9}, { 3.441996140440542*^9, 3.4419961847642765`*^9}, {3.441996226424181*^9, 3.4419962291981697`*^9}, {3.442062182373003*^9, 3.4420623115687776`*^9}, { 3.4420630760180016`*^9, 3.4420630844501266`*^9}, {3.442139188311514*^9, 3.4421392389443197`*^9}}, FontWeight->"Plain"], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{ RowBox[{"PackageFromHeldCode", "[", RowBox[{"code", ",", "file"}], "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"PackageReload", "[", RowBox[{"\"\\"", ",", RowBox[{"KillShadowing", "\[Rule]", " ", "True"}]}], "]"}], ";"}]}], "Input", CellChangeTimes->{{3.442063494269418*^9, 3.4420635308019485`*^9}, { 3.442063595845477*^9, 3.4420636064507265`*^9}, {3.4420636716544847`*^9, 3.442063674158085*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"PackageReload", "::", "\<\"unusedold\"\>"}], RowBox[{ ":", " "}], "\<\"Warning: PackageReload discovered that the following \ symbols: \\!\\({Sentences}\\) did not have usage messages (before reloading) \ \"\>"}]], "Message", CellChangeTimes->{3.442139246154688*^9, 3.4421403109557967`*^9, 3.4421411116070766`*^9}], Cell[CellGroupData[{ Cell[BoxData["\<\"The package is being loaded\"\>"], "Print", CellChangeTimes->{3.442139246875725*^9, 3.4421403115967183`*^9, 3.4421411123281136`*^9}], Cell[BoxData["\<\"The package has been loaded\"\>"], "Print", CellChangeTimes->{3.442139246875725*^9, 3.4421403115967183`*^9, 3.4421411123581567`*^9}] }, Open ]] }, Open ]], Cell[TextData[{ "This time, no message was generated after the package has been reloaded, \ since the symbol ", StyleBox["Sentences", FontSlant->"Italic"], " acquired its usage message." }], "Text", CellChangeTimes->{{3.442063694497331*^9, 3.442063745660901*^9}, { 3.4421414672084064`*^9, 3.442141467669069*^9}}] }, Closed]], Cell[CellGroupData[{ Cell["\<\ The case of removal of some symbols from the new (reloaded) version of the \ package\ \>", "Subsubsection", CellChangeTimes->{{3.442053807380355*^9, 3.4420538079111185`*^9}, { 3.442053853646883*^9, 3.4420538849919553`*^9}}, FontWeight->"Plain"], Cell[TextData[{ "This section requires that the previous 2 have been executed before it. In \ this example, we remove the function ", StyleBox["Sentences", FontSlant->"Italic"], " from our package, together with its usage message (some other code \ irrelevant to this section has been removed too) : " }], "Text", CellChangeTimes->{{3.4420533814579086`*^9, 3.442053411921714*^9}, { 3.442063792287947*^9, 3.4420638424901342`*^9}, {3.4420653130146446`*^9, 3.442065349727435*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"code", " ", "=", "\[IndentingNewLine]", " ", RowBox[{"Hold", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"Print", "[", "\"\\"", "]"}], ";", "\[IndentingNewLine]", RowBox[{"BeginPackage", "[", "\"\\"", "]"}], ";", "\[IndentingNewLine]", "\t", RowBox[{ RowBox[{"Words", "::", "usage"}], " ", "=", "\[IndentingNewLine]", "\t\t ", "\"\ to words\>\""}], ";", "\[IndentingNewLine]", "\t", RowBox[{"Begin", "[", "\"\<`Private`\>\"", "]"}], ";", "\[IndentingNewLine]", "\t\t", RowBox[{ RowBox[{"Words", "[", "text_String", "]"}], ":=", RowBox[{"StringCases", "[", RowBox[{"text", ",", RowBox[{"LetterCharacter", ".."}]}], "]"}]}], ";", "\[IndentingNewLine]", "\t", RowBox[{"End", "[", "]"}], ";", "\[IndentingNewLine]", RowBox[{"EndPackage", "[", "]"}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", "\"\\"", "]"}]}], "\[IndentingNewLine]", "]"}]}], ";"}]], "Input", CellChangeTimes->{{3.441990186118648*^9, 3.441990187540693*^9}, { 3.441990490836811*^9, 3.4419905199186287`*^9}, {3.441990789205845*^9, 3.441990883661666*^9}, 3.441990917139805*^9, 3.44199110624172*^9, 3.4419913764903183`*^9, {3.441991451428074*^9, 3.4419915275475283`*^9}, { 3.441991569788267*^9, 3.4419916013436413`*^9}, {3.4419918043555584`*^9, 3.441991810584515*^9}, {3.4419925783384914`*^9, 3.441992579760536*^9}, { 3.441992690069152*^9, 3.4419926956972446`*^9}, {3.441993109301979*^9, 3.441993148979032*^9}, {3.441993527122776*^9, 3.4419935286449647`*^9}, 3.4419936878138385`*^9, {3.44199482467857*^9, 3.441994881440189*^9}, 3.4419952824568224`*^9, {3.4419953958298445`*^9, 3.4419954119830723`*^9}, { 3.441996140440542*^9, 3.4419961847642765`*^9}, {3.441996226424181*^9, 3.4419962291981697`*^9}, {3.4420520474496994`*^9, 3.4420520525470285`*^9}, 3.442053417950382*^9, 3.4420637734208174`*^9, {3.4420638479279537`*^9, 3.4420639121202574`*^9}}, FontWeight->"Plain"], Cell[BoxData[ RowBox[{"PackageFromHeldCode", "[", RowBox[{"code", ",", "file"}], "]"}]], "Input", CellChangeTimes->{{3.4419911082846575`*^9, 3.4419911428042946`*^9}, { 3.441991387416029*^9, 3.441991387876691*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"PackageReload", "[", "\"\\"", "]"}]], "Input", CellChangeTimes->{{3.4420535627586064`*^9, 3.442053563089082*^9}}], Cell[CellGroupData[{ Cell[BoxData["\<\"The package is being loaded\"\>"], "Print", CellChangeTimes->{3.4421392531046815`*^9, 3.4421403163335295`*^9, 3.4421411167344494`*^9}], Cell[BoxData["\<\"The package has been loaded\"\>"], "Print", CellChangeTimes->{3.4421392531046815`*^9, 3.4421403163335295`*^9, 3.4421411167544785`*^9}] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"PackageReload", "::", "\<\"unusednew\"\>"}], RowBox[{ ":", " "}], "\<\"Warning: the following symbols: \\!\\({Sentences}\\) no \ longer have usage messages \"\>"}]], "Message", CellChangeTimes->{3.4421392540760784`*^9, 3.442140317214797*^9, 3.4421411176057024`*^9}] }, Open ]], Cell[TextData[{ "The message generated, shows that changes have been made to the package, \ and some of the symbols that used to have usage messages in the old version \ of the package, no longer do so. Note that, due to the way ", StyleBox["PackageReload", FontWeight->"Bold", FontSlant->"Italic"], " works (it clears all context's symbols rather than removes them, the \ reasons are explained below), it is unable to directly detect a full removal \ of a symbol together with its usage message. So, this is a way for it to \ suggest that the symbol perhaps has been removed from the package. Such \ removals are normal during the interactive package development, but they are \ also important not to miss, since some other package's symbol(s) (or perhaps, \ a system function) may depend on the removed symbol, in which case a subtle \ bug is introduced as a side effect of package reloading (for an example of \ this, see below). " }], "Text", CellChangeTimes->{{3.4420534946907296`*^9, 3.4420535523436303`*^9}, { 3.442063938307914*^9, 3.4420642788576*^9}, {3.4420760458877583`*^9, 3.4420760555516543`*^9}, {3.4421414936163793`*^9, 3.442141559330872*^9}}], Cell[TextData[{ "The symbol ", StyleBox["Sentences", FontSlant->"Italic"], " is however still there in the context ", StyleBox["TextStatistics`", FontSlant->"Italic"], ", and thus the messages will be generated upon next reloads, until we \ explicitly ", StyleBox["Remove", FontSlant->"Italic"], " it :" }], "Text", CellChangeTimes->{{3.4420534946907296`*^9, 3.4420535523436303`*^9}, { 3.442063938307914*^9, 3.442064282442755*^9}, {3.4420643494891634`*^9, 3.4420643546265507`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"PackageReload", "[", "\"\\"", "]"}]], "Input", CellChangeTimes->{{3.442053569237923*^9, 3.442053569468254*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"PackageReload", "::", "\<\"unusedold\"\>"}], RowBox[{ ":", " "}], "\<\"Warning: PackageReload discovered that the following \ symbols: \\!\\({Sentences}\\) did not have usage messages (before reloading) \ \"\>"}]], "Message", CellChangeTimes->{3.442139260144805*^9, 3.4421403200088143`*^9, 3.442141119658654*^9}], Cell[CellGroupData[{ Cell[BoxData["\<\"The package is being loaded\"\>"], "Print", CellChangeTimes->{3.4421392606655536`*^9, 3.442140320619693*^9, 3.442141120189418*^9}], Cell[BoxData["\<\"The package has been loaded\"\>"], "Print", CellChangeTimes->{3.4421392606655536`*^9, 3.442140320619693*^9, 3.442141120229475*^9}] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"PackageReload", "::", "\<\"unused\"\>"}], RowBox[{ ":", " "}], "\<\"Warning: the following symbols: \\!\\({Sentences}\\) still \ don't have usage messages, after the package has been reloaded\"\>"}]], \ "Message", CellChangeTimes->{3.442139260144805*^9, 3.4421403200088143`*^9, 3.442141120269533*^9}] }, Open ]], Cell[TextData[{ "We now ", StyleBox["Remove", FontSlant->"Italic"], " it :" }], "Text", CellChangeTimes->{{3.4420537604829197`*^9, 3.4420537655301776`*^9}}], Cell[BoxData[ RowBox[{"Remove", "[", "Sentences", "]"}]], "Input", CellChangeTimes->{{3.4420537673828416`*^9, 3.442053771729091*^9}}], Cell["No warnings in this case", "Text", CellChangeTimes->{{3.4420537839767027`*^9, 3.442053790796509*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"PackageReload", "[", "\"\\"", "]"}]], "Input"], Cell[CellGroupData[{ Cell[BoxData["\<\"The package is being loaded\"\>"], "Print", CellChangeTimes->{3.442139265282192*^9, 3.442140323824301*^9, 3.442141123203752*^9}], Cell[BoxData["\<\"The package has been loaded\"\>"], "Print", CellChangeTimes->{3.442139265282192*^9, 3.442140323824301*^9, 3.4421411232237806`*^9}] }, Open ]] }, Open ]] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Correcting the code to avoid shadowing", "Subsection", CellChangeTimes->{{3.4420411455234995`*^9, 3.442041161716784*^9}}, FontWeight->"Plain"], Cell[TextData[{ "This is off the main line of our discussion, but let us correct the \ behavior of our model package so that the shadowing does not happen at all. \ Before, we resolved the shadowing problem by using the ", StyleBox["KillShadowing", FontWeight->"Bold", FontSlant->"Italic"], " option in ", StyleBox["PackageReload", FontWeight->"Bold", FontSlant->"Italic"], " function. Here we will take another route. The trick is to use the \ construct ", StyleBox["Symbol[its_string_name]", FontWeight->"Bold", FontSlant->"Italic"], " for any symbol. This will delay its creation in the symbol table from \ parse-time until run-time. We have to additionally use ", StyleBox["Evaluate", FontSlant->"Italic"], " since both ", StyleBox["MessageName", FontSlant->"Italic"], " (::) and ", StyleBox["SetDelayed", FontSlant->"Italic"], " (:=) hold their first argument (the latter holds both its arguments). Some \ portions of the code unimportant for this problem, have been skipped." }], "Text", CellChangeTimes->{{3.442041261610424*^9, 3.4420412947280445`*^9}, { 3.442041654565466*^9, 3.44204173585235*^9}, {3.442042682102992*^9, 3.4420427367115154`*^9}, {3.4420646982206144`*^9, 3.4420647467904544`*^9}, { 3.4420724476237087`*^9, 3.442072512436906*^9}, {3.4420761016980095`*^9, 3.442076188753189*^9}, {3.4420834300556707`*^9, 3.442083448972872*^9}, { 3.4421317768143044`*^9, 3.4421317965126286`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"PackageClearComplete", "[", RowBox[{"\"\\"", ",", RowBox[{"RemovePackage", "\[Rule]", " ", "True"}]}], "]"}], ";"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"code", " ", "=", "\[IndentingNewLine]", " ", RowBox[{"Hold", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"Print", "[", "\"\\"", "]"}], ";", "\[IndentingNewLine]", RowBox[{"BeginPackage", "[", "\"\\"", "]"}], ";", "\[IndentingNewLine]", "\t", RowBox[{ RowBox[{ RowBox[{"Evaluate", "[", RowBox[{"Symbol", "[", "\"\\"", "]"}], "]"}], "::", "usage"}], " ", "=", " ", "\[IndentingNewLine]", "\t\t", "\"\\""}], ";", "\[IndentingNewLine]", "\t", RowBox[{ RowBox[{ RowBox[{"Evaluate", "[", RowBox[{"Symbol", "[", "\"\\"", "]"}], "]"}], "::", "usage"}], " ", "=", "\[IndentingNewLine]", "\t\t ", "\"\ to words\>\""}], ";", "\[IndentingNewLine]", "\t", RowBox[{"Begin", "[", "\"\<`Private`\>\"", "]"}], ";", "\[IndentingNewLine]", "\t\t", RowBox[{ RowBox[{ RowBox[{"Evaluate", "[", RowBox[{"Symbol", "[", "\"\\"", "]"}], "]"}], "[", "text_String", "]"}], ":=", "\[IndentingNewLine]", "\t\t\t", RowBox[{"StringCases", "[", RowBox[{"text", ",", "\[IndentingNewLine]", "\t\t\t\t", RowBox[{"ShortestMatch", "[", "\[IndentingNewLine]", "\t\t\t\t\t", RowBox[{ RowBox[{"CharacterRange", "[", RowBox[{"\"\\"", ",", "\"\\""}], "]"}], "~~", "x__", "~~", "\"\<.\>\""}], "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", "\t\t", RowBox[{ RowBox[{ RowBox[{"Evaluate", "[", RowBox[{"Symbol", "[", "\"\\"", "]"}], "]"}], "[", "text_String", "]"}], ":=", "\[IndentingNewLine]", "\t\t\t", RowBox[{"StringCases", "[", RowBox[{"text", ",", RowBox[{"LetterCharacter", ".."}]}], "]"}]}], ";", "\[IndentingNewLine]", "\t", RowBox[{"End", "[", "]"}], ";", "\[IndentingNewLine]", RowBox[{"EndPackage", "[", "]"}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", "\"\\"", "]"}]}], "\[IndentingNewLine]", "]"}]}], ";"}]], "Input", CellChangeTimes->{{3.441990186118648*^9, 3.441990187540693*^9}, { 3.441990490836811*^9, 3.4419905199186287`*^9}, {3.441990789205845*^9, 3.441990883661666*^9}, 3.441990917139805*^9, 3.44199110624172*^9, 3.4419913764903183`*^9, {3.441991451428074*^9, 3.4419915275475283`*^9}, { 3.441991569788267*^9, 3.4419916013436413`*^9}, {3.4419918043555584`*^9, 3.441991810584515*^9}, {3.4419925783384914`*^9, 3.441992579760536*^9}, { 3.441992690069152*^9, 3.4419926956972446`*^9}, {3.441993109301979*^9, 3.441993148979032*^9}, {3.441993527122776*^9, 3.4419935286449647`*^9}, 3.4419936878138385`*^9, {3.44199482467857*^9, 3.441994881440189*^9}, 3.4419952824568224`*^9, {3.4419953958298445`*^9, 3.4419954119830723`*^9}, { 3.441996140440542*^9, 3.4419961847642765`*^9}, {3.441996226424181*^9, 3.4419962291981697`*^9}, {3.4420417429125023`*^9, 3.4420417491815166`*^9}, {3.4420418776862974`*^9, 3.442041970760131*^9}, 3.4420420578854113`*^9, 3.442042173521688*^9, {3.4420423987555585`*^9, 3.442042469126747*^9}, {3.442042554769896*^9, 3.4420425634924383`*^9}, { 3.442064663420574*^9, 3.442064686153262*^9}, {3.4420647507862*^9, 3.4420648065964513`*^9}}, FontWeight->"Plain"], Cell["We make a package from code :", "Text", CellChangeTimes->{{3.4420426637365828`*^9, 3.442042671277426*^9}}], Cell[BoxData[ RowBox[{"PackageFromHeldCode", "[", RowBox[{"code", ",", "file"}], "]"}]], "Input"], Cell["Load the corrected package :", "Text", CellChangeTimes->{{3.442042493601941*^9, 3.442042502414613*^9}, { 3.4420427640007553`*^9, 3.4420427727833843`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Needs", "[", "\"\\"", "]"}]], "Input"], Cell[CellGroupData[{ Cell[BoxData["\<\"The package is being loaded\"\>"], "Print", CellChangeTimes->{3.442139273303726*^9, 3.4421403301033297`*^9, 3.4421403665257025`*^9, 3.4421411298032417`*^9}], Cell[BoxData["\<\"The package has been loaded\"\>"], "Print", CellChangeTimes->{3.442139273303726*^9, 3.4421403301033297`*^9, 3.4421403665257025`*^9, 3.442141129843299*^9}] }, Open ]] }, Open ]], Cell["Test the functions:", "Text", CellChangeTimes->{{3.4420426438279552`*^9, 3.44204264566059*^9}, { 3.4420427786618366`*^9, 3.442042780834962*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"Words", "[", "text", "]"}], "//", "Short"}]], "Input", CellChangeTimes->{{3.442042631810675*^9, 3.44204263448452*^9}, { 3.442064819915603*^9, 3.4420648212875757`*^9}}], Cell[BoxData[ TagBox[ RowBox[{"{", RowBox[{"\<\"Writing\"\>", ",", "\<\"tests\"\>", ",", RowBox[{"\[LeftSkeleton]", "64", "\[RightSkeleton]"}], ",", "\<\"circumstances\"\>"}], "}"}], Short]], "Output", CellChangeTimes->{3.44213929302208*^9, 3.442140379484336*^9, 3.442141131455618*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"Sentences", "[", "text", "]"}], "//", RowBox[{ RowBox[{"Short", "[", RowBox[{"#", ",", "5"}], "]"}], "&"}]}]], "Input", CellChangeTimes->{{3.4420426366075726`*^9, 3.442042639722051*^9}, { 3.442064825073019*^9, 3.4420648307111263`*^9}, {3.4420762425705743`*^9, 3.4420762490599055`*^9}}], Cell[BoxData[ TagBox[ RowBox[{"{", RowBox[{"\<\"Writing tests first forces me to examine my understanding of \ the purpose of the class (the question) I am about to create.\"\>", ",", RowBox[{"\<\"It requires exact, detai\"\>", "\[Ellipsis]", "\<\"tests with anything less.\"\>"}], ",", RowBox[{"\[LeftSkeleton]", "197", "\[RightSkeleton]"}]}], "}"}], Short[#, 5]& ]], "Output", CellChangeTimes->{3.4421392945442686`*^9, 3.4421403802153873`*^9, 3.4421411325271587`*^9}] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"PackageClearComplete", "[", RowBox[{"\"\\"", ",", RowBox[{"RemovePackage", "\[Rule]", " ", "True"}]}], "]"}], ";"}]], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Some comments", "Subsection", CellChangeTimes->{{3.442042949998206*^9, 3.442042952762181*^9}}, FontWeight->"Plain"], Cell[TextData[{ "Note that ", StyleBox["PackageReload", FontWeight->"Bold", FontSlant->"Italic"], " uses internally ", StyleBox["PackageClearComplete", FontWeight->"Bold", FontSlant->"Italic"], " with ", StyleBox["RemovePackage -> False", FontWeight->"Bold", FontSlant->"Italic"], " option. This is done for safety reasons: if any symbol in other contexts \ does depend on some symbol (s) in the context of the package we want to \ reload, then it will become ", StyleBox["Removed[thatsymbol] ", FontSlant->"Italic"], "in all places where this symbol was present before", StyleBox[",", FontSlant->"Italic"], " should we remove it rather than clear it, during reloading of our package. \ This will most certainly cause trouble, and such bugs are hard to catch." }], "Text", CellChangeTimes->{{3.4420429539538946`*^9, 3.4420431634651566`*^9}, { 3.44206445611248*^9, 3.442064611986616*^9}, 3.442065644200867*^9, { 3.442065682856451*^9, 3.4420657125791903`*^9}, {3.4420835198147373`*^9, 3.4420835545947485`*^9}, {3.442083591267482*^9, 3.4420835968455024`*^9}, { 3.442083638845896*^9, 3.4420836501020813`*^9}, {3.442083714204256*^9, 3.4420837201628237`*^9}}], Cell[CellGroupData[{ Cell["Illustration", "Subsubsection", CellChangeTimes->{{3.442083801029104*^9, 3.4420838042737694`*^9}}, FontWeight->"Plain"], Cell["Here is a simple example of such behavior:", "Text", CellChangeTimes->{{3.4420429539538946`*^9, 3.4420431634651566`*^9}, { 3.44206445611248*^9, 3.442064611986616*^9}, 3.442065644200867*^9, { 3.442065682856451*^9, 3.4420657125791903`*^9}, {3.4420835198147373`*^9, 3.4420835545947485`*^9}, {3.442083591267482*^9, 3.4420835968455024`*^9}, { 3.442083638845896*^9, 3.4420836501020813`*^9}, {3.442083714204256*^9, 3.4420837212543936`*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"ClearAll", "[", RowBox[{"f", ",", "g"}], "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"f", "[", "x_", "]"}], ":=", RowBox[{"x", "^", "2"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"g", "[", "x_", "]"}], ":=", RowBox[{"Sin", "[", RowBox[{"f", "[", "x", "]"}], "]"}]}], ";"}]}], "Input", CellChangeTimes->{{3.4420835990286417`*^9, 3.442083624395117*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"?", "g"}]], "Input", CellChangeTimes->{{3.442083627779984*^9, 3.442083628130488*^9}}], Cell[CellGroupData[{ Cell["Global`g", "Print", "PrintUsage", CellChangeTimes->{3.442141675768301*^9}, CellTags->"Info3442112875-8059705"], Cell[BoxData[ InterpretationBox[GridBox[{ {GridBox[{ { RowBox[{ RowBox[{"g", "[", "x_", "]"}], ":=", RowBox[{"Sin", "[", RowBox[{"f", "[", "x", "]"}], "]"}]}]} }, BaselinePosition->{Baseline, {1, 1}}, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}, GridBoxItemSize->{"Columns" -> {{ Scaled[0.999]}}, "ColumnsIndexed" -> {}, "Rows" -> {{1.}}, "RowsIndexed" -> {}}]} }, BaselinePosition->{Baseline, {1, 1}}, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}], Definition["g"], Editable->False]], "Print", CellChangeTimes->{3.442141675808358*^9}, CellTags->"Info3442112875-8059705"] }, Open ]] }, Open ]], Cell[TextData[{ "We ", StyleBox["Remove", FontSlant->"Italic"], " f :" }], "Text", CellChangeTimes->{{3.442083730047037*^9, 3.4420837335721054`*^9}}], Cell[BoxData[ RowBox[{"Remove", "[", "f", "]"}]], "Input", CellChangeTimes->{{3.442083630363699*^9, 3.4420836320461187`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"?", "g"}]], "Input", CellChangeTimes->{{3.4420836334481344`*^9, 3.4420836337585807`*^9}}], Cell[CellGroupData[{ Cell["Global`g", "Print", "PrintUsage", CellChangeTimes->{3.442141679083067*^9}, CellTags->"Info3442112878-7144394"], Cell[BoxData[ InterpretationBox[GridBox[{ {GridBox[{ { RowBox[{ RowBox[{"g", "[", "x_", "]"}], ":=", RowBox[{"Sin", "[", RowBox[{ TagBox[ RowBox[{"Removed", "[", "\<\"f\"\>", "]"}], False, Editable->False], "[", "x", "]"}], "]"}]}]} }, BaselinePosition->{Baseline, {1, 1}}, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}, GridBoxItemSize->{"Columns" -> {{ Scaled[0.999]}}, "ColumnsIndexed" -> {}, "Rows" -> {{1.}}, "RowsIndexed" -> {}}]} }, BaselinePosition->{Baseline, {1, 1}}, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}], Definition["g"], Editable->False]], "Print", CellChangeTimes->{3.4421416791131105`*^9}, CellTags->"Info3442112878-7144394"] }, Open ]] }, Open ]], Cell["We \"reload\" f", "Text", CellChangeTimes->{{3.4420837467109985`*^9, 3.4420837533104877`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"f", "[", "x_", "]"}], ":=", RowBox[{"x", "^", "2"}]}], ";"}]], "Input", CellChangeTimes->{{3.4420836662252655`*^9, 3.442083674216757*^9}}], Cell["We try now :", "Text", CellChangeTimes->{{3.442083683129573*^9, 3.442083685583101*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"g", "[", RowBox[{"Sqrt", "[", "Pi", "]"}], "]"}]], "Input", CellChangeTimes->{{3.4420836760794353`*^9, 3.4420837067635565`*^9}, { 3.4421416709613886`*^9, 3.4421416893277984`*^9}}], Cell[BoxData[ RowBox[{"Sin", "[", RowBox[{ TagBox[ RowBox[{"Removed", "[", "\<\"f\"\>", "]"}], False, Editable->False], "[", SqrtBox["\[Pi]"], "]"}], "]"}]], "Output", CellChangeTimes->{3.442141689738389*^9}] }, Open ]], Cell["Now you see what I am talking about.", "Text", CellChangeTimes->{{3.4420837601202803`*^9, 3.442083770905789*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"Remove", "[", RowBox[{"f", ",", "g"}], "]"}], ";"}]], "Input", CellChangeTimes->{{3.4420838214484653`*^9, 3.442083831893485*^9}}] }, Closed]], Cell[CellGroupData[{ Cell["", "Subsubsection", CellChangeTimes->{{3.4420838117244835`*^9, 3.4420838120349293`*^9}}], Cell[TextData[{ "The disadvantage of this approach is that in a new (reloaded) version of \ the package some symbols may be present without actually being useful for \ anything. This happens if the symbol is simply not present in the user's \ context in the new version of the package. It then still remains in the \ symbol table from the times of the old package, but with all its global \ properties cleared by ", StyleBox["PackageClearComplete", FontSlant->"Italic"], ". As discussed above, warning messages are generated by ", StyleBox["PackageReload", FontWeight->"Bold", FontSlant->"Italic"], " in such cases. " }], "Text", CellChangeTimes->{{3.4420429539538946`*^9, 3.4420431634651566`*^9}, { 3.44206445611248*^9, 3.442064611986616*^9}, 3.442065644200867*^9, { 3.442065682856451*^9, 3.4420657125791903`*^9}, {3.4420835198147373`*^9, 3.4420835545947485`*^9}, {3.442083591267482*^9, 3.4420835968455024`*^9}, { 3.442083657692997*^9, 3.442083662780312*^9}, {3.442083692893613*^9, 3.4420837109595904`*^9}, {3.4420837793379135`*^9, 3.442083783053256*^9}, { 3.4420838818653407`*^9, 3.4420838837380333`*^9}}] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["\<\ Appendix: another way to avoid shadowing in our code-to-package convertion \ technique\ \>", "Subsection", CellChangeTimes->{{3.4420751224499197`*^9, 3.442075122810438*^9}, { 3.442076315184989*^9, 3.442076362212611*^9}}, FontWeight->"Plain"], Cell["\<\ To avoid shadowing this time, we will use a \"quick and dirty\" solution: \ \>", "Text", CellChangeTimes->{{3.4420663999475775`*^9, 3.4420664190350237`*^9}, { 3.4420721529900465`*^9, 3.44207218773*^9}, {3.442072305389186*^9, 3.4420723346412477`*^9}, 3.442076315184989*^9}], Cell[BoxData[ RowBox[{ RowBox[{"Hold", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"removeShadowingSymbols", "[", "code_Hold", "]"}], ":=", RowBox[{"Remove", "@@", RowBox[{"JoinHeld", "@@", RowBox[{"Union", "[", RowBox[{"Cases", "[", RowBox[{"code", ",", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"Verbatim", "[", "MessageName", "]"}], "[", RowBox[{"sym_", ",", "\"\\""}], "]"}], "\[RuleDelayed]", RowBox[{"Hold", "[", "sym", "]"}]}], ",", "Infinity"}], "]"}], "]"}]}]}]}], "\[IndentingNewLine]", "]"}], ";"}]], "Input", CellChangeTimes->{{3.4420661952231984`*^9, 3.4420663184103327`*^9}, { 3.4420721966328015`*^9, 3.442072204934739*^9}, 3.442076315184989*^9, { 3.442139310116661*^9, 3.4421393254286785`*^9}}, FontWeight->"Plain"], Cell[TextData[{ "This function will hunt the code for symbols in the user context and ", StyleBox["Remove", FontSlant->"Italic"], " them (these symbols are identified by having usage messages attached to \ them). This function could be incorporated into ", StyleBox["PackageFromHeldCode", FontSlant->"Italic"], ":" }], "Text", CellChangeTimes->{{3.4420722095513773`*^9, 3.442072232073763*^9}, { 3.442072336994632*^9, 3.442072352567024*^9}, {3.442072577510477*^9, 3.4420725984505873`*^9}, 3.442076315184989*^9}], Cell[BoxData[ RowBox[{ RowBox[{"Hold", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"Clear", "[", "PackageFromHeldCode", "]"}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"PackageFromHeldCode", "[", RowBox[{ RowBox[{"code", ":", RowBox[{"Hold", "[", RowBox[{"CompoundExpression", "[", "___", "]"}], "]"}]}], ",", "fname_String"}], "]"}], ":=", "\[IndentingNewLine]", RowBox[{"CompoundExpression", "[", RowBox[{ RowBox[{"Put", "@@", RowBox[{"JoinHeld", "[", RowBox[{ RowBox[{"Replace", "[", RowBox[{ RowBox[{"Map", "[", RowBox[{"Unevaluated", ",", RowBox[{"Replace", "[", RowBox[{"code", ",", RowBox[{"x_", "\[RuleDelayed]", RowBox[{"(", RowBox[{"x", ";"}], ")"}]}], ",", RowBox[{"{", "2", "}"}]}], "]"}], ",", RowBox[{"{", "2", "}"}]}], "]"}], ",", RowBox[{ RowBox[{ RowBox[{"Verbatim", "[", "CompoundExpression", "]"}], "[", "x___", "]"}], "\[RuleDelayed]", "x"}], ",", RowBox[{"{", "1", "}"}]}], "]"}], ",", RowBox[{"Hold", "[", "fname", "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"removeShadowingSymbols", "[", "code", "]"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", "]"}], ";"}]], "Input", CellChangeTimes->{{3.442072389570232*^9, 3.442072428045557*^9}, 3.442076315184989*^9, {3.4421393275817747`*^9, 3.442139333730616*^9}}, FontWeight->"Plain"], Cell["\<\ In this case, shadowing is avoided for all symbols that have usage messages. \ On the other hand, those that do not, but are present in the user context, \ are bugs, as we discussed already.\ \>", "Text", CellChangeTimes->{{3.442076372647616*^9, 3.442076439824211*^9}, { 3.4420774274743824`*^9, 3.4420775540263553`*^9}}], Cell[TextData[{ "The problem of this solution is that it may occasionally Remove some global \ symbol which is currently in use for purposes other than just being present \ in the code of our package-to-be-created. Thus, the solution based on ", StyleBox["Symbol[its_string_name]", FontSlant->"Italic"], " construct seems preferable. " }], "Text", CellChangeTimes->{{3.442076372647616*^9, 3.442076439824211*^9}, { 3.4420774274743824`*^9, 3.44207757531697*^9}, {3.4421417789566784`*^9, 3.442141787879509*^9}}] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell["Summary", "Section", CellChangeTimes->{{3.442076918362315*^9, 3.4420769210762177`*^9}}, FontWeight->"Plain"], Cell[TextData[{ "The present package allows one to programmatically reload any given package \ any number of times during the interactive ", StyleBox["Mathematica", FontSlant->"Italic"], " session (or, during execution of a stand - alone program), and also to ", StyleBox["Remove", FontSlant->"Italic"], " the entire context of the package (and optionally all its sub - contexts) \ in a way consistent with general package mechanics in ", StyleBox["Mathematica", FontSlant->"Italic"], ". " }], "Text", CellChangeTimes->{{3.442082182551848*^9, 3.4420821851656065`*^9}, { 3.4420823381856384`*^9, 3.4420823539382896`*^9}}], Cell[TextData[{ "In order to dynamically reload the package, use ", StyleBox["PackageReload", FontWeight->"Bold", FontSlant->"Italic"], StyleBox["[context]", FontSlant->"Italic"], ". If it is desired that possible shadowing problems occurring before or \ during reloading are resolved automatically (by ", StyleBox["Remove", FontSlant->"Italic"], "-ing shadowing duplicate symbols in other contexts), use ", StyleBox["PackageReload", FontWeight->"Bold", FontSlant->"Italic"], StyleBox[" ", FontWeight->"Bold"], "with an option ", StyleBox["KillShadowing->True", FontWeight->"Bold", FontSlant->"Italic"], ".The function ", StyleBox["PackageReload", FontWeight->"Bold", FontSlant->"Italic"], StyleBox[" ", FontSlant->"Italic"], "also has additional functionality of tracking escaping symbols - that is, \ symbols in the main (user) context of the package which don't have usage \ messages. It tracks these symbols both before and after package reloading, \ and if they are found, warning messages are generated. This is especially \ helpful during interactive package development, when the package's interface \ is subject to frequent changes." }], "Text", CellChangeTimes->{{3.4420816093376064`*^9, 3.442081742949731*^9}, { 3.442081855802005*^9, 3.442082025946661*^9}, {3.4420822740233774`*^9, 3.442082277858893*^9}, {3.442082369340437*^9, 3.4420823834907837`*^9}, { 3.442083964864688*^9, 3.442083969871888*^9}, 3.442139458690299*^9}], Cell[TextData[{ "To ", StyleBox["Clear", FontSlant->"Italic"], " the entire context (that is, all names in it), use ", StyleBox["PackageClear", FontWeight->"Bold", FontSlant->"Italic"], ". To ", StyleBox["Remove", FontSlant->"Italic"], " an entire context (", StyleBox["Remove", FontSlant->"Italic"], " all names in it, and also remove it from", StyleBox[" $ContextPath, $Packages", FontSlant->"Italic"], "), use ", StyleBox["PackageRemove", FontWeight->"Bold", FontSlant->"Italic"], ". Note that ", StyleBox["PackageRemove", FontWeight->"Bold", FontSlant->"Italic"], " will not remove the sub-contexts. To ", StyleBox["Clear", FontSlant->"Italic"], " symbols in the entire context with all its sub-contexts, use ", StyleBox["PackageClearComplete", FontWeight->"Bold", FontSlant->"Italic"], ". Note that clearing does not remove any symbols from the symbol table, but \ merely clears all possible definitions associated with the symbols (", StyleBox["ClearAll", FontSlant->"Italic"], " is used). To ", StyleBox["Remove", FontSlant->"Italic"], " the entire context with all its sub-contexts, use ", StyleBox["PackageClearComplete", FontWeight->"Bold", FontSlant->"Italic"], " with an option ", StyleBox["RemovePackage-> True", FontWeight->"Bold", FontSlant->"Italic"], StyleBox[". ", FontSlant->"Italic"], "After the package has been removed with ", StyleBox["PackageRemove", FontWeight->"Bold", FontSlant->"Italic"], " or ", StyleBox["PackageClearComplete", FontWeight->"Bold", FontSlant->"Italic"], "[context, ", StyleBox["RemovePackage-> True", FontSlant->"Italic"], "], one can use standard ", StyleBox["Needs", FontSlant->"Italic"], " (or ", StyleBox["Get", FontSlant->"Italic"], ") to load the package again (", StyleBox["PackageReload", FontWeight->"Bold", FontSlant->"Italic"], " also can be used in this case).\n\nAs a by-product of the main discussion, \ we looked at how one may programmatically generate a package from code \ entered directly in the interactive ", StyleBox["Mathematica", FontSlant->"Italic"], " session (", StyleBox["Global`", FontSlant->"Italic"], " context), and associated with this possible shadowing problems and ways to \ resolve them." }], "Text", CellChangeTimes->{{3.4420817443918047`*^9, 3.4420817550771694`*^9}, { 3.4420817907684913`*^9, 3.4420818479006433`*^9}, {3.442082112951768*^9, 3.4420821784259152`*^9}, {3.442082437538501*^9, 3.442082509522008*^9}, { 3.4420825437311983`*^9, 3.4420826687409534`*^9}, {3.442084054643784*^9, 3.4420841781313505`*^9}, 3.4421394639478593`*^9}] }, Open ]] }, Open ]] }, WindowSize->{1016, 651}, WindowMargins->{{0, Automatic}, {Automatic, 0}}, PrintingCopies->1, PrintingPageRange->{Automatic, Automatic}, ShowSelection->True, Magnification->1.5, FrontEndVersion->"6.0 for Microsoft Windows (32-bit) (April 28, 2007)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{ "Info3442112199-7221442"->{ Cell[8904, 262, 184, 3, 61, "Print", CellTags->"Info3442112199-7221442"]}, "Info3442112492-1059804"->{ Cell[38148, 1044, 134, 2, 60, "Print", CellTags->"Info3442112492-1059804"]}, "Info3442112493-8549421"->{ Cell[38441, 1055, 128, 2, 60, "Print", CellTags->"Info3442112493-8549421"]}, "Info3442112875-8059705"->{ Cell[80996, 2181, 118, 2, 60, "Print", CellTags->"Info3442112875-8059705"], Cell[81117, 2185, 841, 24, 32, "Print", CellTags->"Info3442112875-8059705"]}, "Info3442112878-7144394"->{ Cell[82434, 2233, 118, 2, 60, "Print", CellTags->"Info3442112878-7144394"], Cell[82555, 2237, 963, 28, 32, "Print", CellTags->"Info3442112878-7144394"]} } *) (*CellTagsIndex CellTagsIndex->{ {"Info3442112199-7221442", 95853, 2622}, {"Info3442112492-1059804", 95962, 2625}, {"Info3442112493-8549421", 96073, 2628}, {"Info3442112875-8059705", 96184, 2631}, {"Info3442112878-7144394", 96377, 2636} } *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[590, 23, 500, 11, 117, "Subtitle"], Cell[CellGroupData[{ Cell[1115, 38, 278, 9, 156, "Subsection"], Cell[1396, 49, 147, 2, 41, "Subsubsection"], Cell[1546, 53, 411, 9, 31, "Subsubsection"] }, Open ]], Cell[CellGroupData[{ Cell[1994, 67, 121, 2, 105, "Section"], Cell[2118, 71, 584, 12, 90, "Text"], Cell[2705, 85, 716, 11, 115, "Text"], Cell[3424, 98, 433, 9, 67, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[3894, 112, 123, 2, 105, "Section"], Cell[CellGroupData[{ Cell[4042, 118, 125, 2, 54, "Subsection"], Cell[CellGroupData[{ Cell[4192, 124, 119, 2, 41, "Subsubsection"], Cell[4314, 128, 344, 6, 90, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[4695, 139, 136, 2, 41, "Subsubsection"], Cell[4834, 143, 273, 8, 42, "Text"], Cell[5110, 153, 371, 9, 125, "Input"], Cell[5484, 164, 102, 1, 41, "Text"], Cell[5589, 167, 156, 2, 43, "Input"], Cell[5748, 171, 165, 3, 43, "Input"], Cell[5916, 176, 132, 1, 41, "Text"], Cell[CellGroupData[{ Cell[6073, 181, 133, 2, 43, "Input"], Cell[CellGroupData[{ Cell[6231, 187, 2670, 73, 127, "Print"], Cell[8904, 262, 184, 3, 61, "Print", CellTags->"Info3442112199-7221442"] }, Open ]] }, Open ]], Cell[9115, 269, 115, 1, 41, "Text"], Cell[9233, 272, 221, 5, 43, "Input"], Cell[9457, 279, 136, 1, 41, "Text"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[9642, 286, 211, 3, 40, "Subsection"], Cell[9856, 291, 444, 10, 67, "Text"], Cell[10303, 303, 689, 18, 98, "Input"], Cell[10995, 323, 1358, 33, 98, "Input"], Cell[12356, 358, 286, 8, 42, "Text"], Cell[12645, 368, 303, 7, 125, "Input"], Cell[12951, 377, 121, 1, 41, "Text"], Cell[13075, 380, 359, 8, 43, "Input"], Cell[13437, 390, 317, 6, 66, "Text"], Cell[13757, 398, 3259, 62, 593, "Input"], Cell[17019, 462, 131, 1, 41, "Text"], Cell[17153, 465, 220, 4, 43, "Input"], Cell[17376, 471, 193, 4, 41, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[17606, 480, 216, 3, 40, "Subsection"], Cell[17825, 485, 156, 3, 41, "Text"], Cell[17984, 490, 227, 5, 43, "Input"], Cell[18214, 497, 99, 1, 41, "Text"], Cell[CellGroupData[{ Cell[18338, 502, 174, 3, 43, "Input"], Cell[18515, 507, 150, 2, 32, "Print"], Cell[18668, 511, 647, 12, 108, "Message"], Cell[19318, 525, 637, 12, 83, "Message"], Cell[19958, 539, 152, 2, 32, "Print"] }, Open ]], Cell[20125, 544, 1013, 24, 140, "Text"], Cell[21141, 570, 226, 7, 42, "Text"], Cell[CellGroupData[{ Cell[21392, 581, 129, 2, 43, "Input"], Cell[CellGroupData[{ Cell[21546, 587, 152, 2, 32, "Print"], Cell[21701, 591, 150, 2, 32, "Print"] }, Open ]] }, Open ]], Cell[21878, 597, 791, 20, 91, "Text"], Cell[22672, 619, 645, 15, 66, "Text"], Cell[23320, 636, 2046, 48, 287, "Input"], Cell[CellGroupData[{ Cell[25391, 688, 273, 5, 43, "Input"], Cell[25667, 695, 187, 4, 42, "Output"] }, Open ]], Cell[25869, 702, 473, 9, 42, "Text"], Cell[CellGroupData[{ Cell[26367, 715, 229, 4, 43, "Input"], Cell[CellGroupData[{ Cell[26621, 723, 152, 2, 32, "Print"], Cell[26776, 727, 154, 2, 32, "Print"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[26979, 735, 114, 2, 43, "Input"], Cell[27096, 739, 121, 2, 42, "Output"] }, Open ]], Cell[27232, 744, 460, 13, 67, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[27729, 762, 213, 3, 40, "Subsection"], Cell[27945, 767, 305, 8, 41, "Text"], Cell[28253, 777, 801, 14, 233, "Input"], Cell[29057, 793, 92, 1, 41, "Text"], Cell[CellGroupData[{ Cell[29174, 798, 182, 3, 43, "Input"], Cell[29359, 803, 615, 10, 193, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[30011, 818, 126, 2, 43, "Input"], Cell[30140, 822, 1695, 26, 193, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[31884, 854, 251, 6, 40, "Subsection"], Cell[32138, 862, 207, 5, 41, "Text"], Cell[32348, 869, 153, 2, 43, "Input"], Cell[32504, 873, 87, 1, 41, "Text"], Cell[CellGroupData[{ Cell[32616, 878, 173, 3, 43, "Input"], Cell[32792, 883, 138, 3, 42, "Output"] }, Open ]], Cell[32945, 889, 282, 9, 41, "Text"], Cell[CellGroupData[{ Cell[33252, 902, 103, 1, 43, "Input"], Cell[33358, 905, 322, 6, 68, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[33717, 916, 108, 1, 43, "Input"], Cell[33828, 919, 298, 6, 42, "Output"] }, Open ]], Cell[34141, 928, 373, 9, 67, "Text"], Cell[CellGroupData[{ Cell[34539, 941, 281, 5, 43, "Input"], Cell[CellGroupData[{ Cell[34845, 950, 230, 3, 32, "Print"], Cell[35080, 956, 228, 3, 32, "Print"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[35357, 965, 161, 3, 43, "Input"], Cell[35521, 970, 658, 14, 93, "Output"] }, Open ]], Cell[36194, 987, 153, 2, 43, "Input"], Cell[36350, 991, 123, 1, 41, "Text"], Cell[CellGroupData[{ Cell[36498, 996, 91, 2, 43, "Input"], Cell[36592, 1000, 660, 14, 93, "Output"] }, Open ]], Cell[37267, 1017, 169, 2, 41, "Text"], Cell[CellGroupData[{ Cell[37461, 1023, 151, 2, 43, "Input"], Cell[37615, 1027, 214, 4, 42, "Output"] }, Open ]], Cell[37844, 1034, 148, 2, 41, "Text"], Cell[CellGroupData[{ Cell[38017, 1040, 128, 2, 43, "Input"], Cell[38148, 1044, 134, 2, 60, "Print", CellTags->"Info3442112492-1059804"] }, Open ]], Cell[CellGroupData[{ Cell[38319, 1051, 119, 2, 43, "Input"], Cell[38441, 1055, 128, 2, 60, "Print", CellTags->"Info3442112493-8549421"] }, Open ]], Cell[38584, 1060, 430, 7, 66, "Text"], Cell[CellGroupData[{ Cell[39039, 1071, 295, 9, 43, "Input"], Cell[39337, 1082, 315, 6, 42, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[39689, 1093, 204, 3, 43, "Input"], Cell[39896, 1098, 309, 6, 68, "Output"] }, Open ]], Cell[40220, 1107, 243, 3, 41, "Text"], Cell[CellGroupData[{ Cell[40488, 1114, 194, 4, 43, "Input"], Cell[40685, 1120, 253, 6, 42, "Output"] }, Open ]], Cell[40953, 1129, 455, 10, 67, "Text"], Cell[CellGroupData[{ Cell[41435, 1144, 266, 5, 71, "Input"], Cell[CellGroupData[{ Cell[41726, 1153, 152, 2, 32, "Print"], Cell[41881, 1157, 152, 2, 32, "Print"] }, Open ]] }, Open ]], Cell[42060, 1163, 126, 1, 41, "Text"], Cell[42189, 1166, 168, 3, 43, "Input"], Cell[42360, 1171, 193, 2, 41, "Text"], Cell[CellGroupData[{ Cell[42578, 1177, 124, 2, 43, "Input"], Cell[42705, 1181, 260, 6, 68, "Output"] }, Open ]], Cell[42980, 1190, 371, 12, 42, "Text"], Cell[CellGroupData[{ Cell[43376, 1206, 244, 5, 71, "Input"], Cell[CellGroupData[{ Cell[43645, 1215, 154, 2, 32, "Print"], Cell[43802, 1219, 154, 2, 32, "Print"] }, Open ]] }, Open ]], Cell[43983, 1225, 233, 4, 43, "Input"], Cell[44219, 1231, 91, 1, 41, "Text"], Cell[CellGroupData[{ Cell[44335, 1236, 91, 2, 43, "Input"], Cell[44429, 1240, 563, 12, 93, "Output"] }, Open ]], Cell[45007, 1255, 173, 4, 41, "Text"], Cell[CellGroupData[{ Cell[45205, 1263, 322, 9, 43, "Input"], Cell[45530, 1274, 138, 3, 42, "Output"] }, Open ]], Cell[45683, 1280, 154, 3, 41, "Text"], Cell[CellGroupData[{ Cell[45862, 1287, 148, 2, 43, "Input"], Cell[CellGroupData[{ Cell[46035, 1293, 151, 2, 32, "Print"], Cell[46189, 1297, 154, 2, 32, "Print"] }, Open ]] }, Open ]], Cell[46370, 1303, 168, 3, 43, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[46575, 1311, 148, 2, 40, "Subsection"], Cell[46726, 1315, 1497, 41, 240, "Text"], Cell[CellGroupData[{ Cell[48248, 1360, 242, 5, 41, "Subsubsection"], Cell[48493, 1367, 233, 6, 43, "Input"], Cell[48729, 1375, 292, 5, 66, "Text"], Cell[49024, 1382, 3469, 66, 593, "Input"], Cell[52496, 1450, 110, 1, 41, "Text"], Cell[52609, 1453, 269, 5, 43, "Input"], Cell[52881, 1460, 97, 1, 41, "Text"], Cell[CellGroupData[{ Cell[53003, 1465, 148, 2, 43, "Input"], Cell[53154, 1469, 149, 2, 32, "Print"], Cell[53306, 1473, 647, 12, 108, "Message"], Cell[53956, 1487, 635, 12, 83, "Message"], Cell[54594, 1501, 151, 2, 32, "Print"] }, Open ]], Cell[54760, 1506, 432, 10, 68, "Text"], Cell[CellGroupData[{ Cell[55217, 1520, 280, 5, 43, "Input"], Cell[55500, 1527, 357, 8, 83, "Message"], Cell[CellGroupData[{ Cell[55882, 1539, 154, 2, 32, "Print"], Cell[56039, 1543, 154, 2, 32, "Print"] }, Open ]], Cell[56208, 1548, 341, 8, 83, "Message"] }, Open ]], Cell[56564, 1559, 730, 13, 139, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[57331, 1577, 137, 2, 30, "Subsubsection"], Cell[57471, 1581, 204, 3, 41, "Text"], Cell[57678, 1586, 3315, 62, 593, "Input"], Cell[CellGroupData[{ Cell[61018, 1652, 477, 11, 71, "Input"], Cell[61498, 1665, 360, 8, 83, "Message"], Cell[CellGroupData[{ Cell[61883, 1677, 154, 2, 32, "Print"], Cell[62040, 1681, 154, 2, 32, "Print"] }, Open ]] }, Open ]], Cell[62221, 1687, 320, 8, 66, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[62578, 1700, 258, 6, 30, "Subsubsection"], Cell[62839, 1708, 490, 10, 90, "Text"], Cell[63332, 1720, 2163, 39, 318, "Input"], Cell[65498, 1761, 220, 4, 43, "Input"], Cell[CellGroupData[{ Cell[65743, 1769, 156, 2, 43, "Input"], Cell[CellGroupData[{ Cell[65924, 1775, 156, 2, 32, "Print"], Cell[66083, 1779, 156, 2, 32, "Print"] }, Open ]], Cell[66254, 1784, 309, 7, 58, "Message"] }, Open ]], Cell[66578, 1794, 1173, 19, 214, "Text"], Cell[67754, 1815, 501, 15, 66, "Text"], Cell[CellGroupData[{ Cell[68280, 1834, 154, 2, 43, "Input"], Cell[68437, 1838, 358, 8, 83, "Message"], Cell[CellGroupData[{ Cell[68820, 1850, 152, 2, 32, "Print"], Cell[68975, 1854, 152, 2, 32, "Print"] }, Open ]], Cell[69142, 1859, 344, 8, 83, "Message"] }, Open ]], Cell[69501, 1870, 162, 6, 41, "Text"], Cell[69666, 1878, 135, 2, 43, "Input"], Cell[69804, 1882, 108, 1, 41, "Text"], Cell[CellGroupData[{ Cell[69937, 1887, 88, 1, 43, "Input"], Cell[CellGroupData[{ Cell[70050, 1892, 150, 2, 32, "Print"], Cell[70203, 1896, 152, 2, 32, "Print"] }, Open ]] }, Open ]] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[70428, 1906, 150, 2, 40, "Subsection"], Cell[70581, 1910, 1446, 34, 166, "Text"], Cell[72030, 1946, 191, 5, 43, "Input"], Cell[72224, 1953, 3504, 68, 493, "Input"], Cell[75731, 2023, 113, 1, 41, "Text"], Cell[75847, 2026, 101, 2, 43, "Input"], Cell[75951, 2030, 163, 2, 41, "Text"], Cell[CellGroupData[{ Cell[76139, 2036, 80, 1, 43, "Input"], Cell[CellGroupData[{ Cell[76244, 2041, 178, 2, 32, "Print"], Cell[76425, 2045, 176, 2, 32, "Print"] }, Open ]] }, Open ]], Cell[76628, 2051, 153, 2, 41, "Text"], Cell[CellGroupData[{ Cell[76806, 2057, 205, 4, 43, "Input"], Cell[77014, 2063, 308, 8, 61, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[77359, 2076, 337, 8, 43, "Input"], Cell[77699, 2086, 498, 10, 112, "Output"] }, Open ]], Cell[78212, 2099, 191, 5, 43, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[78440, 2109, 123, 2, 40, "Subsection"], Cell[78566, 2113, 1199, 29, 140, "Text"], Cell[CellGroupData[{ Cell[79790, 2146, 127, 2, 41, "Subsubsection"], Cell[79920, 2150, 457, 6, 41, "Text"], Cell[80380, 2158, 456, 13, 98, "Input"], Cell[CellGroupData[{ Cell[80861, 2175, 110, 2, 43, "Input"], Cell[CellGroupData[{ Cell[80996, 2181, 118, 2, 60, "Print", CellTags->"Info3442112875-8059705"], Cell[81117, 2185, 841, 24, 32, "Print", CellTags->"Info3442112875-8059705"] }, Open ]] }, Open ]], Cell[81985, 2213, 155, 6, 41, "Text"], Cell[82143, 2221, 127, 2, 43, "Input"], Cell[CellGroupData[{ Cell[82295, 2227, 114, 2, 43, "Input"], Cell[CellGroupData[{ Cell[82434, 2233, 118, 2, 60, "Print", CellTags->"Info3442112878-7144394"], Cell[82555, 2237, 963, 28, 32, "Print", CellTags->"Info3442112878-7144394"] }, Open ]] }, Open ]], Cell[83545, 2269, 101, 1, 41, "Text"], Cell[83649, 2272, 190, 5, 43, "Input"], Cell[83842, 2279, 94, 1, 41, "Text"], Cell[CellGroupData[{ Cell[83961, 2284, 209, 4, 43, "Input"], Cell[84173, 2290, 232, 8, 49, "Output"] }, Open ]], Cell[84420, 2301, 120, 1, 41, "Text"], Cell[84543, 2304, 169, 4, 43, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[84749, 2313, 95, 1, 31, "Subsubsection"], Cell[84847, 2316, 1142, 21, 140, "Text"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[86038, 2343, 255, 6, 40, "Subsection"], Cell[86296, 2351, 290, 5, 41, "Text"], Cell[86589, 2358, 862, 19, 118, "Input"], Cell[87454, 2379, 527, 12, 66, "Text"], Cell[87984, 2393, 1638, 40, 243, "Input"], Cell[89625, 2435, 333, 6, 66, "Text"], Cell[89961, 2443, 520, 10, 90, "Text"] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell[90530, 2459, 116, 2, 105, "Section"], Cell[90649, 2463, 637, 15, 115, "Text"], Cell[91289, 2480, 1484, 37, 190, "Text"], Cell[92776, 2519, 2641, 85, 317, "Text"] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)