On Mon, Oct 5, 2009 at 2:38 PM, Meikel Brandmeyer <m...@kotka.de> wrote:
> Hi, > > Am 05.10.2009 um 19:29 schrieb cody koeninger: > > Here we have the smell! You cannot define functions with a function. >>> You have to use a macro! >>> >> >> I am not clear on what you mean by this. From a user's point of view, >> what is the difference between defining a function, and interning a >> var with a fn object as its value? >> >> user> (defn define-function [name] (intern *ns* name (fn [] (str >> "called a generated function: " name)))) >> #'user/define-function >> user> (some-function) >> ; Evaluation aborted. >> user> (define-function 'some-function) >> #'user/some-function >> user> (some-function) >> "called a generated function: some-function" >> >> Or is your point just that #'fn is a macro? >> > > I stand corrected. I'd argue that you can define a function within a function, but that interning a var within a function is a smell, and doing it with a constant, rather than argument-supplied or computed, name, in a function or in a macro, is a stench (e.g. (defn foo [x y z] (defn bar ... ))) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---