Re: Top-down code in namspaces

2014-06-04 Thread u1204
> Hi everyone, I'm looking to get some opinions on code style. > > Specifically, I like to write my code in a top-down. > > What I mean by that is that within a file the highest-level functions sit > at the top, and are implemented in terms of lower-level functions further > down. You could write

Re: Top-down code in namspaces

2014-06-04 Thread Luc Prefontaine
I maintain that the average human being looking at sed commands would rather end up standing on his head for a significant amount of time to avoid it :))) BTWY, I have been scripting under u*x for a few decades by now. I resort to it when nothing and I mean nothing (think about Daffy Duck's voi

Re: Top-down code in namspaces

2014-06-04 Thread Phillip Lord
Then integrate the whole lot into the Clojure compiler pipeline so that it just works in the first place. Reid McKenzie writes: > Clearly the solution is to use tools.analyzer and write a big def emitter > > /s > Reid > On 06/04/2014 10:27 AM, Mars0i wrote: >> >> >> On Wednesday, June 4, 2014 9

Re: Top-down code in namspaces

2014-06-04 Thread Colin Fleming
I actually have an open issue for Cursive to do this automatically: #200 . I'm starting to think a namespace sorter that automatically manages the declares might not be such a crazy idea. On 5 June 2014 03:37, Reid McKenzie wrote: > Clearly

Re: Top-down code in namspaces

2014-06-04 Thread Reid McKenzie
Clearly the solution is to use tools.analyzer and write a big def emitter /s Reid On 06/04/2014 10:27 AM, Mars0i wrote: > > > On Wednesday, June 4, 2014 9:42:41 AM UTC-5, Mars0i wrote: > > ... Then I add the new functions to the declarestatement by hand, > or I periodically do something li

Re: Top-down code in namspaces

2014-06-04 Thread Mars0i
On Wednesday, June 4, 2014 9:42:41 AM UTC-5, Mars0i wrote: > > ... Then I add the new functions to the declare statement by hand, or I > periodically do something like: > > grep defn mysourcefile.clj >> mysourcefile.clj > (Be careful to use two ">"s!) > > and then I edit the junk at the end of t

Re: Top-down code in namspaces

2014-06-04 Thread Mars0i
On Sunday, June 1, 2014 9:36:55 AM UTC-5, Glen Mailer wrote: > > Hi everyone, I'm looking to get some opinions on code style. > > Specifically, I like to write my code in a top-down. > > What I mean by that is that within a file the highest-level functions sit > at the top, and are implemented i

Re: Top-down code in namspaces

2014-06-04 Thread Phillip Lord
Gregg Reynolds writes: >> This is not side-effect free (sorry for pun). I did this for my code, >> and now slamhound doesn't work on it. Other tools too? I don't know. >> >> https://github.com/technomancy/slamhound/issues/61 > > > (load "foo") is legal Clojure; if a tool can't handle it, that's e

Re: Top-down code in namspaces

2014-06-04 Thread Phillip Lord
Gary Trakhman writes: > Knowing with certainty that some called method is defined above in the > compilation strategy simplifies code-reading and comprehension by > minimizing where you have to look, and it also makes it easier to move > stuff around with a text editor than what I imagine the alte

Re: Top-down code in namspaces

2014-06-03 Thread Colin Fleming
> > (load "foo") is legal Clojure; if a tool can't handle it, that's either a > bug or a deliberate limitation in the tool. This is not true. Cursive, for example, indexes Clojure projects in order to perform its magic. In IntelliJ, index data for a file is only allowed to depend on the contents

Re: Top-down code in namspaces

2014-06-03 Thread Softaddicts
Does not work on my iPad, I forget to lock the display every time. Damn it... Luc P. > I just turn the monitor upside-down ;-). > > > On Tue, Jun 3, 2014 at 1:50 PM, Luc Prefontaine > wrote: > > > Yeah, it's certainly hard, just tried it, > > blood pressure increases in the head > > and my

Re: Top-down code in namspaces

2014-06-03 Thread Gary Trakhman
I just turn the monitor upside-down ;-). On Tue, Jun 3, 2014 at 1:50 PM, Luc Prefontaine wrote: > Yeah, it's certainly hard, just tried it, > blood pressure increases in the head > and my eyes were bulging out of their > sockets. > > A bit easier using these chairs > that allow you to flip upsi

