Re: Symbols evaluated at compile time?

2009-03-17 Thread Christophe Grand
How do you cope with type-hinted vars or macros? (ok #'declare does not work for macros neither) With autodef, one could have to either move the definition or add a declare just to be able to add a type hint. Christophe Stephen C. Gilardi a écrit : On Mar 16, 2009, at 6:59 PM, Elena

Re: Symbols evaluated at compile time?

2009-03-17 Thread Elena
On Mar 17, 12:15 am, Stephen C. Gilardi squee...@mac.com wrote: If *autodef-unresolved-symbols* is true, and if a has never been   mentioned before, this interaction with Clojure:         user= a         java.lang.Exception: Unable to resolve symbol: a in this context would become:      

Re: Symbols evaluated at compile time?

2009-03-17 Thread Elena
On Mar 17, 10:46 am, Michael Wood esiot...@gmail.com wrote: I understand why people want to be able to do things like this: (defn b [] (a)) (defn a [] (...)) That's what I'm asking for. But that's completely different from the above.  The above is more like: (a) (defn a [] (...)) Why

Re: Symbols evaluated at compile time?

2009-03-17 Thread Stephen C. Gilardi
On Mar 17, 2009, at 4:44 AM, Christophe Grand wrote: How do you cope with type-hinted vars or macros? (ok #'declare does not work for macros neither) With autodef, one could have to either move the definition or add a declare just to be able to add a type hint. The class of vars you're

Re: Symbols evaluated at compile time?

2009-03-17 Thread Michael Wood
On Tue, Mar 17, 2009 at 1:01 PM, Elena egarr...@gmail.com wrote: On Mar 17, 10:46 am, Michael Wood esiot...@gmail.com wrote: I understand why people want to be able to do things like this: (defn b [] (a)) (defn a [] (...)) That's what I'm asking for. But that's completely different from

Re: Symbols evaluated at compile time?

2009-03-17 Thread Stephen C. Gilardi
On Mar 17, 2009, at 7:20 AM, Elena wrote: I wanted to say that entering: (defn a [] (b)) should issue a warning (and I don't think an exception is the right way to warn the user). The autodef I described would not warn, nor throw an exception in this case. I think warn on autodef

Re: Symbols evaluated at compile time?

2009-03-17 Thread Laurent PETIT
Hello Rich, 2009/3/17 Rich Hickey richhic...@gmail.com I remain opposed, and here are some more reasons: when you say (def foo [x] (bar x 42)) you are as likely to be referring to a forgot-to-require bar-lib as you are to a to-be-defined bar. The compiler can only default the latter,

Re: Symbols evaluated at compile time?

2009-03-17 Thread Laurent PETIT
2009/3/17 Stephen C. Gilardi squee...@mac.com On Mar 16, 2009, at 8:25 PM, Laurent PETIT wrote: Hi Laurent, Your solution is indeed close to what I had in mind in terms of requirements. I was currently hacking with clojure java class Compiler to enhance Timothy's patch and add a

Re: Symbols evaluated at compile time?

2009-03-17 Thread Stephen C. Gilardi
On Mar 17, 2009, at 5:52 PM, Laurent PETIT wrote: I give up on this one. I've now been half convinced that it's even less an ideal solution than I expected at first, and I prefer use the little free time I have to enhance clojuredev. Sounds good. Thanks for closing the loop on this.

Re: Symbols evaluated at compile time?

2009-03-17 Thread Elena
On 17 Mar, 13:23, Rich Hickey richhic...@gmail.com wrote: I remain opposed, and here are some more reasons: when you say (def foo [x]   (bar x 42)) you are as likely to be referring to a forgot-to-require bar-lib as you are to a to-be-defined bar. The compiler can only default the

Re: Symbols evaluated at compile time?

2009-03-17 Thread Elena
And of course, if somebody agrees that is a worth proposal and could provide some directions, I'm here ready to churn out some code. Here in Italy we say Help yourself and God will help you along the way ^_^ Did I mention I'm Italian? I bet you guessed it already since I talk too much for sure.

Re: Symbols evaluated at compile time?

2009-03-16 Thread Christophe Grand
Elena a écrit : Hi, in this code: (defn main [] (check-services)) (defn check-services [] 1) if I call slime-eval-defun on main before calling it on check- services, Clojure aborts with: java.lang.Exception: Unable to resolve symbol: check-services in this context

Re: Symbols evaluated at compile time?

2009-03-16 Thread Konrad Hinsen
On 16.03.2009, at 11:35, Elena wrote: in this code: (defn main [] (check-services)) (defn check-services [] 1) if I call slime-eval-defun on main before calling it on check- services, Clojure aborts with: java.lang.Exception: Unable to resolve symbol: check-services in

Re: Symbols evaluated at compile time?

2009-03-16 Thread Elena
On Mar 16, 10:40 am, Christophe Grand christo...@cgrand.net wrote: Yes, it prevents typos to go unnoticed. You can write a forward declaration : (declare check-services); equivalent to (def check-services) (defn main []         (check-services)) (defn check-services []         1)

Re: Symbols evaluated at compile time?

2009-03-16 Thread Elena
On Mar 16, 10:43 am, Konrad Hinsen konrad.hin...@laposte.net wrote: Yes. Clojure checks that symbols are defined before they are used.   You can put (declare check-services) before your definition of main to define the symbol and make it clear   to the (human) reader that you indeed to

Re: Symbols evaluated at compile time?

2009-03-16 Thread Meikel Brandmeyer
Hi, Am 16.03.2009 um 18:36 schrieb Elena: IMHO, this is a no-no for interactive development. I understand that it helps avoiding undefined symbols, but such code integrity checks could be delayed to a final compilation stage. Having them earlier forces you to develop code in a bottom-up way.

Re: Symbols evaluated at compile time?

2009-03-16 Thread Jeffrey Straszheim
I agree. It doesn't matter what order the compiler reads the definitions: I can scroll up and type. It does effect humans reading the code, however. Often when looking at unfamiliar Clojure code, I find myself scrolling to the bottom first. On Mon, Mar 16, 2009 at 1:58 PM, Meikel Brandmeyer

Re: Symbols evaluated at compile time?

2009-03-16 Thread Elena
On 16 Mar, 20:14, Jeffrey Straszheim straszheimjeff...@gmail.com wrote: It does effect humans reading the code, however.  Often when looking at unfamiliar Clojure code, I find myself scrolling to the bottom first. That's exactly my point: why should I scroll to the bottom? That's not the way

Re: Symbols evaluated at compile time?

2009-03-16 Thread David Nolen
This has come up before. You can actually work around this (search the mailing list for declare) I think that when not hacking against the REPL that the default behavior is a good one. Having to use declare bugged me a little at first, but I now consider it a very minor annoyance compared to the

Re: Symbols evaluated at compile time?

2009-03-16 Thread Laurent PETIT
I also agree that I keep going first to the end of the file, searching the real function to launch or to reuse when reading new clojure code ... What I would be happy with is a way to have clojure not complain before the end of a unit of compiled code. For the REPL, that would be somewhat

Re: Symbols evaluated at compile time?

2009-03-16 Thread Paul Stadig
I may be missing something, but how does having to (declare) vars fix typos? I don't think anyone is suggesting *creating* a var that is referenced before it is defined. What people are asking for is that the compiler looks-ahead to verify that the var will eventually be defined, and then go on

Re: Symbols evaluated at compile time?

2009-03-16 Thread David Nolen
On Mon, Mar 16, 2009 at 4:08 PM, Paul Stadig p...@stadig.name wrote: I may be missing something, but how does having to (declare) vars fix typos? I don't think anyone is suggesting *creating* a var that is referenced before it is defined. What people are asking for is that the compiler

Re: Symbols evaluated at compile time?

2009-03-16 Thread Elena
On 16 Mar, 20:45, David Nolen dnolen.li...@gmail.com wrote: This has come up before. You can actually work around this (search the mailing list for declare) I've searched the mailing list and I've found also an explanation by Rich Hickey (I apologize for not having done it in the first

Re: Symbols evaluated at compile time?

2009-03-16 Thread Elena
On 16 Mar, 20:58, Laurent PETIT laurent.pe...@gmail.com wrote: For files, that would be wait until the end of the file before complaining for undefined symbols, and let me arrange the defs in any order I feel most readable without having to think about placing those (declare) calls. I second

Re: Symbols evaluated at compile time?

2009-03-16 Thread Phil Hagelberg
André Thieme splendidl...@googlemail.com writes: But it also protects you from typos. And this can be even more important. Imagine you have a complex program and accidently made a typo, and this will go unnoticed for days and days, until the program actually runs your code... If you go days

Re: Symbols evaluated at compile time?

2009-03-16 Thread Raoul Duke
If you go days and days without actually running your code, then you deserve what you get. A test suite would catch this for you every time; developing without one is irresponsible. geeze people, i'm tired of the tests are the answer to everything. give it a break. not every test suite will

Re: Symbols evaluated at compile time?

2009-03-16 Thread Laurent PETIT
2009/3/16 Meikel Brandmeyer m...@kotka.de Hi, Am 16.03.2009 um 22:19 schrieb Elena: On 16 Mar, 21:57, Laurent PETIT laurent.pe...@gmail.com wrote: I agree that it's not difficult. But, at least in my own experience, it's not the second step to cleaning up my programs. I generally try

Re: Symbols evaluated at compile time?

2009-03-16 Thread Meikel Brandmeyer
Hi, Am 16.03.2009 um 22:44 schrieb Laurent PETIT: In french, we have a sentence for that, that would translate literally into eat the banana by both ends at the same time. I don't think top-down and bottom-up programming are antogonists. I often do both at the same time myself.

Re: Symbols evaluated at compile time?

2009-03-16 Thread Laurent PETIT
2009/3/16 Phil Hagelberg p...@hagelb.org André Thieme splendidl...@googlemail.com writes: But it also protects you from typos. And this can be even more important. Imagine you have a complex program and accidently made a typo, and this will go unnoticed for days and days, until the

Re: Symbols evaluated at compile time?

2009-03-16 Thread Elena
On 16 Mar, 22:31, André Thieme splendidl...@googlemail.com wrote: The behaviour of Clojure can be seen as a disadvantage, yes, because you either need these forward declarations, or you need to arrange functions different. But it also protects you from typos. And this can be even more

Re: Symbols evaluated at compile time?

2009-03-16 Thread André Thieme
On 16 Mrz., 20:45, David Nolen dnolen.li...@gmail.com wrote: Should the REPL have an interactive mode where it won't fire an exception on undefined symbols and instead issue compiler warnings? If compiler warnings were issued this would be a nice hook for Emacs and other IDEs. Yes, I was

Re: Symbols evaluated at compile time?

2009-03-16 Thread Timothy Pratley
Just FYI, The actual patch is in the files section: http://groups.google.com/group/clojure/web/auto-def.patch With an example: http://groups.google.com/group/clojure/web/lit-wc.clj From a longer thread about 'snake' which talked about literate programming:

Re: Symbols evaluated at compile time?

2009-03-16 Thread Phil Hagelberg
Laurent PETIT laurent.pe...@gmail.com writes: OK, so now is time for another ugly english translation of a french proverb before saying something, roll your tongue 8 times in your mouth before speaking. I guess this could also be applied for e-mail Agreed, it could have been worded better.

Re: Symbols evaluated at compile time?

2009-03-16 Thread Elena
On 16 Mar, 22:55, Meikel Brandmeyer m...@kotka.de wrote: My remark was pointed at the fact, that before it was claimed, that the one way doesn't work in Clojure and one has to go the other. And then the same person goes on to contradict him(or her?)self. But be it... To say something more

Re: Symbols evaluated at compile time?

2009-03-16 Thread Elena
On 16 Mar, 23:26, Timothy Pratley timothyprat...@gmail.com wrote: For fully compiled code the 'checkpoint' is clear - but Clojure is dynamic... what should happen with this code: (defn myfun []   (another-fun 5)) (myfun) (defn another-fun [x]   (inc x)) In a compiled language that

Re: Symbols evaluated at compile time?

2009-03-16 Thread Phil Hagelberg
Laurent PETIT laurent.pe...@gmail.com writes: 2009/3/16 Phil Hagelberg p...@hagelb.org Laurent PETIT laurent.pe...@gmail.com writes: But please, think about it twice before saying people are irresponsible. Unit tests are not the only answer to bug-free and quality

Re: Symbols evaluated at compile time?

2009-03-16 Thread Elena
On 16 Mar, 23:47, Elena egarr...@gmail.com wrote: On 16 Mar, 23:26, Timothy Pratley timothyprat...@gmail.com wrote: what should happen with this code: (defn myfun []   (another-fun 5)) (myfun) (defn another-fun [x]   (inc x)) In a compiled language that would be valid, but in

Re: Symbols evaluated at compile time?

2009-03-16 Thread Stephen C. Gilardi
On Mar 16, 2009, at 6:59 PM, Elena wrote: Furthermore, if I understand Rich's opinion in that regards, this code: (defn myfun [] (another-fun 5)) should be rejected if definition of another-fun is missing (but I'd say: only in code to be released). I don't mind the current behavior of

Re: Symbols evaluated at compile time?

2009-03-16 Thread André Thieme
On 16 Mrz., 22:41, Phil Hagelberg p...@hagelb.org wrote: André Thieme splendidl...@googlemail.com writes: But it also protects you from typos. And this can be even more important. Imagine you have a complex program and accidently made a typo, and this will go unnoticed for days and days,

Re: Symbols evaluated at compile time?

2009-03-16 Thread Laurent PETIT
Hello, Thanks for taking time thinking about this idea! Your solution is indeed close to what I had in mind in terms of requirements. I was currently hacking with clojure java class Compiler to enhance Timothy's patch and add a variation on what you described. My concern is that it should also

Re: Symbols evaluated at compile time?

2009-03-16 Thread Stephen C. Gilardi
On Mar 16, 2009, at 8:25 PM, Laurent PETIT wrote: Hi Laurent, Your solution is indeed close to what I had in mind in terms of requirements. I was currently hacking with clojure java class Compiler to enhance Timothy's patch and add a variation on what you described. Cool. I look

Re: Symbols evaluated at compile time?

2009-03-16 Thread Laurent PETIT
Hello again, 2009/3/17 Stephen C. Gilardi squee...@mac.com On Mar 16, 2009, at 8:25 PM, Laurent PETIT wrote: Hi Laurent, Your solution is indeed close to what I had in mind in terms of requirements. I was currently hacking with clojure java class Compiler to enhance Timothy's patch and

Re: Symbols evaluated at compile time?

2009-03-16 Thread Stephen C. Gilardi
On Mar 16, 2009, at 9:06 PM, Laurent PETIT wrote: The real one was : how to correctly get the thread bound value, and change the thread bound value of a Var instance, from within java code ? You can set the thread-bound value with set (defined in Var.java). You get the thread-bound

Re: Symbols evaluated at compile time?

2009-03-16 Thread Laurent PETIT
2009/3/17 Stephen C. Gilardi squee...@mac.com On Mar 16, 2009, at 9:06 PM, Laurent PETIT wrote: The real one was : how to correctly get the thread bound value, and change the thread bound value of a Var instance, from within java code ? You can set the thread-bound value with set