Characterizing StringTemplate

ST is a dynamically typed, pure functional language with dynamic scoping and lazy evaluation. Those fancy terms highlight some important characteristics, so let’s define them:

  • Dynamically typed: ST uses toString to convert attributes to string values. Since all Java objects answer this method, ST works with any Java object. Also, if you ask for property b of attribute a (with a.b), it’s up to you to make sure attribute a has that property at run-time. Python and Ruby programmers should feel very much at home.

  • Pure functional: All expressions are side-effect free. There’s no direct way for ST to alter data values or data structures that we pass in. (Well, you could code a toString method to erase the hard drive, but ...

Get Language Implementation Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.