[cl-ppcre-devel] register-groups-bind tests all groups for nil

dsb at prairienet.org dsb at prairienet.org
Fri Apr 6 15:08:46 UTC 2007


Using register-groups-bind, sbcl generates a compiler warning
if the user doesn't make sure each bound variable is non-nil before
using it.  Since the body is evaluated only if there's a match,
testing bound variables seems kind of redundant for the first
N variables, where N is the number of groups in the regex.

It looks like an IF form in register-groups-bind is the source of
the warning.  It checks all groups for nil-ness, even the first ones.
I thought variables that match groups would be guaranteed to be non-nil.
I would be nice to be able to use matching variables immediately
as long as the user is careful not to bind extra ones.

I guess eliminating individual tests for bound groups would require
that scan returns another value containing the number of matches,
or truncates the register-groups array so that the number of matches
is just the length of the array.   Then matching variables could be
bound directly, and extras could be set to nil without the IF.

--Dan
prairienet.org/~dsb/




More information about the Cl-ppcre-devel mailing list