Closed jpellegrini closed 10 months ago
The reference implementations of SRFIs 227 (optional lambda) and 232 (currying) use ellipsis patterns in improper lists,
Ha ha! I just realized you already implemented SRFI 227. Anyway, 232 is ready!
Great!!! Thanks @jpellegrini. I'm merging it immediately.
Hi @egallesio !
The reference implementations of SRFIs 227 (optional lambda) and 232 (currying) use ellipsis patterns in improper lists, and STklos currently doesn't handle those. This patch fixes that. Maybe this also allows us to bring the reference implementation of SRFI 197 (pipeline operators), butI didn't test that.
See the description:
mbe:matches-pattern?
andmbe:get-bindings
did not account for the presence of an ellipsis pattern in an improper list, as in(a b ... c . d)
. It would calllength
on the list tail after the ellipsis, which would signal an error.So, we:
Create
split-improper-tail
, which splits the list into lst-CDR and everything but it.(split-improper-tail '())
=> values'(), '()
(split-improper-tail '(1 2 3))
=> values'(), '(1 2 3)
(split-improper-tail '(1 2 . 3))
=> values'(3), '(1 2)
Change
mbe:matches-pattern?
andmbe:get-bindings
to usesplit-improper-tail
Since we were there, document those procedures a bit. :)
And, of course, include some tests...