Stuart Sierra wrote:
> > - The reader performs a few substitutions, then gives the resulting
> > code to the compiler.
> > - The compiler starts by expanding macros into their substitution.
> > --- Thus, for functions, there's no such thing as macros.
> > --- Thus, all that functions see of mac
Hi Daniel,
On Jan 16, 6:54 pm, Daniel Jomphe wrote:
> I'll tell you my current understanding of how Clojure works, so you
> can correct me where I may be wrong:
>
> - The compiler has for target a living environment; thus, it's
> dynamic.
> - There's no interpreter; thus, the following points wi
Stuart Sierra said:
> It's not covered much. You get used to it. Think of it this way -- macros
> only exist during compilation. Functions like "apply" get evaluated at
> run-time. A macro like "and" has no value at run-time, so you can't use it
> as an argument to a function.
I'll tell y
On Fri, Jan 16, 2009 at 3:41 PM, Michael Reid wrote:
>
>> Is there anyway to write a macro/function that acts as a function when
>> necessary (so it can be passed as an argument), but expands into a
>> macro (for speed) when deemed possible?
>
> I don't think this is possible without some sort of
> Is there anyway to write a macro/function that acts as a function when
> necessary (so it can be passed as an argument), but expands into a
> macro (for speed) when deemed possible?
I don't think this is possible without some sort of support for a
macro/function duality in core Clojure. In the
On Fri, Jan 16, 2009 at 12:49 PM, CuppoJava wrote:
>
> I'm also very interested in this topic.
>
> The only reason to write "and" as a macro is for performance reasons.
That's not the only reason. Another reason is to have the option to
avoid evaluating all of the arguments. Functions always eva
and is also written as a macro to short circuit evaluation:
clojure.core/and
([] [x] [x & rest])
Macro
Evaluates exprs one at a time, from left to right. If a form
returns logical false (nil or false), and returns that value and
doesn't evaluate any of the other expressions, otherwise it re
I'm also very interested in this topic.
The only reason to write "and" as a macro is for performance reasons.
It's much more convenient, programming-wise, if and is a function.
Is there anyway to write a macro/function that acts as a function when
necessary (so it can be passed as an argument),
I second the vote for _On Lisp_. I have ported the examples to Clojure:
http://blog.thinkrelevance.com/2008/12/12/on-lisp-clojure
Stuart
>> When I found that out, I was surprised. My knowledge of lisp comes
>> from reading, in the past few months:
>> - ANSI Common Lisp
>> - Practical Common Lis
On 16.01.2009, at 00:04, Daniel Jomphe wrote:
> When I found that out, I was surprised. My knowledge of lisp comes
> from reading, in the past few months:
> - ANSI Common Lisp
> - Practical Common Lisp
> and, some years ago, a few more things.
The best book to read about macros is in my opinion
> fuzzy in my mind how some functions interact well with macros while
> some others don't.
Good:
(some-function (some-macro stuff))
Bad:
(some-function some-macro stuff)
For me I find it easiest to remember as "macros are not first class
functions" ie: they cannot be passed to and executed by o
On Jan 15, 6:04 pm, Daniel Jomphe wrote:
> And still, I wasn't prepared for the fact that macros don't mix 100%
> with functions. Either I overlooked an important section in these
> books, or they didn't really cover it much.
It's not covered much. You get used to it. Think of it this way --
m
12 matches
Mail list logo