Re: (memoize) and recursive functions (Clojure 1.2)

2011-04-01 Thread Laurent PETIT
2011/4/1 Ken Wesson kwess...@gmail.com

 On Thu, Mar 31, 2011 at 3:24 PM, Laurent PETIT laurent.pe...@gmail.com
 wrote:
  2011/3/31 Ken Wesson kwess...@gmail.com
 
  On Wed, Mar 30, 2011 at 12:02 PM, Laurent PETIT 
 laurent.pe...@gmail.com
  wrote:
   Except in 1.3 it will be a little bit harder to do throw-away
   per-thread
   memoizes for vars you do no own if their author didn't make their
   holding
   var :dynamic ('cause then you will not be able to rebind them).
  
   This is close to being a problem for paredit.clj (not tested yet), but
   hopefully I'll discover that I'm using memoize this way with paredit's
   own
   functions only ...
 
  You'll still be able to use
 
  (ns foo.core
   (use (somens.baz :exclude quux)))
 
  (def quux (memoize somens.baz/quux))
 
  (code that
   (uses quux
 (goes here)))
 
  Indeed but that's not what I meant to express. I was talking about a more
  volatile memoization, one which does not stay around until the
  foo.core/quux root's value is explicitly replaced (and hopefully garbage
  collected).

 Well, there's always

 (ns foo,.core
  (use ...))

 (some code
  (let [quux (memoize quux)]
(more code)))

 when you want the memoized version locally, and don't mind creating it
 anew (with no memory) each time a particular code path is called.


Well, of course, but then it's lexically scoped, and you'll have to pass it
around to every function which may need it (or who calls a function which
may need it).
Not so with a carefully rebound var.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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: NB/Enclojure issues

2011-04-01 Thread Laurent PETIT
You should really consider adding a ;tldr section in your posts ...

