Re: let-binding overrides binding-binding

2010-02-01 Thread Alex Osborne
Tom Hicks writes: > I can't seem to do this with the 'inc' function: > > user=> (binding [inc (fn [y] (+ 2 y))] (inc 44)) > 45 > > Why doesn't this work? See this thread: http://groups.google.com/group/clojure/browse_thread/thread/d772e114e50aace6 -- You received this message because you are

Re: let-binding overrides binding-binding

2009-12-25 Thread Richard Newman
> Actually, I think shadowing core functions is not a great idea Quite so! Common Lisp expressly prohibits this stuff for the COMMON- LISP package. > but I wanted to understand the principles involved here. Thanks > again for your rapid help. My pleasure. Happy Christmas! -- You received this

Re: let-binding overrides binding-binding

2009-12-24 Thread Tom Hicks
On Dec 24, 6:01 pm, Richard Newman wrote: > > but, I can't seem to do this with the 'inc' function: > > > user=> (binding [inc (fn [y] (+ 2 y))] (inc 44)) > > 45 > > > Why doesn't this work? > > Because inc is inlined, and thus isn't mentioned when your binding   > occurs. Thanks Richardthat'

Re: let-binding overrides binding-binding

2009-12-24 Thread Richard Newman
> but, I can't seem to do this with the 'inc' function: > > user=> (binding [inc (fn [y] (+ 2 y))] (inc 44)) > 45 > > Why doesn't this work? Because inc is inlined, and thus isn't mentioned when your binding occurs. (defn inc "Returns a number one greater than num." {:inline (fn [x] `(. c

Re: let-binding overrides binding-binding

2009-12-24 Thread Tom Hicks
On a related note, can someone explain the following... I can define a function 'p1': user=> (defn p1 [x] (+ 1 x)) #'user/p1 user=> (p1 44) 45 and then shadow it within the binding construct: user=> (binding [p1 (fn [y] (+ 2 y))] (p1 44)) 46 but, I can't seem to do this with the 'inc' function

Re: let-binding overrides binding-binding

2009-12-19 Thread Stephen C. Gilardi
On Dec 19, 2009, at 5:23 PM, Stefan Kamphausen wrote: > 1. Is my explanation correct? It is. The binding form operates on the var, it doesn't affect name resolution within the binding form's body. *val* within the body of the binding still resolves to the let-bound local. While *val* is shadow