Re: Eval troubles

2010-01-21 Thread Meikel Brandmeyer
Hi, On Jan 20, 11:10 pm, Bryce wrote: > What am I missing? Try ` instead of '. eval evaluates the expression with a different ns. Since y is not properly quoted it is not found. ` will resolve y to its qualified name and everything will work out. Standard Disclaimer: this is only one subtle go

Re: Eval troubles

2010-01-21 Thread kreso
Hi, > (defn y [a b] (+ a b)) > (def x '(y 1 2)) > > (defn -main [] >   (println (eval x))) > > which yields > > "Unable to resolve symbol: y in this context (NO_SOURCE_FILE:7)" > etc. > What am I missing? The problem is namespace inside the function used by gen-class (and it this case your -main

Re: Eval troubles

2009-09-04 Thread Stuart Sierra
On Sep 4, 1:55 am, Miron Brezuleanu wrote: > I'm not sure this is an interpreter/compiler issue :-) I think it is > more of a resource allocation problem, i.e. what features to add to > Clojure and when. True, it's that Clojure does not have first-class environments, either dynamic or lexical.

Re: Eval troubles

2009-09-03 Thread Konrad Hinsen
On 4 Sep 2009, at 07:04, Stuart Sierra wrote: > Or, more simply, Python is an interpreter, Clojure is a compiler. So > Clojure's "eval" actually compiles the form into Java bytecode, then > executes it. I'd say both Python and Clojure are somewhere in between the classical extremes of "interp

Re: Eval troubles

2009-09-03 Thread Miron Brezuleanu
Hello, On Fri, Sep 4, 2009 at 8:04 AM, Stuart Sierra wrote: > > On Sep 3, 9:26 am, Konrad Hinsen wrote: >> I don't think so. Python and Clojure are quite different languages. >> Python is much more dynamic, with variable lookup happening at >> runtime. > > Or, more simply, Python is an interpret

Re: Eval troubles

2009-09-03 Thread Miron Brezuleanu
Hello, On Fri, Sep 4, 2009 at 4:01 AM, James Sofra wrote: > > Hi, > > I am not familiar with the Python code.interact() thing and what it > does so I may be missing something but if you are looking to do > debugging is there a reason you can't use a Java debugger to debug > your Clojure code? (I

Re: Eval troubles

2009-09-03 Thread Stuart Sierra
On Sep 3, 9:26 am, Konrad Hinsen wrote: > I don't think so. Python and Clojure are quite different languages.   > Python is much more dynamic, with variable lookup happening at   > runtime. Or, more simply, Python is an interpreter, Clojure is a compiler. So Clojure's "eval" actually compiles t

Re: Eval troubles

2009-09-03 Thread James Sofra
Hi, I am not familiar with the Python code.interact() thing and what it does so I may be missing something but if you are looking to do debugging is there a reason you can't use a Java debugger to debug your Clojure code? (I have heard some people have had success for JSwat.) I guess that is not

Re: Eval troubles

2009-09-03 Thread Miron Brezuleanu
Hi, On Thu, Sep 3, 2009 at 4:26 PM, Konrad Hinsen wrote: > > On 3 Sep 2009, at 14:43, Miron Brezuleanu wrote: > >> Is there a way to get the list of symbols bound locally and to access >> their values? > > I don't think so. Python and Clojure are quite different languages. > Python is much more d

Re: Eval troubles

2009-09-03 Thread Konrad Hinsen
On 3 Sep 2009, at 14:43, Miron Brezuleanu wrote: > Is there a way to get the list of symbols bound locally and to access > their values? I don't think so. Python and Clojure are quite different languages. Python is much more dynamic, with variable lookup happening at runtime. In Clojure, onl

Re: Eval troubles

2009-09-03 Thread Miron Brezuleanu
Hello, thanks everyone for replies, On Thu, Sep 3, 2009 at 2:36 PM, Konrad Hinsen wrote: > > On 3 Sep 2009, at 08:24, Miron Brezuleanu wrote: > > > user=> (let [x 1] (eval '(inc x))) > > java.lang.Exception: Unable to resolve symbol: x in this context > > (NO_SOURCE_FILE:1) > > > > (on a freshl

Re: Eval troubles

2009-09-03 Thread Konrad Hinsen
On 3 Sep 2009, at 08:24, Miron Brezuleanu wrote: > user=> (let [x 1] (eval '(inc x))) > java.lang.Exception: Unable to resolve symbol: x in this context > (NO_SOURCE_FILE:1) > > (on a freshly downloaded&compiled clojure from github) > > According to my understanding of http://clojure.org/evaluati

Re: Eval troubles

2009-09-03 Thread Jarkko Oranen
On Sep 3, 9:24 am, Miron Brezuleanu wrote: > Hello, > > I'm a Clojure newbie (many thanks to Rich Hickey and everyone involved > - it's a great programming environment) and I have some trouble with > 'eval'. > > What I'm trying is: > $ java -cp clojure.jar clojure.lang.Repl > Clojure 1.1.0-alpha-

Re: Eval troubles

2009-09-03 Thread Christian Vest Hansen
You need to unquote the x to get its value from the let. You can do that with the tilde character inside syntax quotes: user=> (let [x 1] (eval `(inc ~x))) 2 On Thu, Sep 3, 2009 at 8:24 AM, Miron Brezuleanu wrote: > > Hello, > > I'm a Clojure newbie (many thanks to Rich Hickey and everyone invol