Changes between Initial Version and Version 1 of RefactoringSteps/EliminateVariable


Ignore:
Timestamp:
Feb 18, 2012, 3:46:19 PM (13 years ago)
Author:
manualwiki
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • RefactoringSteps/EliminateVariable

    v1 v1  
     1= Eliminate variable = 
     2 
     3In this refactoring, all instances of a variable are replaced with its bound value. Those instances of the variable where the value of the instance is not used can be dropped. 
     4 
     5Replacing all instances of variable {{{Y}}} with its value: 
     6 
     7{{{ 
     8func(X) -> 
     9   Y=X+2, 
     10   Pid ! {value,Y}, 
     11   Y. 
     12}}} 
     13 
     14Result: 
     15 
     16{{{ 
     17func(X) -> 
     18 
     19   Pid ! {value,X+2}, 
     20   X+2. 
     21}}} 
     22 
     23== Side conditions == 
     24 
     25 * The variable has exactly one binding occurrence on the left hand side of a pattern matching expression, and not a part of a compound pattern. 
     26  
     27 * The expression bound to the variable has no side effects. 
     28 
     29 * Every variable of the expression is visible (that is, not shadowed) at every occurrence of the variable to be eliminated. 
     30 
     31 * If the selection is not specify a variable but it is inside a function clause, the tool gives a list to the user to select a variable. The list contains the reachable variables in the given function clause. 
     32 
     33 
     34== Transformation steps and compensations == 
     35 
     36 1. Every occurrence of the variable is substituted with the expression bound to it at its binding occurrence, with parentheses around the. 
     37 
     38 2. If the result of the match expression that binds the variable is discarded, the whole match expression is removed. Otherwise, the match expression is replaced with its right hand side.