Skip to content
  • Marc Coiffier's avatar
    Add a templating feature to all concatenative languages implemented with... · 1d045b9d
    Marc Coiffier authored
    Add a templating feature to all concatenative languages implemented with Algebra.Monad.Concatenative
    
    At its simplest, a template is just a regular quote (between '{' and
    '}'). Inside a template, you can drill some holes with the syntax {@
    code... @}. The holes thus drilled are automatically filled from left
    to right when the template is instanciated, that is, when its value
    comes into scope.
    
    For example, you can write a generic function to define custom
    setters for individual variables like so :
    
      'defvar { dup "set-%s" format { {@ swap @} swap def } def } def
      'A defvar 'B defvar
      3 set-A 5 set-B
      A B + A *
    1d045b9d