The newname strategy is a variant of the new strategy, which generates a new unique string. Newname generates unique strings, just like new, but it also accepts a prefix that will be part of the generated string. By default, the numbering is also done per prefix. For example, if you apply newname three times to the string "foo", then the results will be "foo_0", "foo_1" and "foo_2". If newname is applied to "bar" after this, then the result will be "bar_0", not "bar_4". Thus, The newname strategy is very useful for generating more user-friendly, unique names in a program transformation.

The library strategy newname trims any trailing digits up to the rightmost '_'. Hence, repeated application of newname will not result in mutiple numeric postfixes (for example a_0_0)

Example

  <newname> "a"        // produces "a_0"
; <newname> "b"        // produces "b_0"
; <newname> "b_1"      // produces "b_2"
; <newname> "b_1729"   // produces "b_3"
; <newname> "b_a"      // produces "b_a_0"

Revision: r1.4 - 12 Apr 2004 - 20:27 - MartinBravenboer
Copyright © 1999-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback