[<<][staapl][>>][..]
Sun Mar 14 21:32:58 CET 2010

Haskell vs. Scheme

Idea: pattern matching is not composable in Haskell/OCaml: syntactic
elements that cannot be abstracted over.  In Scheme this is easy.

     (patterns-class
      (macro)
      ;;----------------------------------------
      (word         opcode)
      ;;----------------------------------------
      ((1+          incf)
       (1-          decf)
       (rot<<c      rlcf)
       (rot>>c      rrcf)
       (rot<<       rlncf)
       (rot>>       rrncf)
       (rot>>4      swapf))
      ;;----------------------------------------
      (([movf f 0 0] word) ([opcode f 0 0]))
      ((word)              ([opcode WREG 0 0])))

Here the identifiers `1+',`1-',... are defined by instantiating the
two rules on the bottom, filling in `word' and `opcode' respectively.




[Reply][About]
[<<][staapl][>>][..]