Re: Why does unquote clone values?

2014-07-04 Thread Pascal Germroth
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 dat

Re: Why does unquote clone values?

2014-07-03 Thread Atamert Ölçgen
On Thu, Jul 3, 2014 at 11:55 PM, Pascal Germroth 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 actually slower.

Re: Why does unquote clone values?

2014-07-03 Thread Pascal Germroth
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 some

Re: Why does unquote clone values?

2014-07-03 Thread adrian . medina
"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 und

Re: Why does unquote clone values?

2014-07-03 Thread Pascal Germroth
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

Re: Why does unquote clone values?

2014-07-03 Thread adrian . medina
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 over

Re: Why does unquote clone values?

2014-07-03 Thread Pascal Germroth
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 Clo

Re: Why does unquote clone values?

2014-07-03 Thread adrian . medina
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:

Re: Why does unquote clone values?

2014-07-03 Thread Pascal Germroth
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 i

Re: Why does unquote clone values?

2014-07-02 Thread Atamert Ölçgen
Hi Pascal, On Wed, Jul 2, 2014 at 10:19 PM, Pascal Germroth 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 surprise me. > I gu

Re: Why does unquote clone values?

2014-07-02 Thread Pascal Germroth
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 clojure.la

Why does unquote clone values?

2014-07-02 Thread Pascal Germroth
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 'c

Re: macro - unquote

2014-06-20 Thread sorin cristea
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

Re: macro - unquote

2014-06-19 Thread François Rey
http://clojure.org/reader#The Reader--Macro characters -- 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

macro - unquote

2014-06-19 Thread sorin cristea
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

Re: how does one unquote a list of records that implement IFn without treating the first item as a function?

2013-09-05 Thread Jim - FooBar();
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(); > wrote: HI all, I've gotten myself into a weird situati

Re: how does one unquote a list of records that implement IFn without treating the first item as a function?

2013-09-05 Thread Dave Ray
~(vec attrs), perhaps? On Thu, Sep 5, 2013 at 12:20 PM, Jim - FooBar(); wrote: > 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 [[na

how does one unquote a list of records that implement IFn without treating the first item as a function?

2013-09-05 Thread Jim - FooBar();
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? componen

Re: weird quote/unquote usage

2011-12-25 Thread Razvan Rotaru
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

Re: weird quote/unquote usage

2011-12-25 Thread Meikel Brandmeyer
ss opts] > `(proxy [~klass WithOptions] [] > (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&#

weird quote/unquote usage

2011-12-25 Thread Razvan Rotaru
(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 it

Re: unquote-splicing when calling macro

2011-12-17 Thread Cedric Greevey
On Sat, Dec 17, 2011 at 11:08 AM, Baishampayan Ghose 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

Re: unquote-splicing when calling macro

2011-12-17 Thread Robert Marianski
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 "te

Re: unquote-splicing when calling macro

2011-12-17 Thread Razvan Rotaru
kind of sequence, it does the splicing that I want. Razvan On Dec 17, 6:32 pm, Razvan Rotaru wrote: > Great. Thanks. > > On Dec 17, 6:08 pm, Baishampayan Ghose wrote: > > > > > > > > > > This may sound a bit weird, but can I "unquote-splice" so

Re: unquote-splicing when calling macro

2011-12-17 Thread Razvan Rotaru
Great. Thanks. On Dec 17, 6:08 pm, Baishampayan Ghose 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 &qu

Re: unquote-splicing when calling macro

2011-12-17 Thread Baishampayan Ghose
> 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" ...}]]) >

unquote-splicing when calling macro

2011-12-17 Thread Razvan Rotaru
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) ..

Re: Nested Syntax Quote, Quote and unquote example

2011-10-31 Thread Aquahappy
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

Re: Nested Syntax Quote, Quote and unquote example

2011-10-31 Thread Linus Ericsson
"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

Nested Syntax Quote, Quote and unquote example

2011-10-31 Thread vikbehal
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 mem

Re: unquote

2010-12-16 Thread Meikel Brandmeyer
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 microbenc

Re: unquote

2010-12-16 Thread Jay Fields
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 wrote: > Hi, > > Am 15.12.2010 um 19:54 schrieb Brian Marick: > >> (See also #'dorun.) > > Argh. See also doseq. > > Sincerely > Meikel >

Re: unquote

2010-12-15 Thread Meikel Brandmeyer
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 me

Re: unquote

2010-12-15 Thread Brian Marick
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

Re: unquote

2010-12-15 Thread Ken Wesson
On Wed, Dec 15, 2010 at 11:22 AM, Poojan 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)) (process-print- > list

unquote

2010-12-15 Thread Poojan
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)

Re: Evaluated or not -- unquote in syntax-quote/backquote

2010-07-15 Thread Yang Dong
are evaluated when 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 unquot

Re: Evaluated or not -- unquote in syntax-quote/backquote

2010-07-14 Thread Meikel Brandmeyer
] (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 Mei

Evaluated or not -- unquote in syntax-quote/backquote

2010-07-14 Thread Yang Dong
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 #

Re: Is this unquote dangerous?

2009-07-08 Thread Nathan Kitchen
On Jul 7, 5:02 am, Mike 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 sequence co

Re: Is this unquote dangerous?

2009-07-07 Thread Jonathan Smith
On Jul 6, 6:00 pm, Chouser wrote: > On Mon, Jul 6, 2009 at 4:18 PM, Meikel Brandmeyer 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* ;

Re: Is this unquote dangerous?

2009-07-07 Thread Mike
(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, starti

Re: Is this unquote dangerous?

2009-07-07 Thread Mike
On Jul 6, 4:00 pm, Chouser wrote: > On Mon, Jul 6, 2009 at 3:47 PM, Sean Devlin 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. &

Re: Is this unquote dangerous?

2009-07-06 Thread John Harrop
> > 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 t

Re: Is this unquote dangerous?

2009-07-06 Thread Chouser
On Mon, Jul 6, 2009 at 4:18 PM, Meikel Brandmeyer 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 --~--~--

Re: Is this unquote dangerous?

2009-07-06 Thread Meikel Brandmeyer
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

Re: Is this unquote dangerous?

2009-07-06 Thread Chouser
On Mon, Jul 6, 2009 at 3:47 PM, Sean Devlin 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

Re: Is this unquote dangerous?

2009-07-06 Thread Sean Devlin
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 wrote: > Newbie question here.  Probably answered in Stu's book, but I forgot >

Is this unquote dangerous?

2009-07-06 Thread Mike
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