Re: another question on macros defining functions

2011-06-04 Thread jweiss
If you are connected to a swank server, have you tried C-c C-k to compile the file you're editing? On Jun 4, 1:15 am, nil wrote: > Mark, it turns out that everything I need is known and static at hack- > time. (Sorry for making it sound otherwise) I know all the names, > values, *and* behaviors

Re: another question on macros defining functions

2011-06-04 Thread Mark Nutter
Ok, so what you really want is not to change how your program functions, but how your IDE/editor functions. That means what you really want is not a clojure macro, but an emacs macro--you want to extend the functionality of emacs to make your editing easier. The clojure code you write is not going

Re: another question on macros defining functions

2011-06-03 Thread nil
Mark, it turns out that everything I need is known and static at hack- time. (Sorry for making it sound otherwise) I know all the names, values, *and* behaviors that I want to use when I'm writing the code for my tests. I just want my clojurebox symbol completion to work after having written a bunc

Re: another question on macros defining functions

2011-06-03 Thread Ken Wesson
On Fri, Jun 3, 2011 at 10:36 AM, nil wrote: >> The problem here is that macros run at compile time, but let bindings >> exist at run time. >> >> If you need the name to be determined at run time you will need to use eval. > > Where do I use eval? I tried looking at the argument to see if it was >

Re: another question on macros defining functions

2011-06-03 Thread Mark Nutter
I think you have the right idea, only not quite. :) If you write a macro to define a function whose name is determined at run-time, you end up with either a function that your program will never refer to, or a program that calls functions that may or may not exist, depending on what run-time values

Re: another question on macros defining functions

2011-06-03 Thread nil
> The problem here is that macros run at compile time, but let bindings > exist at run time. > > If you need the name to be determined at run time you will need to use eval. Where do I use eval? I tried looking at the argument to see if it was called with a string literal vs a symbol, but can't ev

Re: another question on macros defining functions

2011-06-03 Thread jweiss
As Ken said, you have to remember macros expand at compile time. Think of a macro call as "folded up code" that the compiler unfolds for you. A macro saves you from writing repetitive code. But if you are trying to define a function whose name isn't known until runtime, that's a whole different t

Re: another question on macros defining functions

2011-06-02 Thread Daniel Renfer
I'm sorry. I misread something in the OP. ignore me, I got nothing. On Fri, Jun 3, 2011 at 1:16 AM, Daniel Renfer wrote: > user> (defmacro foo [x] >        (let [name# (symbol (str "foo-" x))] >          `(defn ~name# [] ( > #'user/foo > user> (let [eff "gee"] (foo eff)) > #'user/foo-eff > >

Re: another question on macros defining functions

2011-06-02 Thread Daniel Renfer
user> (defmacro foo [x] (let [name# (symbol (str "foo-" x))] `(defn ~name# [] ( #'user/foo user> (let [eff "gee"] (foo eff)) #'user/foo-eff On Fri, Jun 3, 2011 at 12:13 AM, Ken Wesson wrote: > On Thu, Jun 2, 2011 at 11:07 PM, Daniel Renfer wrote: >> You don't need to use e

Re: another question on macros defining functions

2011-06-02 Thread Ken Wesson
On Thu, Jun 2, 2011 at 11:07 PM, Daniel Renfer wrote: > You don't need to use eval to create a function dynamically in a macro. You don't need to use eval to create a function via a macro at compile time. But to create a function and intern it in a var whose name is not known until run time is qu

Re: another question on macros defining functions

2011-06-02 Thread Daniel Renfer
You don't need to use eval to create a function dynamically in a macro. For an example, take a look at: https://github.com/duck1123/ciste/blob/master/src/main/clojure/ciste/sections.clj#L34 On Thu, Jun 2, 2011 at 10:34 PM, Ken Wesson wrote: > On Thu, Jun 2, 2011 at 10:06 PM, nil wrote: >> Hi >>

Re: another question on macros defining functions

2011-06-02 Thread Ken Wesson
On Thu, Jun 2, 2011 at 10:06 PM, nil wrote: > Hi > > Here's another macro-noob question. (Thanks for the help on the > previous question and please do let me know if stackoverflow is a more > appropriate place to ask noob questions.) > > I'm trying to write a macro (or a function) that defines/dec

another question on macros defining functions

2011-06-02 Thread nil
Hi Here's another macro-noob question. (Thanks for the help on the previous question and please do let me know if stackoverflow is a more appropriate place to ask noob questions.) I'm trying to write a macro (or a function) that defines/declares specifically named functions. In (let [eff "gee"] (