On Jul 2, 2009, at 11:48 AM, BerlinBrown wrote:

>
> I posted a thread about side-effects.  Some one replied that your
> clojure functions should return a value.  This is good advice, but I
> have code that sometimes return nil.  Is it better to return 'nil' or
> an object with no data.  I guess a simple example, if you have a
> function that returns a string. Should you return a valid string or a
> zero length string for all of your functions.


I don't really understand your example. A zero length string is a  
valid string. Could you elaborate?

If your function is called simply for its side effect, the return  
value isn't very important. But if it's guaranteed to work and takes a  
single parameter I usually just return the argument. That way you can  
stack your function calls. In general it's a good idea to separate the  
logic from the side effects. It makes testing easier and pure  
functions are more composable and reusable.

—
Daniel Lyons


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

Reply via email to