On Oct 20, 7:03 am, 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
>
We could further combine this by making a scalar equivalent to a
vector of length 1; that way, users who expect a function to return
one value would not be confused when a vector is returned instead.

There's a problem, of course -- how to distinguish between vector-as-
holder-of-return-values and vector-as-the-returned-value ?

Cheers,

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