Thanks for the advice, Timothy. I think this is probably much cleaner than
where I ended up, and good advice. I'll let you know how it goes.

On Fri, Apr 24, 2015 at 10:45 AM, Timothy Baldridge <tbaldri...@gmail.com>
wrote:

> This is a situation where I reach for eval. Construct your reify call as
> if you were inside a macro, but instead of returning data from the macro,
> call (eval form). The call to reify will be slow (and could cause permgen
> problems), but if you wrap the form in a function you can cache the
> function and avoid that problem. Something like:
>
>
> (let [cache (atom {})]
>   (defn implement-at-runtime [interface-name method-name & body]
>     (if-let [result (@cache [interface-name method-name body])]
>       (result)
>       (let [f (eval `(fn []
>                        (reify
>                          ~interface-name
>                          (~method-name ~@body))))]
>         (swap! cache assoc [interface-name  method-name body] f)
>         (f)))))
>
> @(implement-at-runtime 'clojure.lang.IDeref 'deref '[this] 42)
> ;; returns 42
>
> Timothy
>
> On Fri, Apr 24, 2015 at 8:14 AM, Steven Deobald <ste...@nilenso.com>
> wrote:
>
>> Okay, Brian. I'll bite. :)
>>
>> I don't have the answer for you, but I'm definitely curious what your use
>> case is. Whatcha upto?
>>
>> Steven Deobald -- ⌀ -- nilenso.com
>>
>> On Fri, Apr 24, 2015 at 7:18 PM, Brian Guthrie <btguth...@gmail.com>
>> wrote:
>>
>>> Hi all,
>>>
>>> Is there a good way to reify protocols programmatically, i.e., by
>>> passing data structures rather than dropping down into a macro? reify
>>> bottoms out in reify*, which doesn't help much.
>>>
>>> Thanks,
>>>
>>> Brian
>>>
>>> --
>>> 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/d/optout.
>>>
>>
>>  --
>> 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/d/optout.
>>
>
>
>
> --
> “One of the main causes of the fall of the Roman Empire was that–lacking
> zero–they had no way to indicate successful termination of their C
> programs.”
> (Robert Firth)
>
> --
> 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/d/optout.
>

-- 
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/d/optout.

Reply via email to