Re: Using a function to def other functions?

2016-08-08 Thread fahptv
Ah, are you saying the binding isn't taking place at the top level because I had to call 'bar' to get the right hand side (so to speak) of the binding? And if 'bar' were a macro instead, then it would be expanded first and then nothing would have to be evaluated before binding to 'foo', and so

Re: Using a function to def other functions?

2016-08-08 Thread Andrew C
I don't understand -- How am I using 'def' in a non-top-level-form? I thought I was calling 'bar', getting the result which is a function, and binding that function to a name 'foo', where the binding is 'def' at the top level. Is that not what I'm doing? I'm trying to avoid the use of

Re: Using a function to def other functions?

2016-08-08 Thread Gregg Reynolds
On Aug 8, 2016 1:52 PM, wrote: > > user> (macroexpand-1 '(defn foo [x] (inc x))) > (def foo (clojure.core/fn ([x] (inc x > > If defn is just a macro, then it seems I can do this: > > user> (defn bar [] (fn ([x] (inc x > #'user/bar > > user> (def foo (bar)) > #'user/foo >

Re: Using a function to def other functions?

2016-08-08 Thread adrian . medina
def isn't a good example actually because it's a special form. But the same principle applies when using it as a non-top level form. On Monday, August 8, 2016 at 5:30:12 PM UTC-4, adrian...@mail.yu.edu wrote: > > defn, def, etc are what I mean by "defining macros". > > On Monday, August 8,

Re: Using a function to def other functions?

2016-08-08 Thread adrian . medina
defn, def, etc are what I mean by "defining macros". On Monday, August 8, 2016 at 5:19:04 PM UTC-4, fah...@gmail.com wrote: > > Oh... 'bar' and 'make-step' count as macros? My intent was that they're > ordinary functions that return functions. Am I mistaken? Or does the issue > you referred

Re: Using a function to def other functions?

2016-08-08 Thread fahptv
Oh... 'bar' and 'make-step' count as macros? My intent was that they're ordinary functions that return functions. Am I mistaken? Or does the issue you referred to apply to using defining *functions and macros *as non-top-level forms? (defn bar [] (fn ([x] (inc x (defn make-step

Re: Using a function to def other functions?

2016-08-08 Thread adrian . medina
Using defining macros as non top-level forms may not be forbidden by the language but its use is generally discouraged. See http://clhs.lisp.se/Issues/iss104_w.htm for a discussion about this issue in Common Lisp for some background context. In short, compile time effects may not be captured

Using a function to def other functions?

2016-08-08 Thread fahptv
user> (macroexpand-1 '(defn foo [x] (inc x))) (def foo (clojure.core/fn ([x] (inc x If defn is just a macro, then it seems I can do this: user> (defn bar [] (fn ([x] (inc x #'user/bar user> (def foo (bar)) #'user/foo user> foo #function[user/bar/fn--10778] But the result is a little