Evaluating Unevaluated Expressions
A SNOBOL pattern may not include subpatterns that haven’t been defined yet. But what if a pattern depends on a dynamically updated variable whose value changes, for example, in a loop? Shouldn’t you redefine it after every change to the variable? You can, but you don’t have to. An alternative solution is to use an unevaluated expression prefixed with an asterisk *.
An unevaluated expression is a reference to an actual expression that’s evaluated at the time of pattern matching. By that time, the values of all variables are expected to be already known.
The program that follows extracts and displays the common words in two strings. A word is defined as a substring that doesn’t contain any punctuation. The ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access