|strings.arc defines endmatch as|
yet, this seems to do the expected job:
(mac endmatch (pat string)
(w/uniq (gstring glen)
`(withs (,gstring ,string ,glen (len ,gstring))
(unless (> ,(len pat) (len ,gstring))
(and ,@(let acc nil
(forlen i pat
(push `(is ,(pat (- (len pat) 1 i))
(,gstring (- ,glen 1 ,i)))
What's more, this doesn't work
(def match-end (pat str)
(is (cut str (-:len pat)) pat))
, because endmatch is expecting a literal string for its "pat" argument - "pat" is not unquoted anywhere inside endmatch.
(endmatch (get-a-string-from-somewhere) str)
Is endmatch more efficient? Or what is the advantage of writing it this way?