The functions Rule, Set, UpSet, TagSet each evaluate their right side immediately. If these functions have named patterns on the left side and the symbols used to name the patterns are needed on the right side then the global values of these symbols are used on the right side. To get the intended result you must ensure these symbols have no global values. This is demonstrated in the (LocalPatterns.nb) notebook.

The package (LocalPatterns.m) defines functions that work like Rule, Set, UpSet, TagSet but don't have the problem described above. All functions in the package are demonstrated and explained in the notebook (LocalPatterns.m).

LocalPatterns.m uses four special characters. A modified version of the BasicInput palette is provided to assist with entering the special characters. The modified palette is also explained in the (LocalPatterns.nb) package.