On Mon, Mar 27, 2023 at 6:13 PM David Bremner <da...@tethera.net> wrote: > > Felipe Contreras <felipe.contre...@gmail.com> writes: > > > We don't need a FileNames enumerable object only for a small number of > > strings, > > we can just get them directly. > > > > This iterator is meant to be transient and works only once, so we better > > just > > iterate it once. > > > > This is the same approach I took with the Tags object, I was waiting for > > feedback on that approach but since there isn't any and there's no reason > > this > > shouldn't work, here's the same for Filenames. > > Hi Felipe; > > I still haven't had a chance to look at the proposed changes, but I did > wonder what your plan was as far as migration. Usually with the library > itself we try to provide fairly smooth upgrades.
There's no migration, there's no functional changes from clients' point of view. Previously the code returned a Notmuch::Tags object, but this class included the Enumerable [1] module, making it an Enumerable. So everything you could do with an Enumerable you could do with Notmuch::Tags, for example: tags.count(). But we didn't implement all these methods, we only had to implement `each()`. If `each()` works, then everything else works. For example this class implements an Enumerable: class Foo include Enumerable def each yield 'inbox' yield 'unread' end end And then all these work: foo = Foo.new foo.each { |e| puts e } puts 'first: %s' % foo.first puts 'count: %s' % foo.count We can replace the Foo object any other kind of Enumerable, and the code works just the same: foo = %w[inbox unread] foo.each { |e| puts e } puts 'first: %s' % foo.first puts 'count: %s' % foo.count So replacing Notmuch::Tags with an array of strings doesn't change anything because both are Enumerable, and both yield Strings. Cheers. [1] https://rubydoc.info/stdlib/core/Enumerable -- Felipe Contreras _______________________________________________ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org