by captainmuon · 3y ago · 0 comments
I wish languages other than SQL had a concept of adding an index. Imagine a variant of Python's list or C++'s vector where you can add indicies on arbitrary fields of the contents, like a more flexible dict. Something like (pseudocode)
books = List<Book, indices=[Book.title, Book.author]>
and then you could up by title or author without traversing the whole list. Sure you can just use a separate dict, but then you have to keep both in sync, it is harder to bind it to UI controls, and so on.I want languages to do less magic, not more, since I read code more than I write it.
[1]: https://www.boost.org/doc/libs/1_82_0/libs/multi_index/doc/i...