On Mon, Oct 20, 2008 at 1:03 PM, Parth Malwankar
<[EMAIL PROTECTED]>wrote:

>
> On Oct 20, 3:51 pm, "Fredrik Appelberg" <[EMAIL PROTECTED]>
> wrote:
> > Hi all,
> >
> > The CL feature for handling multiple return values from a function come
> in
> > really handy sometimes and make for cleaner APIs. For example, the ROUND
> > function returns the integer part of a float as the regular value (as
> this
> > is what you want most of the time), but optionally also returns the
> floating
> > point part in case you want it.
> >
> > I haven't found anything like MULTIPLE-VALUE-BIND in Clojure. Are there
> any
> > plans of incorporating any kind of mechanism for multiple return values?
>
> Hi Fredrik,
>
> Similar results can be accomplished using vectors and
> destructuring in Clojure.
>
> user=> (defn foo [] [:one :two :three])
> #=(var user/foo)
> user=> (let [[a b c] (foo)] (println b))
> :two
> nil
> user=>
>
> The destructuring capabilities of "let" are quite nice.
> A bunch of examples are available in the let reference:
> http://clojure.org/special_forms
>

I agree that Clojure's let form goes a long way towards making multiple
return values easy to handle. What's missing, though, is the ability to
return a single value or multiple values depending on the context in which
the function was called. I.e, if the call happens enclosed in
MULTIPLE-VALUE-BIND, I get all the returned values, otherwise I get a single
one.

Anyway, this is a really nifty feature in CL, but it might not be necessary
in Clojure as its 'let' form is more potent.

Cheers,
-- Fredrik
==============================================
What am I up to? http://twitter.com/appelberg

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