Re: -> vs ->> and names vs anonymous function

2011-11-04 Thread Stefan Kamphausen
Thanks for pointing my error out. I was not only oversimplifying things, worse, I simplified something away that was crucial to the original question. Regards Stefan -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email

Re: -> vs ->> and names vs anonymous function

2011-11-03 Thread Alan Malloy
As a nice result of this, you can easily see what the problem is simply by quoting the form: this resolves reader macros but leaves the form otherwise unevaluated, so you can determine what forms the -> macro is working with: user> '(-> x #(inc %)) (-> x (fn* [p1__4781#] (inc p1__4781#))) user> (m

Re: -> vs ->> and names vs anonymous function

2011-11-03 Thread Laurent PETIT
2011/11/2 Stefan Kamphausen : > Hi, > > while all the other answers already offered explanations and solutions I > feel like I should add, that macros like -> and ->> work on the > source-code. Not quite. Macros work on Clojure data structures returned by the Clojure Reader (so reader-macros have

Re: -> vs ->> and names vs anonymous function

2011-11-02 Thread Brian Mosley
On Wed, Nov 2, 2011 at 6:12 AM, Dennis Haupt wrote: > so -> and ->> behave the same as long as my functions only take one > parameter? They do if you avoid inline function definitions. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this

Re: -> vs ->> and names vs anonymous function

2011-11-02 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 so -> and ->> behave the same as long as my functions only take one parameter? Am 02.11.2011 10:58, schrieb Matt Hoyt: > First question answer: > > The code isn't the same. The ~x is the first argument for -> and > is the last argument for ->>. So

Re: -> vs ->> and names vs anonymous function

2011-11-02 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 thx *note: use macroexpand next time* Am 02.11.2011 10:58, schrieb Jonas: > > > On Wednesday, November 2, 2011 11:37:32 AM UTC+2, HamsterofDeath > wrote: > > hi there, > > i stumbled over two odd things 1) -> and ->> have the same source > code. w

Re: -> vs ->> and names vs anonymous function

2011-11-02 Thread Stefan Kamphausen
Hi, while all the other answers already offered explanations and solutions I feel like I should add, that macros like -> and ->> work on the source-code. So using -> does not mean 'pass the first thing as an argument to the function call in the second thing', it means 'take the first thing an

Re: -> vs ->> and names vs anonymous function

2011-11-02 Thread Brian Mosley
On Wed, Nov 2, 2011 at 5:37 AM, Dennis Haupt wrote: > i stumbled over two odd things > 1) -> and ->> have the same source code. why is that? -> and ->> are macros that have similar purposes. "->" inserts the previous form as the first argument to the function, "->>" inserts it as the last. > 2)

Re: -> vs ->> and names vs anonymous function

2011-11-02 Thread Matt Hoyt
First question answer: The code isn't the same.  The ~x is the first argument for -> and is the last argument for ->>.  So if you do a long chain of expression the first argument is passed into the return value into the next function with -> and ->> pass that value as the last parameter. Secon

Re: -> vs ->> and names vs anonymous function

2011-11-02 Thread Baishampayan Ghose
> i stumbled over two odd things > 1) -> and ->> have the same source code. why is that? The source code is _not_ the same for the two macros you mentioned. I will leave it to you to spot the differences ;-) > 2) why can't i use "(-> "hi" #(println %))" directly? why do i have to > put my functio

Re: -> vs ->> and names vs anonymous function

2011-11-02 Thread Jonas
On Wednesday, November 2, 2011 11:37:32 AM UTC+2, HamsterofDeath wrote: > > hi there, > > i stumbled over two odd things > 1) -> and ->> have the same source code. why is that? > Similar, but not the same [1]: (~(first form) ~x ~@(next form)) vs. (~(first form) ~@(next form) ~x) > 2) why can't