Wow ! Thanks for the link Jozef.
Another question -
>From the Stuart Sierra blog on Lifecycle Composition -
(defrecord Database [uri connection-atom]
Lifecycle
(start [_]
(future (reset! connection-atom (connect uri))))
(stop [_]
(.close @connection-atom)
(future (reset! connection-atom nil))))
(defn database [uri]
(->Database uri (atom nil)))
I know I can create record objects as (Database. uri (atom nil))
However I cant understand how and why the above (-> Database uri (atom
nil)) works ?
Thanks,
Murtaza
On Thursday, September 19, 2013 9:04:53 PM UTC+5:30, Jozef Wagner wrote:
>
> The example you've given is just a stub, not a full implementation of the
> record. The magic is happening in emit-defrecord
> https://github.com/clojure/clojure/blob/master/src/clj/clojure/core_deftype.clj#L148
>
> Best,
> JW
>
>
>
> On Thu, Sep 19, 2013 at 5:21 PM, Murtaza Husain <
> [email protected] <javascript:>> wrote:
>
>> Hi,
>>
>> I was going through the article regarding clojure protocols and datatypes
>> -
>> http://www.ibm.com/developerworks/java/library/j-clojure-protocols/index.html
>>
>> In it an example is given for a new defrecord that the author creates.
>> The generated java source for the record as given in the article -
>>
>> public class PurchaseOrder
>> implements Fulfillment,
>> java.io.Serializable,
>> java.util.Map,
>> java.lang.Iterable,
>> clojure.lang.IPersistentMap {
>>
>> public final Object date;
>> public final Object customer;
>> public final Object products;
>>
>> public PurchaseOrder(Object date, Object customer, Object products) {
>> this.date = date;
>> this.customer = customer;
>> this.products = products;
>> }
>> }
>>
>>
>> My question - I can see that the generated class implements the
>> java.util.Map and clojure.lang.IPersistentMap interfaces. However where are
>> the code for implementations of the interfaces ? I do not see any concrete
>> code other than the constructor and some fields.
>>
>> Thanks,
>> Murtaza
>>
>> --
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to [email protected]<javascript:>
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> [email protected] <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 [email protected] <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 [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.