Working on Pharo Smalltalk: BPatterns: Rewrite Engine with Smalltalk Style
4 hours ago
- #Smalltalk
- #Refactoring
- #BPatterns
- The rewrite engine, introduced by John Brant and Don Roberts in 1997, provides AST-level matching and rewriting with significant power.
- Despite its power, the syntax of the rewrite engine is difficult to remember, even for simple tasks like replacing deprecated messages.
- BPatterns offer a fluent, Smalltalk-native API on top of the rewrite engine, using ordinary Smalltalk blocks as patterns.
- BPatterns eliminate the need for remembering complex syntax by providing a more approachable and scriptable interface.
- BPatterns allow for refining patterns explicitly using the #with: message, enabling more precise matching and rewriting.
- Message patterns in BPatterns can be refined and configured with arbitrary conditions, making them highly flexible.
- BPatterns do not yet expose every feature of the rewrite engine but support many, including full method patterns via #bmethod.
- The GitHub repository provides full details on BPatterns, and a future blog post will discuss a simplified deprecation API built on top of BPatterns.