Thank you. In this case(although I have zero xp with records) I would probably opt for making a wrapper function and have it always be used in any instance when records are to be gotten like that, even though I understand it would be a performance hit (maybe I could make it a macro which I could change in release to return the (:keyword record) thing instead of whatever I decide to use to make sure record isn't nil first)
On Tue, Jan 29, 2013 at 4:35 AM, Joseph Smith <j...@uwcreations.com> wrote: > The problem with this approach is if your map is a record (e.g. made with > defrecord) it will not work. > > > --- > Joseph Smith > j...@uwcreations.com > @solussd > > > On Jan 28, 2013, at 8:31 PM, AtKaaZ <atk...@gmail.com> wrote: > > I would use (map :keyword) myself, for that exact reason(because I'm into > fail-fast), but only when I know the map is expected to never be nil at > this point(but likely I'll do the program in such a way that this point > won't be reached with a nil map in the first place), so that if it happens > that the map is nil it will throw exception at this point and it will stop > the bug propagating further, but if I were to use (:keyword map) it may err > later or never. Sure I could use other ways to test for nil, but just in > case I forget to do so, (map :keyword) would save me where (:keyword map) > would just continue. I note that it's idiomatic clojure to use the latter > variant (ie. non-fail-fast). > > - says the guy(me) that hasn't done any program(in clojure anyway) > > > On Tue, Jan 29, 2013 at 3:09 AM, James Xu <xumingming64398...@gmail.com>wrote: > >> (:Keyword map) is preferred, because keyword itself can never be nil, >> while it's possible for map, you might be interested to have a look at: >> https://github.com/bbatsov/clojure-style-guide >> >> From: Jonathon McKitrick <jmckitr...@gmail.com> >> Reply-To: <clojure@googlegroups.com> >> Date: Mon, 28 Jan 2013 18:00:01 -0800 (PST) >> To: <clojure@googlegroups.com> >> Subject: Best practice - (:keyword map) versus (map :keyword) >> >> Either one works, is there any kind of guideline on which to prefer, >> when? Or is it entirely personal preference? It seems each way could be >> more readable in different circumstances.... >> >> -- >> -- >> 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 unsubscribe from this group and stop receiving emails from it, send an >> email to clojure+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> >> -- >> -- >> 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 unsubscribe from this group and stop receiving emails from it, send an >> email to clojure+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > > > -- > Please correct me if I'm wrong or incomplete, > even if you think I'll subconsciously hate it. > > -- > -- > 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 unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > > > -- > -- > 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 unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.