2011/4/1 Ken Wesson kwess...@gmail.com

 (I'm aware that there's a separate Enclojure Google Group but it seems
 to get very little traffic, and I've seen similar issues to mine
 raised there for literally years without seeing an answer posted
 there, so I'm asking here.)

 While Enclojure provides a decent REPL and generally decent editing UI
 and project management, it has one serious Achilles heel for me (aside
 from lack of rainbow parens):

 It gets hung up from time to time.

 Though I haven't known it to wedge and stay that way, necessitating a
 sigkill/task manager intervention and restart, if it's been left alone
 for any length of time, I often find it hung and nonresponsive when I
 come back to it. It often seems normal until I click in either the
 REPL or an edit pane and then goes to a busy cursor; regardless, it
 will usually be from one to three MINUTES before I get a blinking
 cursor.

 And then, if I actually type something at it, it freezes again for
 several MORE minutes.

 If I then make a REPL, it will typically freeze again for several MORE
 minutes.

 Once all three of these freezes have been endured, it tends to stay
 usable as long as it's not backgrounded for too long.

 Now, to my understanding, software is not like electric motors and
 machinery with moving parts. It doesn't get gummed up and balky until
 you get the machine oil that lubricates its parts warmed up again.

 That considered, Enclojure does a surprisingly good emulation of being
 a balky mechanical contraption at times.

 An interesting question is, of course, what is it actually *doing*
 when it's not responding, as a UI-dominated tool should, to user
 input? The Windows task manager offers a possible clue: the netbeans
 process will be using no detectable CPU but its process size will be
 growing rapidly, packing on several megs every second, typically
 bloating up to several hundred megs by the time it gets out of the
 third and final freeze.

 So, apparently it is allocating memory and building some very large
 data structures. And the time it takes and low CPU use suggests it's
 populating those data structures with data it gets from the filesystem
 rather than by computing.

 The second clue is that there will be a status indicator during the
 first freeze, at least, that says Checking for external changes; it
 rapidly reaches 99% and then hangs there for the duration of that
 freeze. So it may even be network I/O that it's waiting for, network
 I/O that's timing out instead of connecting.

 The data structures don't appear to be temporary; the NB process size
 stays that huge for as long as it's in use. If it's backgrounded for a
 while (not sure exactly how long) the extra memory use disappears
 again.

 Since as far as I am aware most or all of NB is implemented in Java,
 the pattern of large, expensively-created data structures lingering
 but eventually vanishing during idle time suggests SoftReferences hold
 those data structures. As for what they are -- maybe all the
 information needed to quickly autocomplete, pull up JavaDocs, and
 things like that? If so, it could be a general issue with NetBeans
 that's more the fault of the sheer size of Java's standard library
 (and thus all the declarations and documentation URLs and such) than
 anything else.

 Still, it is, IMO, poor design for NB (or, if it is that, Enclojure)
 to lock the user out of using the application while it regenerates
 these data structures. Having autocomplete and doc lookup be chancy
 for a little while (or cause a Please Wait... dialog with a cancel
 option) while the data structures are generated in the background
 would help. Also, if it is using the network, or groveling over all
 sorts of jars and subdirectories, or both, perhaps it should cache a
 serialized representation of those data structures on disk, even
 across sessions.

 At the *very* least, IMO, there should be a modal dialog if the app is
 going to be unresponsive and not just a note in the status line; its
 message should be less cryptic than Checking for external changes;
 and the progress meter should be honest rather than jumping to 99%
 almost instantly and then sitting there for minutes.

 In any event, I'm not calling this an Enclojure bug or even a NetBeans
 bug just yet. It's a wart, at minimum, and it may be in NB rather than
 specific to Enclojure.

 But I am asking if anybody knows more about this, and especially if
 anybody knows of a way to grease the wheels, so to speak, or to keep
 them well lubricated during idle periods.

 FWIW, the machine is fast, has fast disks, has broadband, and has 3GB
 of RAM, of which typically no more than 2 are in use at any given time
 (so thrashing should not be a concern). NB should not have any
 problems with network access (even non-HTTP, unless it's opening a
 listen socket to receive from remote Internet hosts)  caused by
 anything between 

Re: Basic compilation question

2011-04-01 Thread MohanR
The correct syntax works. So basically if the swank-clojure-classpath
has the required jar I should be able to import it in this way. The
classpath seems to be tripping me up again.


Thanks,
Mohan

On Mar 31, 5:12 pm, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 On 31 Mrz., 13:20, MohanR radhakrishnan.mo...@gmail.com wrote:

  (import '(com.test.Test))

 The correct syntax is (import 'com.test.Test) or (import '(com.test
 Test)). Note the subtle difference.

 Sincerely
 Meikel

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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: Announcement: flutter - hiccup-based form field generation

2011-04-01 Thread Joost
I just pushed release 0.0.2, which has many improvements and a bit
more documentation on the API.

If you're interested, please take a look and let me know if you have
any questions or remarks.

Cheers,
Joost Diepenmaat.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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: (memoize) and recursive functions (Clojure 1.2)

2011-04-01 Thread Ken Wesson
On Fri, Apr 1, 2011 at 1:59 AM, Laurent PETIT laurent.pe...@gmail.com wrote:
 2011/4/1 Ken Wesson kwess...@gmail.com

 On Thu, Mar 31, 2011 at 3:24 PM, Laurent PETIT laurent.pe...@gmail.com
 wrote:
  2011/3/31 Ken Wesson kwess...@gmail.com
 
  On Wed, Mar 30, 2011 at 12:02 PM, Laurent PETIT
  laurent.pe...@gmail.com
  wrote:
   Except in 1.3 it will be a little bit harder to do throw-away
   per-thread
   memoizes for vars you do no own if their author didn't make their
   holding
   var :dynamic ('cause then you will not be able to rebind them).
  
   This is close to being a problem for paredit.clj (not tested yet),
   but
   hopefully I'll discover that I'm using memoize this way with
   paredit's
   own
   functions only ...
 
  You'll still be able to use
 
  (ns foo.core
   (use (somens.baz :exclude quux)))
 
  (def quux (memoize somens.baz/quux))
 
  (code that
   (uses quux
     (goes here)))
 
  Indeed but that's not what I meant to express. I was talking about a
  more
  volatile memoization, one which does not stay around until the
  foo.core/quux root's value is explicitly replaced (and hopefully garbage
  collected).

 Well, there's always

 (ns foo,.core
  (use ...))

 (some code
  (let [quux (memoize quux)]
    (more code)))

 when you want the memoized version locally, and don't mind creating it
 anew (with no memory) each time a particular code path is called.

 Well, of course, but then it's lexically scoped, and you'll have to pass it
 around to every function which may need it (or who calls a function which
 may need it).
 Not so with a carefully rebound var.

If you want old code X to use a memoized version of a function f
defined in old code Y, and X calls f via its var, then you have no
choice but to use binding or def to replace f with its memoized
version globally.

If it's only direct calls to f from your own code you want to memoize,
though, and you want to dynamically scope the memoization and gc it
later:

(ns foo.core
  (use (somens.baz :exclude quux)))

(def ^:dynamic quux somens.baz/quux)

(code that
  (uses quux
    (goes here)))

(defn somefn-that-wants-quux-memoized-during-its-execution []
  (binding [quux (memoize quux)]
(code that
  (uses memoized quux
(and calls functions
  (we want to use memoized quux
(goes here)))

As long as the called functions look up quux via foo.core/quux and not
somens.baz/quux they'll get the memoized version if called during the
execution of the above function.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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: NB/Enclojure issues

2011-04-01 Thread Ken Wesson
On Fri, Apr 1, 2011 at 2:02 AM, Laurent PETIT laurent.pe...@gmail.com wrote:
 You should really consider adding a ;tldr section in your posts ...

What?

And why do you seem to be trying to redirect replies to your on-list
posts to your personal email?

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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: (memoize) and recursive functions (Clojure 1.2)

2011-04-01 Thread Laurent PETIT
2011/4/1 Ken Wesson kwess...@gmail.com

 On Fri, Apr 1, 2011 at 1:59 AM, Laurent PETIT laurent.pe...@gmail.com
 wrote:
  2011/4/1 Ken Wesson kwess...@gmail.com
 
  On Thu, Mar 31, 2011 at 3:24 PM, Laurent PETIT laurent.pe...@gmail.com
 
  wrote:
   2011/3/31 Ken Wesson kwess...@gmail.com
  
   On Wed, Mar 30, 2011 at 12:02 PM, Laurent PETIT
   laurent.pe...@gmail.com
   wrote:
Except in 1.3 it will be a little bit harder to do throw-away
per-thread
memoizes for vars you do no own if their author didn't make their
holding
var :dynamic ('cause then you will not be able to rebind them).
   
This is close to being a problem for paredit.clj (not tested yet),
but
hopefully I'll discover that I'm using memoize this way with
paredit's
own
functions only ...
  
   You'll still be able to use
  
   (ns foo.core
(use (somens.baz :exclude quux)))
  
   (def quux (memoize somens.baz/quux))
  
   (code that
(uses quux
  (goes here)))
  
   Indeed but that's not what I meant to express. I was talking about a
   more
   volatile memoization, one which does not stay around until the
   foo.core/quux root's value is explicitly replaced (and hopefully
 garbage
   collected).
 
  Well, there's always
 
  (ns foo,.core
   (use ...))
 
  (some code
   (let [quux (memoize quux)]
 (more code)))
 
  when you want the memoized version locally, and don't mind creating it
  anew (with no memory) each time a particular code path is called.
 
  Well, of course, but then it's lexically scoped, and you'll have to pass
 it
  around to every function which may need it (or who calls a function which
  may need it).
  Not so with a carefully rebound var.

 If you want old code X to use a memoized version of a function f
 defined in old code Y, and X calls f via its var, then you have no
 choice but to use binding or def to replace f with its memoized
 version globally.


It is clear that we are in strong agreement since the beginning of this
thread ...



 If it's only direct calls to f from your own code you want to memoize,
 though, and you want to dynamically scope the memoization and gc it
 later:

 (ns foo.core
  (use (somens.baz :exclude quux)))

 (def ^:dynamic quux somens.baz/quux)

 (code that
   (uses quux
 (goes here)))

 (defn somefn-that-wants-quux-memoized-during-its-execution []
  (binding [quux (memoize quux)]
(code that
  (uses memoized quux
(and calls functions
  (we want to use memoized quux
(goes here)))

 As long as the called functions look up quux via foo.core/quux and not
 somens.baz/quux they'll get the memoized version if called during the
 execution of the above function.

 --
 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
 Note that posts from new members are moderated - please be patient with
 your first post.
 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


-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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: NB/Enclojure issues

2011-04-01 Thread Laurent PETIT
2011/4/1 Ken Wesson kwess...@gmail.com

 On Fri, Apr 1, 2011 at 2:02 AM, Laurent PETIT laurent.pe...@gmail.com
 wrote:
  You should really consider adding a ;tldr section in your posts ...


 What?


;tldr means too long, didn't read (I discovered this recently) and it acts
as a sort of the start of a short section at the end of a long post where
people not having time to read it in its entirety can see a summary.
Something like that :

...
...
long
long
...
post
...

;tldr
... short summary  ...




 And why do you seem to be trying to redirect replies to your on-list
 posts to your personal email?


I was not aware of that. It was not intentional, I wasn't trying to do
anything.
I assume it's because I hit the reply-all button instead of reply (I now
see that the reply to is correctly set to the group, so that's what I'll
be using from now, thanks for having pointed this).

-- 
Laurent

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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: NB/Enclojure issues

2011-04-01 Thread Meikel Brandmeyer
Hi,

On 1 Apr., 11:01, Laurent PETIT laurent.pe...@gmail.com wrote:

 ;tldr means too long, didn't read (I discovered this recently) and it acts
 as a sort of the start of a short section at the end of a long post where
 people not having time to read it in its entirety can see a summary.

For this case it could look like this:

tl;dr: I have severe responsiveness problems with Netbeans and
Enclojure. There is no obvious CPU activity, so it seems to be
something I/O related. The status message Checking for external
changes also points into this direction. Does someone have a similar
problem?

Sincerely
Meikel

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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: NB/Enclojure issues

2011-04-01 Thread Chas Emerick

On Apr 1, 2011, at 5:29 AM, Meikel Brandmeyer wrote:

 Hi,
 
 On 1 Apr., 11:01, Laurent PETIT laurent.pe...@gmail.com wrote:
 
 ;tldr means too long, didn't read (I discovered this recently) and it acts
 as a sort of the start of a short section at the end of a long post where
 people not having time to read it in its entirety can see a summary.
 
 For this case it could look like this:
 
 tl;dr: I have severe responsiveness problems with Netbeans and
 Enclojure. There is no obvious CPU activity, so it seems to be
 something I/O related. The status message Checking for external
 changes also points into this direction. Does someone have a similar
 problem?

Yes, I encountered such behaviour on a regular basis across many releases in my 
time using NetBeans (close to 2 years, which started when Enclojure was the 
only option for those of us that are allergic to emacs).  In my experience, 
NetBeans does get gummed up on a regular basis, almost always while engaging in 
various automatic IO-intensive scanning processes:

http://blogs.sun.com/netbeansphp/entry/enable_auto_scanning_of_sources
http://wiki.netbeans.org/FaqScanningAndIndexingIssues

The project actually has a FAQ highlighting various ways the IDE might become 
unresponsive:

http://wiki.netbeans.org/FaqSlowNetBeans

- Chas

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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


definterface / gen-class constructor issue - alpha4

2011-04-01 Thread Jules
Guys,

I've come across an annoying issue that has cost me some tie - so I thought 
I would post it in case anyone else has the same problem or a better 
solution - or perhaps I am just doing it wrong :-) ?

If I had more time I would write a testcase and try to reduce it further but 
I haven't :-(

It manifests itself thus :

You define an interface Foo in xxx/foo.clj

You gen-class a class Bar which expects a Foo in its construction.

In yyy/Bar.clj :
I :use xxx.foo
I :import xxx.foo,Foo
I specify xxx.foo..Foo's canonical name in the :constructor description.

Yet, and this is the interesting bit, on my netbook I always get a 
compilation error - ClassNotFound xxx.foo.Foo. Whilst on my desktop and 
other machines on which I have tried the compilation it proceeds with no 
problem.

I briefly compared JDK, Maven and Clojure versions on all the boxes that I 
tested this on - the netbook (on which the problem occurs) had the same 
versions as the other machines. All were using a clean git tree of the 
project in question.

I can work around the problem by declaring that the constructor expects 
Object, then using a ^Foo type hint in the definition of the -init function 
- so I know that this can happily see Foo.

Is it possible that there is some sort of race condition going on ? That 
Bar's constructor has failed to express its dependency on Foo somehow and 
that it it just luck that on faster multicore machines Foo is compiled in 
time to be seen at Bar's constructor's compilation time ? whereas on slower 
single core machines like my netbook, it is not ?

Its taken quite a while to reduce it to this, as the problem moves around as 
code changes etc and only manifests itself on one of the machines with which 
I work... but if there is interest I may be able to reduce it further.

thanks for your time,

Jules


-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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: NB/Enclojure issues

2011-04-01 Thread Armando Blancas
That's how it is with these bloated IDEs. My day job is mainly Eclipse
plug-in/rcp dev, so I'm also guilty of putting an absurd burden on
others (disk footprint, startup time, memory use, unresponsiveness),
but that's what's passes for effective tooling these days.

On Apr 1, 4:10 am, Chas Emerick cemer...@snowtide.com wrote:
 On Apr 1, 2011, at 5:29 AM, Meikel Brandmeyer wrote:

  Hi,

  On 1 Apr., 11:01, Laurent PETIT laurent.pe...@gmail.com wrote:

  ;tldr means too long, didn't read (I discovered this recently) and it 
  acts
  as a sort of the start of a short section at the end of a long post where
  people not having time to read it in its entirety can see a summary.

  For this case it could look like this:

  tl;dr: I have severe responsiveness problems with Netbeans and
  Enclojure. There is no obvious CPU activity, so it seems to be
  something I/O related. The status message Checking for external
  changes also points into this direction. Does someone have a similar
  problem?

 Yes, I encountered such behaviour on a regular basis across many releases in 
 my time using NetBeans (close to 2 years, which started when Enclojure was 
 the only option for those of us that are allergic to emacs).  In my 
 experience, NetBeans does get gummed up on a regular basis, almost always 
 while engaging in various automatic IO-intensive scanning processes:

 http://blogs.sun.com/netbeansphp/entry/enable_auto_scanning_of_sourceshttp://wiki.netbeans.org/FaqScanningAndIndexingIssues

 The project actually has a FAQ highlighting various ways the IDE might become 
 unresponsive:

 http://wiki.netbeans.org/FaqSlowNetBeans

 - Chas

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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: NB/Enclojure issues

2011-04-01 Thread Chas Emerick
On the contrary, I've found Eclipse to be very responsive and pleasant to use, 
having now used it exclusively for the past 8 months or so and been 
particularly productive with it.

I'll absolutely grant that the plugin/RCP development lifecycle is painful, but 
if you're lucky enough to avoid being an Eclipse plugin author, you get to 
enjoy all of the benefits that go along with that ecosystem.  I particularly 
like the bleeding-edge attention Amazon gives to their AWS plugin[1] and the 
GUI builders that Google open-sourced sometime last year[2].

- Chas

[1] http://aws.amazon.com/eclipse/
[2] http://code.google.com/javadevtools/wbpro/index.html

On Apr 1, 2011, at 10:18 AM, Armando Blancas wrote:

 That's how it is with these bloated IDEs. My day job is mainly Eclipse
 plug-in/rcp dev, so I'm also guilty of putting an absurd burden on
 others (disk footprint, startup time, memory use, unresponsiveness),
 but that's what's passes for effective tooling these days.
 
 On Apr 1, 4:10 am, Chas Emerick cemer...@snowtide.com wrote:
 On Apr 1, 2011, at 5:29 AM, Meikel Brandmeyer wrote:
 
 Hi,
 
 On 1 Apr., 11:01, Laurent PETIT laurent.pe...@gmail.com wrote:
 
 ;tldr means too long, didn't read (I discovered this recently) and it 
 acts
 as a sort of the start of a short section at the end of a long post where
 people not having time to read it in its entirety can see a summary.
 
 For this case it could look like this:
 
 tl;dr: I have severe responsiveness problems with Netbeans and
 Enclojure. There is no obvious CPU activity, so it seems to be
 something I/O related. The status message Checking for external
 changes also points into this direction. Does someone have a similar
 problem?
 
 Yes, I encountered such behaviour on a regular basis across many releases in 
 my time using NetBeans (close to 2 years, which started when Enclojure was 
 the only option for those of us that are allergic to emacs).  In my 
 experience, NetBeans does get gummed up on a regular basis, almost always 
 while engaging in various automatic IO-intensive scanning processes:
 
 http://blogs.sun.com/netbeansphp/entry/enable_auto_scanning_of_sourceshttp://wiki.netbeans.org/FaqScanningAndIndexingIssues
 
 The project actually has a FAQ highlighting various ways the IDE might 
 become unresponsive:
 
 http://wiki.netbeans.org/FaqSlowNetBeans
 
 - Chas
 
 -- 
 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
 Note that posts from new members are moderated - please be patient with your 
 first post.
 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

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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: NB/Enclojure issues

2011-04-01 Thread Laurent PETIT
2011/4/1 Chas Emerick cemer...@snowtide.com

 On the contrary, I've found Eclipse to be very responsive and pleasant to
 use, having now used it exclusively for the past 8 months or so and been
 particularly productive with it.

 I'll absolutely grant that the plugin/RCP development lifecycle is painful


But it's becoming easier and easier (not yet to the point of being fun, tho)
thanks to an embedded nrepl server and your nrepl integration into CCW.
An opportunity to publicly thank you, Chas, again, for having pushed ahead
CCW's state of the art with your contributions !


 , but if you're lucky enough to avoid being an Eclipse plugin author, you
 get to enjoy all of the benefits that go along with that ecosystem.  I
 particularly like the bleeding-edge attention Amazon gives to their AWS
 plugin[1] and the GUI builders that Google open-sourced sometime last
 year[2].

 - Chas

 [1] http://aws.amazon.com/eclipse/
 [2] http://code.google.com/javadevtools/wbpro/index.html

 On Apr 1, 2011, at 10:18 AM, Armando Blancas wrote:

  That's how it is with these bloated IDEs. My day job is mainly Eclipse
  plug-in/rcp dev, so I'm also guilty of putting an absurd burden on
  others (disk footprint, startup time, memory use, unresponsiveness),
  but that's what's passes for effective tooling these days.
 
  On Apr 1, 4:10 am, Chas Emerick cemer...@snowtide.com wrote:
  On Apr 1, 2011, at 5:29 AM, Meikel Brandmeyer wrote:
 
  Hi,
 
  On 1 Apr., 11:01, Laurent PETIT laurent.pe...@gmail.com wrote:
 
  ;tldr means too long, didn't read (I discovered this recently) and
 it acts
  as a sort of the start of a short section at the end of a long post
 where
  people not having time to read it in its entirety can see a summary.
 
  For this case it could look like this:
 
  tl;dr: I have severe responsiveness problems with Netbeans and
  Enclojure. There is no obvious CPU activity, so it seems to be
  something I/O related. The status message Checking for external
  changes also points into this direction. Does someone have a similar
  problem?
 
  Yes, I encountered such behaviour on a regular basis across many
 releases in my time using NetBeans (close to 2 years, which started when
 Enclojure was the only option for those of us that are allergic to emacs).
  In my experience, NetBeans does get gummed up on a regular basis, almost
 always while engaging in various automatic IO-intensive scanning processes:
 
 
 http://blogs.sun.com/netbeansphp/entry/enable_auto_scanning_of_sourceshttp://wiki.netbeans.org/FaqScanningAndIndexingIssues
 
  The project actually has a FAQ highlighting various ways the IDE might
 become unresponsive:
 
  http://wiki.netbeans.org/FaqSlowNetBeans
 
  - Chas
 
  --
  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
  Note that posts from new members are moderated - please be patient with
 your first post.
  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

 --
 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
 Note that posts from new members are moderated - please be patient with
 your first post.
 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


-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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: NB/Enclojure issues

2011-04-01 Thread Armando Blancas
 I particularly like the bleeding-edge attention Amazon gives to their AWS 
plugin[1] and the GUI builders that Google open-sourced sometime last year[2].

Well, those gui builders are now free of charge, so there's something
to like right there. If that were the way products get built, or even
prototyped, the Instantiations dudes wouldn't have sold the shop to
Google. Or  maybe it's just that nobody will pay for tools anymore;
dunno. (WindowsTester Pro is excellent, IMO.)

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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


clojure-clr - getting started on Windows WPF

2011-04-01 Thread kjeldahl
I'm toying around with clojure-clr, and it seems to work great. But
getting started is a bit challenging to say the least (which may very
well be because of me beeing rookie with .net/clr as well). Anyway,
I've managed to find an example using the Windows Forms API, a simple
hello world example:

(import '(System.Reflection Assembly))
(Assembly/LoadWithPartialName System.Windows.Forms)
(ns helloworld
(:import (System.Windows.Forms MessageBox)))
(MessageBox/Show Hello world)

Runs fine under the latest 1.3 build of clojure-clr at least.

But I have yet to find any examples or get anything working using the
WPF APIs instead, which seems to be the direction Windows is heading.
Most WPF examples assumes using Visual Studio with it's GUI builder
and/or XML files. It is possible to do programmatically as well, so in
theory it should work fine with clojure. Most minimal examples of
programmatic WPF applications in C# just creates and shows a Window.
But when I try to do similar stuff in clojure-clr, there seems to be
some plumbing needed.

I haven't figured it all out yet, but it seem necessary to set up the
proper threading environment (SPF thread for GUI or something like
it), and try to create a window from that thread.

Needless to say, I'm struggling a bit and though I would ask this
community if anybody had a working example or links to such, for
starting out with clojure-clr and WPF.

Thanks,

Marius K.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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: ANN: status-codes keyword status codes for compojure

2011-04-01 Thread Hubert Iwaniuk
New version is out v0.2 featuring dependency on latest and greatest of 
compojure and special response code for today.
418 I'm a teapot

Cheers,
Hubert Iwaniuk.

On Mar 31, 2011, at 11:51 PM, Hubert Iwaniuk wrote:

 status-codes allows you to report HTTP Response Status Codes as keywords like 
 :ok, :accepted and so on.
 
 You can find code at github http://github.com/neotyk/status-codes
 
 (use 'status-codes)
 (GET /test _ :accepted)
 ;; or
 (PUT /test _ {:headers {Location ..} :status :created})
 
 Enjoy,
 Hubert Iwaniuk.
 
 

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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


Example to introspect a class

2011-04-01 Thread Mushfaque Chowdhury
Hi

I'm trying to solve a introspection problem of the following type

(def Region {'fields '((datatype x) (datatype y))})

(def Country {'fields '((int x) (double y {reference `Region}))})

I'd like to introspect the fields from Country and see {reference
Region} replaced by (reference ((datatype x) (datatype y)))

I can get as far as seeing this

((nth (nth (Country 'fields) 1) 2) 'reference)
which gives
(quote com.test.Common/Region)

which is sort of close, but how do I now look at it's fields?

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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


clearly, I'm too dense to upgrade slime/swank/clojure-mode... help?

2011-04-01 Thread B Smith-Mannschott
Some months ago my ability to send non-ascii characters to clojure
running in a swank server started with maven clojure:swank broke,
despite the fact that I'm doing this:

 (set-language-environment UTF-8)
 (setq slime-net-coding-system 'utf-8-unix)

In my .emacs file as suggested back in June 2009.

Since I haven't updated any of my tooling for quite some time, I
though, I'd give it a try and upgrade to current releases of
clojure-mode, clojure-swank and slime. I guess I hoped that the
breakage might be a bug since fixed.

I'm using Emacs 23.3.1; package.el 0.9

Here's what I was using before the upgrade:
- slime-20100404 via package.el
- slime-repl20100404 via package.el
- swank-clojure-1.1.0 via package.el
- clojure-test-mode-1.4
- clojure-mode 1.7
- clojure-maven-plugin 1.3.3
- swank-clojure 1.2.1

This combination worked pretty well, except that I can't get non-ascii
text to the clojure process via the slime repl. When I attempt this,
the repl just seems to freeze. I can continue to type at it, but the
prompt never reappears and no output is produced. The console from
which mvn clojure:swank was started does not show any output (e.g. no
stack trace).

I took this as an opportunity to upgrade my tooling. I remember the
tooling upgrade was quite a pain for me back with the clojure 1.1-1.2
transition, but hoped that things would work out better this time.

I tried to upgrade first from within package.el, but the default
package.el repository is (1) slow and (2) outdated. I discovered the
advice on https://github.com/technomancy/swank-clojure/ and:

(add-to-list 'package-archives
 '(marmalade . http://marmalade-repo.org/packages/;) t)

marmelade was also very slow, but after some minutes presented me with
a list containing more recent versions of various clojure related
packages. Unfortunately, installation took many minutes before finally
taking many minutes to 'parse the http repose header' (or words
thereabout) and then doing nothing and not actually installing
anything.

I scrapped that idea, and proceeded to install the upgrades by hand
from git sources:
- clojure-mode 1.8.0
- clojure-test-mode 1.5.4
- slime, slime-repl c27dd18db765c005bbdac9044b8ab513805e7e75
  https://github.com/technomancy/slime.git
- clojure-maven-plugin 1.3.8
- swank-clojure 1.3.0

Results:
- M-x slime-connect no longer works out of the box.
  M-x load-library slime is necessary
- When the repl starts, it is not displayed.
  M-x load-library slime-repl, M-x slime repl is necessary
- The repl is not clojure compatible, displaying instead the promt CL-USER

So. Experiment a failure. Thankfully I keep my emacs stuff under
version control, so I'll just revert back to the last known good state
and live without non-ascii characters.

It's not at all clear to me what combinations of what versions of
these various components are intended to work together.  The use
package.el advice is nice, but, again, it didn't work for me. Should
I just give up on slime and just run inferior clojure process and use
(load ...) or copy/paste? Is it possible to diagnose from this
meandering tale, where I went wrong?

// Ben

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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: using clojure for (java) code generation; advice sought

2011-04-01 Thread B Smith-Mannschott
On Wed, Mar 30, 2011 at 15:00, Stuart Sierra
the.stuart.sie...@gmail.com wrote:
 Take a look at http://www.stringtemplate.org/ for a Turing-complete,
 purely-functional, Java-based template language designed for code
 generation.

Thanks! This is actually the second time I've run across
stringtemplate, only now i'm taking the time to really dig into it.
I'm making progress and it looks like the right solution for my
immediate needs. I particularly like the effort it makes to enforce a
clean separation of template from business logic.

Since I'm a total beginner with stringtemplate, I'm trying to suss out
where to draw the line between putting complexity into the templates
and/or keeping it in clojure. (i.e. should I have a big template group
with one or two entry points where the templates call eachother), or
should I do composition from the outside via Clojure. I'll start with
the latter, but perhaps I'll move more into the templates as I gain
experience.

// Ben

 -Stuart Sierra
 clojure.com

 --
 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
 Note that posts from new members are moderated - please be patient with your
 first post.
 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

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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: using clojure for (java) code generation; advice sought

2011-04-01 Thread B Smith-Mannschott
On Thu, Mar 31, 2011 at 05:00, Eli Barzilay e...@barzilay.org wrote:
 On Tue, Mar 29, 2011 at 4:43 PM, B Smith-Mannschott wrote:
 Horrible hack, maybe, but it got me thinking. What you seem to be
 doing is moving between code and literal mode by quoting with #.
 This is a little like traditional quasi-quote...

 And that got me thinking about Scribble [1] again.  In this
 context I think of scribble as being sort of an inverse of normal
 scheme syntax.  In the end, the scribble reader produces the same
 kind of data structures as the normal scheme reader, but the
 emphasis is moved from code to textual content. Source is content
 by default, but you can escape into logic.

 This is kind of a good summary of the reader's intended use, beyond
 our documentation system: it's fitting for any kind of code that deals
 with a lot of textual content -- and having a kind of cheap DSLs for
 interacting with other tools by generating source is exactly one of
 the things that you can do with it.  But getting that from the
 scribble documentation will be a little hard -- I wrote a paper on
 just the implementation and use cases of the reader that will be much
 more fitting in this context, with some examples of such uses:
  http://barzilay.org/misc/scribble-reader.pdf

Thanks very much for the link. I'm enjoying the paper. When I've
addressed my immediate needs (with stringtemplate), I hope to return
to it again in more depth. I have this notion, that an alternate
reader for Clojure in the style of Scribble combined with core
concepts of stringtemplate could make a convenient and yet lispy
templating system for producing non-lisp code and other textual
output.

// Ben

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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: clearly, I'm too dense to upgrade slime/swank/clojure-mode... help?

2011-04-01 Thread Dennis Crenshaw
I have a problem with swank with an upgrade recently, clojure1.3-alpha5
works, clojure-1.3alpha6 does not, to my knowledge-- which Clojure version
are you using in your project?

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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: clearly, I'm too dense to upgrade slime/swank/clojure-mode... help?

2011-04-01 Thread B Smith-Mannschott
On Fri, Apr 1, 2011 at 22:23, Dennis Crenshaw crensha...@gmail.com wrote:
 I have a problem with swank with an upgrade recently, clojure1.3-alpha5
 works, clojure-1.3alpha6 does not, to my knowledge-- which Clojure version
 are you using in your project?

Silly me, I forgot to mention that. I'm on Clojure 1.2.0.

// ben

 --
 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
 Note that posts from new members are moderated - please be patient with your
 first post.
 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

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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: Example to introspect a class

2011-04-01 Thread Armando Blancas
You'd have to not back-quote Region and then eval the reseult:

user= (def Country {'fields '((int x) (double y {reference
Region}))})
#'user/Country
user= ((nth (nth (Country 'fields) 1) 2) 'reference)
Region
user= (eval ((nth (nth (Country 'fields) 1) 2) 'reference) )
{fields ((datatype x) (datatype y))}

If you want the contents of Region in Country and not its symbol:
(def Country `{fields ((int x) (double y {reference ~Region}))})
and look it up with:
((nth (nth (Country 'fields) 1) 2) 'user/reference)
(((nth (nth (Country 'fields) 1) 2) 'user/reference) 'fields)

Or to avoid the qualified names:
user= (def Country {'fields (list (list 'int 'x) (list 'double 'y
{'reference Region}))})
#'user/Country
user= ((nth (nth (Country 'fields) 1) 2) 'reference)
{fields ((datatype x) (datatype y))}
user= (((nth (nth (Country 'fields) 1) 2) 'reference) 'fields)
((datatype x) (datatype y))


On Apr 1, 7:56 am, Mushfaque Chowdhury
mushfaque.chowdh...@googlemail.com wrote:
 Hi

 I'm trying to solve a introspection problem of the following type

 (def Region {'fields '((datatype x) (datatype y))})

 (def Country {'fields '((int x) (double y {reference `Region}))})

 I'd like to introspect the fields from Country and see {reference
 Region} replaced by (reference ((datatype x) (datatype y)))

 I can get as far as seeing this

 ((nth (nth (Country 'fields) 1) 2) 'reference)
 which gives
 (quote com.test.Common/Region)

 which is sort of close, but how do I now look at it's fields?

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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: clearly, I'm too dense to upgrade slime/swank/clojure-mode... help?

2011-04-01 Thread B Smith-Mannschott
(I'm using Clojure 1.2.0; I neglected to mention that in my first message.)

I was able to upgrade to clojure-mode 1.8.0 and clojure-test-mode
1.5.4 after installing a later package.el 0.9 than the one I had
installed previously:

  commit e47f392dd688ac5f7bb06eeb96b7a29d95de1ce7
  Author: Phil Hagelberg technoma...@gmail.com
  Date:   2010-12-12 13:45:25 -0800

Update with latest version from Emacs 24

All is once again well, except that utf-8 via slime to clojure started
by mvn clojure:swank still doesn't work. Now I am seeing an exception,
so i thought I'd post it here:

(1) type ä [RETURN] into the REPL.

 in the *slime-repl clojure* buffer 
user ä [RETURN]

 in the *slime-events* buffer 
(:emacs-rex
 (swank:listener-eval \ä\\n)
 user :repl-thread 3)
(:write-string \ä\\n :repl-result)
---

(2) type [RETURN] (a second time) into the REPL

 in the *slime-events* buffer 
(:emacs-rex
 (swank:listener-eval \n)
 user :repl-thread 4)
 in the mvn clojure:swank console 
exception in read loop
java.lang.NumberFormatException: For input string: 
3
at 
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:449)
at swank.core.protocol$read_swank_message.invoke(protocol.clj:41)
at swank.core.connection$read_from_connection.invoke(connection.clj:59)
at swank.core$read_loop.invoke(core.clj:337)
at swank.swank$connection_serve$fn__1568$fn__1569.invoke(swank.clj:41)
at clojure.lang.AFn.applyToHelper(AFn.java:159)
at clojure.lang.AFn.applyTo(AFn.java:151)
at clojure.core$apply.invoke(core.clj:540)
at swank.swank$connection_serve$fn__1568.doInvoke(swank.clj:38)
at clojure.lang.RestFn.invoke(RestFn.java:398)
at clojure.lang.AFn.run(AFn.java:24)
at java.lang.Thread.run(Thread.java:680)


Does this ring any bells with anyone?

// Ben

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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: Example to introspect a class

2011-04-01 Thread Ken Wesson
On Fri, Apr 1, 2011 at 10:56 AM, Mushfaque Chowdhury
mushfaque.chowdh...@googlemail.com wrote:
 Hi

 I'm trying to solve a introspection problem of the following type

 (def Region {'fields '((datatype x) (datatype y))})

 (def Country {'fields '((int x) (double y {reference `Region}))})

 I'd like to introspect the fields from Country and see {reference
 Region} replaced by (reference ((datatype x) (datatype y)))

 I can get as far as seeing this

 ((nth (nth (Country 'fields) 1) 2) 'reference)
 which gives
 (quote com.test.Common/Region)

 which is sort of close, but how do I now look at it's fields?

First of all, that's not actually a class, it's a var.

Second, does it actually need to be quoted a second level?

Third, (second '(quote com.test.Common/Region)) will be the symbol
com.test.Common/Region, and if you get that symbol into a local named
foo, (ns-resolve *ns* foo) ought to yield up a Var object.

And (@that-var 'fiels} then ought to cough up '((datatype x) (datatype y)).

Indeed:

user= (def Region {'fields '((datatype x) (datatype y))})
#'user/Region

user= (def Country {'fields '((int x) (double y {reference `Region}))})
#'user/Country

user= (@(ns-resolve (find-ns 'user) (nth ((nth (nth (Country 'fields)
1) 2) 'reference) 1)) 'fields)
((datatype x)
 (datatype y))

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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: using clojure for (java) code generation; advice sought

2011-04-01 Thread Eli Barzilay
On Apr 1, 4:23 pm, B Smith-Mannschott bsmith.o...@gmail.com wrote:
 Thanks very much for the link. I'm enjoying the paper. When I've
 addressed my immediate needs (with stringtemplate), I hope to return
 to it again in more depth. I have this notion, that an alternate
 reader for Clojure in the style of Scribble combined with core
 concepts of stringtemplate could make a convenient and yet lispy
 templating system for producing non-lisp code and other textual
 output.

At the time I worked on this, I've looked at a number of systems, and
none were close to being complete in what they were doing.  IIRC, I
got the general impression that they were all dealing with HTML
output, and things started to go downhill when people tried to
generalize that.  I definitely remember Cheetah being one of these,
where there were some really odd corners around indentation -- an
issue that came up when people tried to use it as a code generator.

OTOH, I made the scribble thing flexible enough that I could even
tackle the odd rules of indenting CPP #-lines.  You can see an example
of that in our ffi code:

  http://git.racket-lang.org/plt/blob/HEAD:/src/foreign/foreign.c

and the source file that generates that:

  http://git.racket-lang.org/plt/blob/HEAD:/src/foreign/foreign.rktc

Look for (ffi-lib filename no-error?) in both files, and see how the
output gets indented.  See also some of that documented in the text
languague description at:

  http://docs.racket-lang.org/scribble/preprocessor.html

(but in retrospect I dislike the overloading of lists as markers for
an indentation group, and will change that in the very near future to
`block'.)

I think that I didn't look at StringTemplate at the time -- maybe it
wasn't too known then.  In any case, looking at some examples (eg,
http://www.antlr.org/wiki/display/ST/Five+minute+Introduction), I
don't see anything radically different from the other tools in the
same category...  (The main difference is a little too much
buzzword-itis...)  So it looks like it's very similar to do these
things with plain scribble.  For example, if I translate the
homepage.st example from that page to Racket, I'd do this (the first
line specifies using the @-reader, and the `require' line gives me the
`output' function which, roughly speaking, displays its argument(s)):

  #lang at-exp racket
  (require scribble/text)
  (define (hello-world title name friends)
@list{
  html
  head
 title@|title|/title
  /head
  body
 pHello again, @name !/p
 pGreetings to your friends @(add-between friends , )/
p
 /body
  /html
})
  (output (hello-world Welcome To NotStringTemplate
   World
   '(Ter Kunle Micheal Marq)))

Note that the @|...| thing is needed when the racket expression
(`title' in the above) needs to be separated from the text around it.
The thing that makes this attractive to me is that there is no need to
talk about attributes, properties, etc -- it's *just* code.  If
you have some objects then things work fine too, of course, but you
can mix things in way you want.  For example, I can easily change the
above with dropping the `title' argument and instead define a single
global value for it -- so the choice of using an argument or a fixed
global is something that is up to the code.

But there is an important point that they're talking about there --
the model-view separation -- which (I think) is coming from the
HTML-generating heritage of these systems, where you want some people
to do the HTML design, and other people to do the hacking.  (Seems
that logic is the canonical term for programming in these
contexts...)  Racket has an `include' thing that can basically read
some source code file into any context, and the `scribble/text' module
uses that and provides an `include/text' which is the same thing, only
using the @-reader to read the file.  Think about `include' as a kind
of a macro that `read's some random file to produce its output, and
`include/text' does the same with the extended readtable.  So to get
this separation, take the textual contents of the `hello-world'
function and dump it in a homepage.st file (unindented, of course),
then change the above code to be:

  #lang at-exp racket
  (require scribble/text)
  (define (hello-world title name friends)
(include/text homepage.st))
  (output ...same as above...)

You can see a number of similar examples in the templates chapter of
our web-server manual, which uses the same thing.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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


Emacs `align' function customization for Clojure

2011-04-01 Thread Christian Schuhegger
I am replying to this thread from January this year:
https://groups.google.com/group/clojure/browse_frm/thread/47c388127e0da3ef

I am not certain if my solution fulfills the aesthetic requirements of
clojure hackers, but I use one of my old C/C++ marcros for aligning
equal signs to align at commas (see below). As commas in clojure are
whitespace you can put them in front of the clauses you want to be
aligned, e.g. in let binding forms. You select the region you want the
alignment to happen and press C-= and the full block gets nicely
aligned.

I hope this may be useful for other people, too.

-- snip start --
(defun align-equals (start end)
  make the first assignment operator on each line line up vertically
 (interactive *r)
 (save-excursion
   (let ((indent 0))
 (narrow-to-region start end)
 (beginning-of-buffer)
 (while (not (eobp))
   (if (find-assignment)
   (progn
 (exchange-point-and-mark)
 (setq indent (max indent (current-column)))
 (delete-horizontal-space)
 (insert  )))
   (forward-line 1))
 (beginning-of-buffer)
 (while (not (eobp))
   (if (find-assignment)
   (indent-to-column (1+ (- indent  (- (mark) (point))
   (forward-line 1)))
   (widen)))

(defun find-assignment ()
  (if (re-search-forward
 [^=!]=\\|\\+=\\|-=\\|\\*=\\|/=\\|=\\||=\\|\\^=\\|=\\|=\
\|:=\\|:\\|,
 (save-excursion (end-of-line) (point)) t)
  (progn
(goto-char (match-beginning 0))
(if (looking-at .==)
nil
  (if (looking-at \\+=\\|-=\\|\\*=\\|/=\\|=\\||=\\|\\^=\\|=\\|=\
\|:=\\|:\\|,)
  (set-mark (match-end 0))
(forward-char 1)
(set-mark (1+ (point
  (delete-horizontal-space)
  t))
nil))

(global-set-key [(control =)] 'align-equals)

-- snip end --

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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