Re: Top-down code in namspaces

2014-06-03 Thread Luc Prefontaine
Yeah, it's certainly hard, just tried it, blood pressure increases in the head and my eyes were bulging out of their sockets. A bit easier using these chairs that allow you to flip upside down, less strain on the neck and no need to keep up your balance every second or so. My apology to the rea

Re: Top-down code in namspaces

2014-06-03 Thread Gregg Reynolds
On Tue, Jun 3, 2014 at 8:32 AM, Gregg Reynolds wrote: > > > > On Sun, Jun 1, 2014 at 9:36 AM, Glen Mailer wrote: > >> Hi everyone, I'm looking to get some opinions on code style. >> > ... > 4. Put your helper funcs ("defn-" stuff) in helpers.clj, without a call > to ns at the top, then (load "

Re: Top-down code in namspaces

2014-06-03 Thread Gregg Reynolds
On Tue, Jun 3, 2014 at 9:51 AM, Phillip Lord wrote: > Gregg Reynolds writes: > > > 4. Put your helper funcs ("defn-" stuff) in helpers.clj, without a call > to > > ns at the top, then (load "helpers") at the top of the file that uses > them. > > You still get the effect you're looking for, wit

Re: Top-down code in namspaces

2014-06-03 Thread Gary Trakhman
It takes a while (a couple months) to get used to reading things upside-down, but I wouldn't want to go back. Knowing with certainty that some called method is defined above in the compilation strategy simplifies code-reading and comprehension by minimizing where you have to look, and it also make

Re: Top-down code in namspaces

2014-06-03 Thread Phillip Lord
Gregg Reynolds writes: > 4. Put your helper funcs ("defn-" stuff) in helpers.clj, without a call to > ns at the top, then (load "helpers") at the top of the file that uses them. > You still get the effect you're looking for, with a one line "preface" > that tells the reader where to look for mo

Re: Top-down code in namspaces

2014-06-03 Thread Timothy Baldridge
Another way of looking at Clojure code is not a "top down abstraction first" view, but as the building of a system from smaller parts. The best example of this is clojure/core.clj . Sure it's bootstrap code so it can be a bit verbose at times, but you start with nothing and end up with a complete s

Re: Top-down code in namspaces

2014-06-03 Thread Gregg Reynolds
On Sun, Jun 1, 2014 at 9:36 AM, Glen Mailer wrote: > Hi everyone, I'm looking to get some opinions on code style. > > Specifically, I like to write my code in a top-down. > > What I mean by that is that within a file the highest-level functions sit > at the top, and are implemented in terms of lo

Re: Top-down code in namspaces

2014-06-03 Thread Phillip Lord
Sean Corfield writes: > On Jun 1, 2014, at 11:53 PM, u1204 wrote: >> Instead of calling load to read the file, call your tangle function. > > Whilst that might work from the REPL, it's not going to work with normal > Clojure tooling and it would mean you couldn't just :require files written > tha

Re: Top-down code in namspaces

2014-06-02 Thread Sean Corfield
On Jun 1, 2014, at 11:53 PM, u1204 wrote: > Instead of calling load to read the file, call your tangle function. Whilst that might work from the REPL, it's not going to work with normal Clojure tooling and it would mean you couldn't just :require files written that way in the file's ns either.

Re: Top-down code in namspaces

2014-06-01 Thread u1204
>Specifically, I like to write my code in a top-down. > >What I mean by that is that within a file the highest-level functions sit >at the top, and are implemented in terms of lower-level functions further >down. > >The idea is that through sensible naming, a reader should be able to stop >readi

Re: Top-down code in namspaces

2014-06-01 Thread Luc Prefontaine
a) move out helpers or core code out of the API name space b) tag stuff left not part of the API as private in the API name space c) keep the API at the bottom d) do the above iteratively as code evolves So far it's been workable ( > 2 locs so far). Not too much name space switche

Top-down code in namspaces

2014-06-01 Thread Glen Mailer
Hi everyone, I'm looking to get some opinions on code style. Specifically, I like to write my code in a top-down. What I mean by that is that within a file the highest-level functions sit at the top, and are implemented in terms of lower-level functions further down. The idea is that through s