Add methods to program literals.
Literals, such as numbers and strings, often make a good starting point for DSL expressions. Traditionally, however, they are built-in types with fixed interfaces, so you can’t extend them. More languages now allow you to add methods to third-party classes using techniques like C#’s extension methods and Ruby’s open classes. This capability is particularly handy for DSLs, as it allows you to start a method chain with a literal.
As with most method chains, one important decision is whether to use an Expression Builder. If you don’t use an Expression Builder, you have to ensure that all the intermediate types have the appropriate fluent methods defined ...