Thank you both for your answers

Regards,

Ryan

On Thursday, February 21, 2013 7:43:05 PM UTC+2, Jim foo.bar wrote:
>
>  I think Alex is trying to say that a macro is almost never appropriate 
> when a first-class function would do...therefore, there is no good reason 
> for carrying the complexity of macros all over your code, given that in 
> your case they do nothing special (like postponed evaluation) and can be 
> replaced by functions.
>
> Jim
>
>
> On 21/02/13 17:11, Ryan wrote:
>  
> I got confused a bit with the reason that a macro would not be appropriate 
> for this case. Can you please explain again? 
>
>  Ryan
>
> On Thursday, February 21, 2013 7:05:11 PM UTC+2, Alex Baranosky wrote: 
>>
>> A function could be appropriate, but a macro  not appropriate, since 
>> everything you need here can be done with using macros.
>> On Feb 21, 2013 7:53 AM, "Ryan" <areka...@gmail.com> wrote:
>>
>>> Thanks for your input Alex. 
>>>
>>>  Do you think a macro would be appropriate if I use this more than once 
>>> in my code?
>>>
>>>  Ryan
>>>
>>> On Thursday, February 21, 2013 5:41:49 PM UTC+2, Alex Baranosky wrote: 
>>>>
>>>> I'd often just write it like this: 
>>>>
>>>>  (defn create-map []
>>>>>   (merge {:foo "a"
>>>>>                :bar "b"
>>>>>                ... many more keys}
>>>>>               (when (some-condition-true)
>>>>>                  {:extra-key value)))
>>>>
>>>>
>>>>  Alex
>>>>
>>>> On Thu, Feb 21, 2013 at 7:27 AM, Ryan <areka...@gmail.com> wrote:
>>>>
>>>>> Thanks Meikel for your reply. 
>>>>>
>>>>>  It wasn't clear on my example, but I wish to use *merge *inside my 
>>>>> create-map function. Do you think I should bind my hash-map to a let 
>>>>> variable first and then apply merge, or do you have another proposal? 
>>>>> What 
>>>>> i mean is this:
>>>>>
>>>>>  (defn create-key-value [value] 
>>>>>
>>>>>  (when (some-condition-true) {:extra-key value)) 
>>>>>
>>>>>  
>>>>> (defn create-map [] 
>>>>>>   (let [my-map {:foo "a" :bar "b"}]
>>>>>>     (merge my-map (create-key-value "some-value")))
>>>>>
>>>>>
>>>>>  Is the above "clojurish" or is there a better way? For example if 
>>>>> the my-map was a big hash-map, and not with just two pairs, wouldn't it 
>>>>> be 
>>>>> ugly with the above way? or..it's just fine and no better way is possible?
>>>>>  
>>>>>  Ryan 
>>>>>   
>>>>> On Thursday, February 21, 2013 5:02:21 PM UTC+2, Meikel Brandmeyer 
>>>>> (kotarak) wrote: 
>>>>>>
>>>>>> Hi, 
>>>>>>
>>>>>>  merge works with nil. So (merge (create-map) (create-key-value 
>>>>>> "some-value")) should work as you intend with the functions as they are 
>>>>>> defined now.
>>>>>>
>>>>>>  Kind regards
>>>>>> Meikel
>>>>>>
>>>>>>   -- 
>>>>> -- 
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Clojure" group.
>>>>> To post to this group, send email to clo...@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+u...@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+u...@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 clo...@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+u...@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+u...@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 clo...@googlegroups.com <javascript:>
> Note that posts from new members are moderated - please be patient with 
> your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com <javascript:>
> 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+u...@googlegroups.com <javascript:>.
> 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.


Reply via email to