New Name

Stratego -- Strategies for Program Transformation
The new primitive of the StrategoLibrary? generates a new unique name. That is, it generates a string that is guaranteed not to occur in any live term.

A way of generating a new unique string based on an existing string would be nice. Something similar to

    make-unique: s -> <conc-strings> (s, <new>())

except that this only guarantees that the <new> part is unique; the combined string could occur somewhere else, right? It would also be helpful if two calls to make-unique with different base strings didn't affect each other, so that

    <make-unique> "foo" => "foo_0"
    <make-unique> "bar" => "bar_0"       (instead of "bar_1")
    <make-unique> "foo" => "foo_1"       (instead of "foo_2")

I often end up generating source files which differ almost only in the names of temporary variables (generated with "new"), which makes them difficult to compare with diff(1). If I could generate temporaries based on the name of another variable (or the function), I could avoid affecting the names of temporaries in completely unrelated parts of the program I'm working on.

Currently, I sometimes run a sed script to make all generated names identical, before I diff(1), but that means I could end up missing a significant difference.

Looking at ssl/src/string.c, I believe I might be able to come up with an implementation, but I suspect EelcoVisser will be able to do it better, and in less time...

-- OttoSkroveBagge - 05 Feb 2002

CategoryToDo? | LibraryImprovements | ToDo