Mathematica: Scoping & Modularity

Favorite Article   

  • With — evaluate with specified variables replaced by values
  • Module — localize names of variables (lexical scoping)
  • Block — localize values of variables (dynamic scoping)
  • DynamicModule — localize names of variables in dynamic interface constructs
     

Constructs with Automatic Name Scoping

Function — a pure function, with formal variables automatically scoped

Rule (->), RuleDelayed (:>) — named pattern variables automatically scoped

Set (=), SetDelayed (:=) — named pattern variables automatically scoped
 

Constructs with Automatic Value Scoping

Table — create a table, with iterator variables automatically scoped

  • Do    
  • Sum  
  • Plot   
  • Plot3D   
  • NDSolve  
     

Other Forms of Scoping

  • BeginEnd — localize symbol namespace
  • ThrowCatch — localize exceptions
  • QuietCheck — localize messages
  • BlockRandom — localize pseudorandom variables

 

Referenced from: Reference.wolfram.com

 

19585
12/21/2017 1:55:25 PM