I've been bitten by this before.

Unless there's a good reason for :or to work the way it does I think
that would be a good idea,
since then you can define "default" maps somewhere else and use those
both with the :or keyword or when
calling the function itself.

Maybe the :or map can just be underlaid with the actual map being used
to call the function?


--Robert McIntyre

On Sun, Sep 12, 2010 at 9:21 PM, Tom Hicks <hickstoh...@gmail.com> wrote:
> I just noticed this unexpected result for Map destructuring with an
> <quote>:or</quote> directive:
>
> <pre>
> user=> (def guys-name-map {:f-name "Guy" :l-name
> "Steele"})
> #'user/guys-name-map
>
> user=> (let [{:keys [f-name m-name l-name] :or {:m-name "CL"}} guys-
> name-map] (str l-name ", " f-name "+" m-name))
> "Steele, Guy+"
>
> user=> (let [{:keys [f-name m-name l-name] :or {m-name "CL"}} guys-
> name-map] (str l-name ", " f-name "+" m-name))
> "Steele, Guy+CL"
> </pre>
>
> Note that the <quote>:or</quote> directive does not seem to respect/
> use the preceeding :keys directive and appears to be doing its lookup
> using symbols only. Was this the intended behavior?
>
> Wouldn't it be more useful to extend the behavior of <quote>:or</
> quote> to use the same lookup method (:keys, :strs, or :syms) as
> specified in the (same) preceeding map context?
>
> --
> 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

-- 
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

Reply via email to