Thanks Stu! I wasn't aware of the meta function. That helps a lot!

I looked for occurrences of "(meta " throughout the clojure and
clojure-contrib repositories, but I didn't find a function that prints
the code for a given function. That would be incredibly useful for
learning! Does anybody know what function does that and whether it is
part of clojure-contrib?

On Wed, Nov 19, 2008 at 4:09 PM, Stuart Halloway
<[EMAIL PROTECTED]> wrote:
>
> Hi Mark,
>
> The metadata points to the source:
>
> user> (meta #'with-open)
> {:doc "bindings => name init\n\n  Evaluates body in a try expression
> with name bound to the value of\n  init, and a finally clause that
> calls (.close name).", :ns #<Namespace clojure.core>, :arglists
> ([bindings & body]), :file "core.clj", :name with-open, :macro
> true, :line 1752}
>
> If you look through the archive I believe somebody posted code that
> uses the metadata to locate the source and display it at the REPL.
>
> Stu
>
>>
>> On Wed, Nov 19, 2008 at 2:45 PM, prhlava <[EMAIL PROTECTED]>
>> wrote:
>>>
>>>
>>> Hello again,
>>>
>>> Thank you all for the posts and explanations,
>>>
>>> After getting the clojure SVN version and few tweaks in the code, the
>>> working result looks like:
>>>
>>>                    (with-open [ofile (new java.io.FileOutputStream
>>>                                       (str result-directory
>>>                                            "/"
>>>                                            (make-filename x y))
>>>                                       (boolean true))] ; I am
>>> appending only
>>>                               (. ofile write
>>>                             (into-array Byte/TYPE
>>>                                         [(byte (bit-shift-right pix
>>> 16))
>>>                                          (byte (bit-shift-right pix
>>> 8))
>>>                                          (byte pix)])) ; the pix is
>>> of the Integer type
>>
>> It looks like with-open accepts any number of bindings. Does it just
>> call close on the first one when the body finishes or on all of them?
>>
>> If I wanted to figure this out for myself, how would I find the source
>> code for with-open?
>>
>> --
>> R. Mark Volkmann
>> Object Computing, Inc.
>>
>> >
>
>
> >
>



-- 
R. Mark Volkmann
Object Computing, Inc.

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

Reply via email to