robrix/RXPreprocessing — pull request #3 by jasongregori (2013-03-04 04:31:44+00:00)
Title: Fixed interpolation bug caused by fixed fold logic

`rx_q` broke after the fold logic was fixed.

Before `rx_q` relied on the fact that the first argument (an empty argument) to `rx_fold` was passed in as the first argument in the first call to `_rx_q_format_each`, which just passed it back out untouched. The empty argument was then ignored in the other preprocessing logic.

After `rx_fold` was fixed, the empty argument was passed into the last call of `_rx_q_format_each` as the second argument, which would break the call to `rx_f`.

Now the last argument is passed in as the first argument in the first call to `_rx_q_format_each`. I tried moving the empty argument to the end, but the preprocessor optimized it out so when you used `rx_q` with one argument, there was an error. The solution I came up with is to use `nil` as the "empty argument". It gets passed in as the first argument in the first call to `_rx_q_format_each` which passes it harmlessly to the end of arguments. To deal with that, I had to use `+[NSArray arrayWithObjects:]` to swallow the `nil`.

Sorry for the long explanation, I needed it to convince myself. All these macros calling other macros is confusing :)

I have some tests set up here if you want to confirm: https://github.com/jasongregori/RXPreprocessingTests (use the interpolation-bug branch).