thephoeron / let-over-lambda

Doug Hoyte's "Production" version of macros from Let Over Lambda, ready for ASDF and Quicklisp.
Other
134 stars 25 forks source link

Change from ppcre:scan to ppcre:scan-to-strings #12

Closed EuAndreh closed 9 years ago

EuAndreh commented 9 years ago

ppcre:scan-to-strings gives a more practical usage to the #~m macro, as far as pilfering Perl's syntax goes.

EuAndreh commented 9 years ago

I've also changed the if-match macro: now it works nested:

* (when-match (#~m_a(b)c_ "abc")
      (when-match (#~m_(f)(g)h_ "fgh") 
          (print $1)
          (print $2))
      (print $1)
      t)
; "f"
; "g"
; "b"
; => T

* (when-match (#~m_a(b)c_ "abc")
      (when-match (#~m_(f)(g)h_ "fgh") 
          (print $1)
          (print $2))
      (print $1)
      (print $2)
      t)
; "f"
; "g"
; "b"
; => ERROR: Too few matchs: $2 unbound.
EuAndreh commented 9 years ago

Instead of an error, uncaptured variables could also return nil.

thephoeron commented 9 years ago

Neat.