tonsky / tongue

Do-it-yourself i18n library for Clojure/Script
Eclipse Public License 1.0
307 stars 19 forks source link

It should not try to call vectors with 0 arguments #2

Closed gacelita closed 3 years ago

gacelita commented 8 years ago

In core.cljc: (if (ifn? t) (t) t)))

I think it should be: (if (fn? t) (t) t)))

This way, vectors stop being called with 0 arguments.

tonsky commented 8 years ago

Why exactly is it happening? Are you putting vector in dictionary? Why? It’s actually perfectly valid to return substitute of functions (e.g. maps) as well as real functions from dictionary.

gacelita commented 8 years ago

I am building a personal website. The website has a list of works. The works have a description that has to be translated in English and Spanish. So I put the works (which are stored in a vector) in the dictionary. Is this a bad idea? Should it be a list instead?

I know that I can store functions in the dictionary, but I do not want to store a function whose only purpose is to return the vector. I chose to fork tongue and make the change I mentioned here.

tonsky commented 8 years ago

Interesting, I haven't envisioned tongue to be a storage for any random stuff, only strings. But your use-case makes sense, I'm thinking now how to better address it without sacrificing agility that ifn provides. Any ideas (besides chaning to fn?)

gacelita commented 6 years ago

Revisiting this, it's not that difficult to simply dispatch the proper collection without putting the collections inside tongue's dictionaries. Putting a large, dynamic amount of data inside the dictionaries does not seem like a good practice.

You can close this, if you want. Greets!