On Jun 8, 2009, at 17:46, samppi wrote: > ...I'd love it if the values of symbol keys could be any symbol, not > just keywords, so that the key symbol is bound to (val-symbol > the-map): > (let [{name this-is-a-symbol} person-1] ...) ; name is bound to > (this-is-a-symbol person-1) > > It's backwards-compatible. But is this possible? Practical?
I don't think it could made to be backwards-compatible. The documentation states: "Map binding-forms allow you to bind names to parts of associative things (not just maps), like maps, vectors, string and arrays (the latter three have integer keys)." The current implementation of destructuring map binding forms uses get: (destructure '[{name :name} person-1]) -> [map__268 person-1 name (clojure.core/get map__268 :name)] This works as advertised with maps, vectors, strings, etc. Your proposal would change the expansion to -> [map__268 person-1 name (:name map__268)] That works fine if person-1 is a map, but destructuring a vector with a map binding form is no longer possible. Nothing stops you from defining your own let-like macro with your own destructuring rules, of course! Konrad. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---