On Sep 10, 5:01 pm, Allen Rohner <[EMAIL PROTECTED]> wrote:
> > For very short functions one can use the cut notation: #(...). In case
> > there are several functions or functions going over several lines, this
> > is a sign that they should go into an own defn(-) with appropriate
> > docstring.
>
Sorry, emacs again. I'm having the stupids today.

Maybe the solution is to use defn-. Scheme made me used to the local
function approach for encapsulation. I don't have a problem with doing

 (defn foo [x]
     (defn bar [y]
       "doc string")
     (defn baz [z]
       "doc string2")
     (do_stuff (bar[x]))

except that the interior defns are public. To me, the local functions
are a stronger indication that bar and baz are *only* used inside foo.
That indication isn't as apparent with


(defn bar [y]
   ...)

(defn baz [z]
  ...)

(defn foo [x]
  (do_stuff (bar x)))

As an aside, how is (defn- ) supposed to work? private symbols cannot
be referred to outside of the namespace? The macroexpand looks
identical:

user=> (macroexpand '(defn- foo [x] x))
(def foo (clojure/fn ([x] x)))
user=> (macroexpand '(defn foo [x] x))
(def foo (clojure/fn ([x] x)))

Allen



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to [email protected]
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