Re: Is Clojure's lack of support for forward referencing a feature or a bug?

2009-03-25 Thread Mark Engelberg

On Wed, Mar 11, 2009 at 5:18 PM, Timothy Pratley
timothyprat...@gmail.com wrote:
 It is also quite trivial to patch the compiler to auto-def symbols as
 it finds them instead of throwing an error.

I would be interested in knowing how to do such a patch.  When I work
on code, I like to organize my functions in a way that makes it easy
to read and understand what is going on.  As I work on longer chunks
of Clojure code, I'm finding that shuffling around the functions to
avoid a lot of forward declarations is destroying the readability of
my code.

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Is Clojure's lack of support for forward referencing a feature or a bug?

2009-03-25 Thread Timothy Pratley

Hi Mark,

A fuller discussion can be found here:
http://groups.google.com/group/clojure/browse_thread/thread/a99b420d5ee0aa40/47f8c2ab6845e9ae
Which has links to the simple patch I tried, and discusses the more
advanced technique Laurent experimented with.
Elena subsequently developed an emacs plugin which looks interesting
(I'm a VI ninja though so haven't used it)
http://groups.google.com/group/clojure/browse_thread/thread/ca7076f4c6591fdd/cda5cf10b89a3679

My own experience FWIW was that it was great for two weeks coding with
autodef, then for about a week I became frustrated with my typos and
disabled it. More promising solutions might come from an external tool
(such as Knuth's literate programming noweb) or IDE support like Elena
described.

For now my work flow is write the code backwards (ie: manually move
the cursor up) and/or chopping and pasting. Then when I'm happy with
it, I re-chop it all in my 'preferred' order and put a declare at the
top. That sounds quite inefficient, but VI is really great for re-
organizing text blocks so it is not too strenuous. That said, I'm
really interested in ways that literate programming style can be
followed with the least external support.


Regards,
Tim.


On Mar 26, 4:15 pm, Mark Engelberg mark.engelb...@gmail.com wrote:
 On Wed, Mar 11, 2009 at 5:18 PM, Timothy Pratley

 timothyprat...@gmail.com wrote:
  It is also quite trivial to patch the compiler to auto-def symbols as
  it finds them instead of throwing an error.

 I would be interested in knowing how to do such a patch.  When I work
 on code, I like to organize my functions in a way that makes it easy
 to read and understand what is going on.  As I work on longer chunks
 of Clojure code, I'm finding that shuffling around the functions to
 avoid a lot of forward declarations is destroying the readability of
 my code.
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Is Clojure's lack of support for forward referencing a feature or a bug?

2009-03-25 Thread David Nolen
For what it's worth I'm a big fan of the wishful thinking programming style.
I write some functions how I think they should look, declare the functions I
haven't defined yet. Then I implement the lower level functions, write some
tests- then usually the higher level stuff works without too much tweaking.
In a non-functional programming language this doesn't work so well, but it's
a good fit for something like Clojure.

On Thu, Mar 26, 2009 at 1:42 AM, Timothy Pratley
timothyprat...@gmail.comwrote:


 Hi Mark,

 A fuller discussion can be found here:

 http://groups.google.com/group/clojure/browse_thread/thread/a99b420d5ee0aa40/47f8c2ab6845e9ae
 Which has links to the simple patch I tried, and discusses the more
 advanced technique Laurent experimented with.
 Elena subsequently developed an emacs plugin which looks interesting
 (I'm a VI ninja though so haven't used it)

 http://groups.google.com/group/clojure/browse_thread/thread/ca7076f4c6591fdd/cda5cf10b89a3679

 My own experience FWIW was that it was great for two weeks coding with
 autodef, then for about a week I became frustrated with my typos and
 disabled it. More promising solutions might come from an external tool
 (such as Knuth's literate programming noweb) or IDE support like Elena
 described.

 For now my work flow is write the code backwards (ie: manually move
 the cursor up) and/or chopping and pasting. Then when I'm happy with
 it, I re-chop it all in my 'preferred' order and put a declare at the
 top. That sounds quite inefficient, but VI is really great for re-
 organizing text blocks so it is not too strenuous. That said, I'm
 really interested in ways that literate programming style can be
 followed with the least external support.


 Regards,
 Tim.


 On Mar 26, 4:15 pm, Mark Engelberg mark.engelb...@gmail.com wrote:
  On Wed, Mar 11, 2009 at 5:18 PM, Timothy Pratley
 
  timothyprat...@gmail.com wrote:
   It is also quite trivial to patch the compiler to auto-def symbols as
   it finds them instead of throwing an error.
 
  I would be interested in knowing how to do such a patch.  When I work
  on code, I like to organize my functions in a way that makes it easy
  to read and understand what is going on.  As I work on longer chunks
  of Clojure code, I'm finding that shuffling around the functions to
  avoid a lot of forward declarations is destroying the readability of
  my code.
 


--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Is Clojure's lack of support for forward referencing a feature or a bug?

2009-03-25 Thread Timothy Pratley

:) I like that description! :)

On Mar 26, 4:47 pm, David Nolen dnolen.li...@gmail.com wrote:
 For what it's worth I'm a big fan of the wishful thinking programming style.
 I write some functions how I think they should look, declare the functions I
 haven't defined yet. Then I implement the lower level functions, write some
 tests- then usually the higher level stuff works without too much tweaking.
 In a non-functional programming language this doesn't work so well, but it's
 a good fit for something like Clojure.

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Is Clojure's lack of support for forward referencing a feature or a bug?

2009-03-11 Thread pmf

On Mar 11, 4:23 pm, quasar quasistellarli...@gmail.com wrote:
 It seems it makes Clojure source code to be in the order of lowest-to-
 highest abstraction.
 Naive mutual recursion based on top-level functions is impossible.
 I am curious, is it due to the current implementaiton of Reader or by
 design?

You can use
  (declare something)


--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Is Clojure's lack of support for forward referencing a feature or a bug?

2009-03-11 Thread Timothy Pratley

Clojure does support forward referencing (if I understand your
question):
user= (declare a)
user= (defn b [x] (a x))
user= (defn a [x] (b x))
user= (a 4)
java.lang.StackOverflowError
Note: (declare a) is a synonym for (def a) which works also.

It is also quite trivial to patch the compiler to auto-def symbols as
it finds them instead of throwing an error. That makes it hard to
discover typoed symbols. One strategy to have the best of both worlds
would be to allow auto-def until a non-def call is made, and at that
point warn if there are any unbound. Not quite correct for a fully
dynamic language.


Regards,
Tim.

On Mar 12, 2:23 am, quasar quasistellarli...@gmail.com wrote:
 It seems it makes Clojure source code to be in the order of lowest-to-
 highest abstraction.
 Naive mutual recursion based on top-level functions is impossible.
 I am curious, is it due to the current implementaiton of Reader or by
 design?

 Best regards,
 Leonid
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---