One of the sweet things about Lisp (some part of which I could have done in Ruby, my other language) ist that it prints structures in a format Lisp can read back. Thus, rather than custom-code a configuration format, I can take the printed output from a working card reader and include it as a list of configuration settings; Lisp will read it into the correct C-flavored structure (thanks to Swig and clisp).
Then, I can mapcar through the list, applying a generic function set-config to each entry: the GF's methods call the correct configuration function based on the structure that Lisp re-created from the original config output.
This gives me bit-level access to the configurations, without having to hand-code a config-to-struct transform, etc. In addition, the configuration entries are readable, since the Lisp structure I/O is readable: instead of
Code: Select all
BIT_SETTINGS = [[0,0,16,26], [1,1,16,26], [1,1,25,32]]
Code: Select all
(defvar mt-config
(list #S(PCPROX-API::ID-BIT-COUNTS :LEAD-PARITY 1
:TRAILING-PARITY 1
:ID 16
:TOTAL 26
:IPAD4 0
:IPAD5 0
:IPAD6 0
:IPAD7 0)
...))