Having a function which returns a seq of characters, I need to modify it to allow attaching metadata to some characters (but not all). Clojure doesn't support 'with-meta' on primitive types. So, the possible options are:
- return a seq of vectors of [character, metadata];
pros: simplicity, data and metadata are tied together
cons: need to extract data from vector
- return two separate seqs, one for characters and one for metadata, caller most iterate those simultaneously if he cares about metadata;
pros: caller is not forced to extract data from each stream element and may throw away meta-sequence if he wishes
cons: need to iterate both seqs at once, more complexity on caller side if metadata is needed
- introduce some record-wrapper containing one character and allowing to attach meta to itself (Clojure records implement IMeta);
pros: data and metadata are tied together
cons: need to extract data from record
- your better option.
Which approach is better?