Hi Atamert,
I'm not an expert but I believe REPL does compile the forms you enter to
bytecode. It compiles an fn form into a JVM class that implements IFn. It
also compiles a quoted form (such as `(fn ...) ) but this time it takes the
form of a list (as in (list ...) ), IOW it's still data
Hi Atamert,
Here's a gist with the example code:
https://gist.github.com/neapel/4e502a14e3738b709672
I tried replacing a closure with a dynamically built and evaluated
metafunction but discovered that it was actually slower.
If evaluating code during run is slower than AOT compiling it, it
You're going down a rabbit hole here. Evaluating forms at runtime will
always result in a slower execution time than a function that doesn't
evaluate a form at runtime.
On Thursday, July 3, 2014 11:55:02 AM UTC-4, Pascal Germroth wrote:
Hi Atamert,
Here's a gist with the example code:
On Thursday, July 3, 2014 5:19:56 PM UTC+1, adrian...@mail.yu.edu wrote:
You're going down a rabbit hole here. Evaluating forms at runtime will
always result in a slower execution time than a function that doesn't
evaluate a form at runtime.
I thought that was the whole point of
I'm not sure I understand what you're saying here. :( Your example is
simply benchmarking the same bit of code in each form. Why would evaluating
one explicitly affect that benchmark? Your original example called eval in
the body of the functions that you're benchmarking. That is where the
On Thursday, July 3, 2014 6:15:32 PM UTC+1, adrian...@mail.yu.edu wrote:
I'm not sure I understand what you're saying here. :( Your example is
simply benchmarking the same bit of code in each form. Why would evaluating
one explicitly affect that benchmark? Your original example called eval
No I'm benchmarking the functions returned by f1-4.
Where did I say different?
In any event, I'm trying to help you understand why your benchmarking
results are not aligning with your expectations and assumptions about the
code you wrote.
I would really like to help you gain a greater
On Thursday, July 3, 2014 7:27:24 PM UTC+1, adrian...@mail.yu.edu wrote:
No I'm benchmarking the functions returned by f1-4.
Where did I say different?
I understood Your original example called eval in the body of the
functions that you're benchmarking as meaning I was running something
On Thu, Jul 3, 2014 at 11:55 PM, Pascal Germroth funkyco...@gmail.com
wrote:
Hi Atamert,
Here's a gist with the example code:
https://gist.github.com/neapel/4e502a14e3738b709672
I tried replacing a closure with a dynamically built and evaluated
metafunction but discovered that it was
Hi,
I tried replacing a closure with a dynamically built and evaluated
metafunction but discovered that it was actually slower.
Here's a minimal example:
(defn f1 [x](fn [y ] (=x y )))
(defn f2 [x] (eval `(fn [y#] (= ~x y#
(defn f3 [x] (eval `(fn [y#] (= ~@[x] y#
(use
It gets even weirder. I tried this hoping it would create a closure like f1
does:
(defn f4 [x] (eval `(let [[x#] ~@[[x]]]
(fn [y#]
(= x# y#)
And indeed using no.disassemble in my test cases f1 and f4 always create
the same bytecode: a
Hi Pascal,
On Wed, Jul 2, 2014 at 10:19 PM, Pascal Germroth funkyco...@gmail.com
wrote:
I tried replacing a closure with a dynamically built and evaluated
metafunction but discovered that it was actually slower.
If evaluating code during run is slower than AOT compiling it, it wouldn't
http://blog.8thlight.com/colin-jones/2012/05/22/quoting-without-confusion.html
On Thursday, June 19, 2014 12:22:36 PM UTC+3, sorin cristea wrote:
hi all,
related to macro definition, what are the differences between*[** ' ]*
char and *[ ` ]* char ?
thanks.
--
You received this
hi all,
related to macro definition, what are the differences between*[** ' ]* char
and *[ ` ]* char ?
thanks.
--
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
http://clojure.org/reader#The Reader--Macro characters
http://clojure.org/reader#The%20Reader--Macro%20characters
--
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
HI all,
I've gotten myself into a weird situation...
I'm defining a def-like macro and I want to use 'name-with-attributes'.
Consider the following skeleton:
(defmacro defX [name args]
(let [[name attrs] (name-with-attributes name args)]
`(let [cs-coll# ~attrs]
(assert (every?
~(vec attrs), perhaps?
On Thu, Sep 5, 2013 at 12:20 PM, Jim - FooBar(); jimpil1...@gmail.comwrote:
HI all,
I've gotten myself into a weird situation...
I'm defining a def-like macro and I want to use 'name-with-attributes'.
Consider the following skeleton:
(defmacro defX [name args]
I ended up using (list ~@attrs) which is very similar to what you're
suggesting...:)
JIm
On 05/09/13 20:22, Dave Ray wrote:
~(vec attrs), perhaps?
On Thu, Sep 5, 2013 at 12:20 PM, Jim - FooBar(); jimpil1...@gmail.com
mailto:jimpil1...@gmail.com wrote:
HI all,
I've gotten myself
#] ((getOptions ~'this) x#
The gen-proxy functions is a helper which is used in macros. The code
works, as far as I can tell, but there's one thing that intrigues me:
the usage of unquote/quote is necessary (~'_ and ~'this). I assume it
has something to do with macros qualifying symbols
] []
(getOptions [~'_] ~opts)
(getOption [~'this x#] ((getOptions ~'this) x#
The gen-proxy functions is a helper which is used in macros. The code
works, as far as I can tell, but there's one thing that intrigues me:
the usage of unquote/quote is necessary (~'_ and ~'this). I assume
Thanks. Razvan
--
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
Hi,
This may sound a bit weird, but can I unquote-splice something when
calling a macro. Here's an attempt to do this with hiccup:
(defn get-header
[[:link {:type text/css ...}]
[:script {:type text/javascript ...}]])
(html [:head (get-header) ...] [:body ...])
The result of get-header
This may sound a bit weird, but can I unquote-splice something when
calling a macro. Here's an attempt to do this with hiccup:
(defn get-header
[[:link {:type text/css ...}]
[:script {:type text/javascript ...}]])
(html [:head (get-header) ...] [:body ...])
The result of get-header
Great. Thanks.
On Dec 17, 6:08 pm, Baishampayan Ghose b.gh...@gmail.com wrote:
This may sound a bit weird, but can I unquote-splice something when
calling a macro. Here's an attempt to do this with hiccup:
(defn get-header
[[:link {:type text/css ...}]
[:script {:type text
, it does the splicing that I want.
Razvan
On Dec 17, 6:32 pm, Razvan Rotaru razvan.rot...@gmail.com wrote:
Great. Thanks.
On Dec 17, 6:08 pm, Baishampayan Ghose b.gh...@gmail.com wrote:
This may sound a bit weird, but can I unquote-splice something when
calling a macro. Here's an attempt
On Sat, Dec 17, 2011 at 06:06:50AM -0800, Razvan Rotaru wrote:
Hi,
This may sound a bit weird, but can I unquote-splice something when
calling a macro. Here's an attempt to do this with hiccup:
(defn get-header
[[:link {:type text/css ...}]
[:script {:type text/javascript
On Sat, Dec 17, 2011 at 11:08 AM, Baishampayan Ghose b.gh...@gmail.com wrote:
This may sound a bit weird, but can I unquote-splice something when
calling a macro. Here's an attempt to do this with hiccup:
(defn get-header
[[:link {:type text/css ...}]
[:script {:type text/javascript
Can anyone give me some basic example which contained nested quotes
and unquotes? with explanation at each step!
--
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
No one can be told what the matrix is.
Well, the best way to understand the macros is to try it out yourself. John
Lawrence Aspden published some really helpful tutorials om macros, and a
kata - try it! Links in the end.
There are some other code examples around, also look in the source-code of
Those are great links Linus, thank you.
Also highly relevant and beginner friendly is the text adventure game
chapter from the, Land of Lisp book, of
which a free clojure translation is available online:
http://www.lisperati.com/clojure-spels/casting.html
Cheers,
Joshua
On Oct 31, 6:01 pm,
In general you should prefer doseq because it doesn't hold on to the head,
correct?
Sent from my iPhone
On Dec 15, 2010, at 5:14 PM, Meikel Brandmeyer m...@kotka.de wrote:
Hi,
Am 15.12.2010 um 19:54 schrieb Brian Marick:
(See also #'dorun.)
Argh. See also doseq.
Sincerely
Meikel
Hi,
Am 16.12.2010 um 14:50 schrieb Jay Fields:
In general you should prefer doseq because it doesn't hold on to the head,
correct?
dorun does the same. But it constructs a lazy sequence of return values which
is thrown away immediately. This is very ugly and wasteful. Doing some
I was trying to print out a list of symbols and I was wondering if I
could remove the quotes.
(def process-print-list
(fn [a-list]
(cond (empty? a-list) 'false
(list? a-list) (let [a a-list] (println (first a)) (process-print-
list (rest a) ))
:else (process-print-list (rest a-list)
On Wed, Dec 15, 2010 at 11:22 AM, Poojan poojanshah2...@gmail.com wrote:
I was trying to print out a list of symbols and I was wondering if I
could remove the quotes.
(def process-print-list
(fn [a-list]
(cond (empty? a-list) 'false
(list? a-list) (let [a a-list] (println (first a))
On Dec 15, 2010, at 10:22 AM, Poojan wrote:
I was trying to print out a list of symbols and I was wondering if I
could remove the quotes.
(name 'symbol) ; gives the string name of a symbol
(map name '(a b c))) ; will give you a list of string names of symbols.
(println (map
Hi,
Am 15.12.2010 um 19:54 schrieb Brian Marick:
(See also #'dorun.)
Argh. See also doseq.
Sincerely
Meikel
--
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
the macro is expanded. body evaluates to
whatever is bound to the argument.
(our-let [...] (this) (is the) (body))
In this case body evaluates to ((this) (is the) (body)) which is
inserted into the macro expansion. (Note: since we use unquote-splice
aka. ~@ instead of plain unquote aka
Hi, all
It seems Lisp macro expander will not evalute the argument prefixed by
unquote. The following code, written in Common Lisp, is an excerpt
from `On Lisp'. This macro implemented `let'.
1. (defmacro our-let (binds body body)
2. ‘((lambda ,(mapcar #’(lambda (x)
3
[...] (this) (is the) (body))
In this case body evaluates to ((this) (is the) (body)) which is
inserted into the macro expansion. (Note: since we use unquote-splice
aka. ~@ instead of plain unquote aka. ~ the outer list is spliced away
in the expansion)
Hope this helps.
Sincerely
Meikel
--
You
On Jul 7, 5:02 am, Mike cki...@gmail.com wrote:
(not sure where my reply to Chouser et al. went, but basically I said
that I was writing a macro and I might be overdoing it. I was right!)
Here's what I was trying to accomplish, but in functions, not macros:
(defn slice
Returns a lazy
On Jul 6, 4:00 pm, Chouser chou...@gmail.com wrote:
On Mon, Jul 6, 2009 at 3:47 PM, Sean Devlinfrancoisdev...@gmail.com wrote:
I think your unquote is okay. ClojureQL does something similar.
However, my gut says this should be in a doseq, not a for statement.
Could be totally wrong
(not sure where my reply to Chouser et al. went, but basically I said
that I was writing a macro and I might be overdoing it. I was right!)
Here's what I was trying to accomplish, but in functions, not macros:
(defn slice
Returns a lazy sequence composed of every nth item of
coll,
On Jul 6, 6:00 pm, Chouser chou...@gmail.com wrote:
On Mon, Jul 6, 2009 at 4:18 PM, Meikel Brandmeyerm...@kotka.de wrote:
Hi,
Am 06.07.2009 um 22:00 schrieb Chouser:
Or if you really do need a list:
(for [x [1 2 3]] (cons 'some-symbol (list x)))
o.O
*cough*(list 'some-symbol
Newbie question here. Probably answered in Stu's book, but I forgot
it at home today.
is:
(for [x [1 2 3]] `(some-symbol ~x))
dangerous? I mean, assuming that some-symbol is bound and all. At
the REPL I get
((user/some-symbol 1) (user/some-symbol 2) (user/some-symbol 3))
which is what I'm
I think your unquote is okay. ClojureQL does something similar.
However, my gut says this should be in a doseq, not a for statement.
Could be totally wrong, tough.
My $.02
Sean
On Jul 6, 2:39 pm, Mike cki...@gmail.com wrote:
Newbie question here. Probably answered in Stu's book, but I
On Mon, Jul 6, 2009 at 3:47 PM, Sean Devlinfrancoisdev...@gmail.com wrote:
I think your unquote is okay. ClojureQL does something similar.
However, my gut says this should be in a doseq, not a for statement.
Could be totally wrong, tough.
I think the OP is trying to build and return a list
Hi,
Am 06.07.2009 um 22:00 schrieb Chouser:
Or if you really do need a list:
(for [x [1 2 3]] (cons 'some-symbol (list x)))
o.O
*cough*(list 'some-symbol x)*cough* ;)
Sincerely
Meikel
smime.p7s
Description: S/MIME cryptographic signature
On Mon, Jul 6, 2009 at 4:18 PM, Meikel Brandmeyerm...@kotka.de wrote:
Hi,
Am 06.07.2009 um 22:00 schrieb Chouser:
Or if you really do need a list:
(for [x [1 2 3]] (cons 'some-symbol (list x)))
o.O
*cough*(list 'some-symbol x)*cough* ;)
Oh. Right. What he said.
--Chouser
Or if you really do need a list:
(for [x [1 2 3]] (cons 'some-symbol (list x)))
Why not
(for [x [1 2 3]] (list 'some-symbol x))
?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this
49 matches
Mail list logo