By C. Lutz and H. Derby circa 1982. Header:
This is class report but also a great design exercise in reversible programming language constructs. For example, I love how they make if conditions reversible:
if num # 1 then i += 1 ; Put last prime away, if not done fact[i] : num ; and zero num else num -= 1 fi fact[i] # fact[i-1]
Note that # means not equals; colon is used for swap (!!). The "fi" condition must match the truth value of the "if" condition so the condition can be played backwards. Loop constructs are similarly organized so they can play backwards, the language has procedures but all variables are global :).
Sadly, although there are a few follow on papers (e.g. by Yokoyama et al.) and some esoteric reversible languages like Kayak, there doesn't seem to be any other good examples of high-level serious reversible programming languages.
I would like to share this language here as it has recently had a new version released. Nimrod resembles Python in that it uses whitespace to delimit blocks and Pascal because of the way that types are defined (TType). It supports metaprogramming with macros and templates. Code example:
# compute average line length var count = 0 var sum = 0 for line in stdin.lines: count += 1 sum += line.len echo "Average line length: ", if count > 0: sum / count else: 0
Active forum topics
New forum topics