This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-09
Channels
- # adventofcode (201)
- # bangalore-clj (5)
- # beginners (90)
- # cider (1)
- # cljs-dev (3)
- # cljsrn (28)
- # clojure (128)
- # clojure-argentina (1)
- # clojure-brasil (15)
- # clojure-dev (9)
- # clojure-greece (18)
- # clojure-italy (11)
- # clojure-madison (1)
- # clojure-poland (19)
- # clojure-russia (28)
- # clojure-spec (33)
- # clojure-uk (26)
- # clojurescript (20)
- # core-async (2)
- # cursive (1)
- # datomic (2)
- # emacs (4)
- # figwheel (3)
- # fulcro (15)
- # graphql (7)
- # hoplon (1)
- # lein-figwheel (2)
- # lumo (2)
- # numerical-computing (3)
- # off-topic (9)
- # re-frame (13)
- # ring (1)
- # shadow-cljs (1)
- # unrepl (1)
- # vim (17)
Hi guys, I write articles on Clojure on a daily basis taking brave clojure as a reference. Check out my latest article on Functions in Clojure: Day 4 : https://medium.com/@abiduzair420/functions-in-clojure-day-4-6a38c6e18661
@abiduzair420 nice effort. Here's another way to differentiate macros vs functions: What is a function? A function is a mappings of data -> data, that evaluates at run time. So, functions are used to consume and produce run-time data and side-effects. What is a macro? A macros is also a mapping of data -> data, but one that evaluates at compile time. So, macros are used to do source code transformations at compile time. Functions can also be used to manipulate s-expressions. See, for example, lines 121 to 197 here: https://github.com/technomancy/leiningen/blob/master/src/leiningen/repl.clj#L121
Heyy @U051MHSEK Thanks for the explanation. I didn't know about the compile/runtime diff b/w function and a macro.
This is also the reason why one can't pass a macro as an argument to a function. i.e. while macros are also functions of data->data, they are not "first-class", because they are meaningless in a run-time context. An unevaluated macro would be meaningless at run-time, because it can't do anything with the source code any more.
Ooh, this thread has appeared an opportune moment. Directly related to what we are discussing now ... https://clojurians.slack.com/archives/C06E3HYPR/p1512859240000027
@abiduzair420 nice effort. Here's another way to differentiate macros vs functions: What is a function? A function is a mappings of data -> data, that evaluates at run time. So, functions are used to consume and produce run-time data and side-effects. What is a macro? A macros is also a mapping of data -> data, but one that evaluates at compile time. So, macros are used to do source code transformations at compile time. Functions can also be used to manipulate s-expressions. See, for example, lines 121 to 197 here: https://github.com/technomancy/leiningen/blob/master/src/leiningen/repl.clj#L121