Re: errors?

2009-03-13 Thread Mark Engelberg

But how do you get rid of the (NO_SOURCE_FILE:0) messages for every
single error?  I'd really like to know the line number of the function
that threw the error.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Question about IntelliJ Plugin

2009-03-13 Thread Mark Engelberg

If I split my code across files, how do I make it so that the REPL can
"see" all the code?
For example, if I have a main.clj and a tests.clj, when I run the REPL
from one of the two files, it only sees the definitions from that
file, not everything in the project.

What's the right way to do this?  Thanks.

--~--~-~--~~~---~--~~
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: VimClojure 2

2009-03-13 Thread Mark Feeney

One of my problems, I just discovered, was that I was sometimes
testing with a namespace continaing a hyphen in a file also containing
a hyphen.  e.g.

my-foo.clj

(ns my-foo)
(+1 1)

Clojure, of course, wants the file to be named my_foo.clj
(underscore), and said as much in the error messages, but I failed to
notice this little detail!

Anyway, user error, as you predicted above :)  Things are working much
better now.


On Mar 13, 11:18 am, Meikel Brandmeyer  wrote:
> Hi,
>
> Am 13.03.2009 um 15:02 schrieb Mark Feeney:
>
>
>
> > So you could try \rf, but for me this still doesn't quite work for
> > me.  If I have just one file:
>
> > foo.clj
> > 
> > (ns foo)
> > (+ 1 1)
>
> > I can't \ef it.  I get the same "line 23" error you get.  If I \rf it
> > I get:
>
> > (clojure.core/load "/foo")
> > # > foo__init.class or foo.clj on classpath:  (REPL:0)>
>
> > I've tried making sure the path to foo.clj is on my classpath, but
> > that doesn't appear to work either.  Not really sure what's up.
>
> Make sure, that the file is in the Classpath of the *server* not
> the client. The client is only a proxy transferring in- and output
> between the shell and the server. So the important part for
> Java things like the Classpath is the server.
>
> > Work-arounds I've used:
>
> > 1) don't set a namespace (just work in the user ns implicitly)
> > 2) temporarily change your ns macro to put you in the user ns.  i.e.
> > in my example above, changing (ns foo) to (ns user) works, since the
> > user ns always exists.
> > 3) Bring up the REPL (\sr) and execute your ns macro there before
> > \ef'ing or \et'ing your file.
>
> These all work, because you circumvent the classpath.
>
> > Tons of promise with this new version of VimClojure.  Just some bugs
> > (or user education?) to get through first.
>
> I boldly claim, that that's user education. 95% of problems
> stem from misuse by the user. The above case of \ef vs. \rf
> is how Clojure works. \rf goes the rigth way through require
> setting up the namespace correctly. \ef is just a convenience.
> But that's not a reason for being lazy. If you don't setup the
> environment correctly, things won't work.
>
> But VimClojure is not perfect. I will try make it more robust
> and to point out such things in the docs.
>
> Sincerely
> Meikel
>
>  smime.p7s
> 5KViewDownload
--~--~-~--~~~---~--~~
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: errors?

2009-03-13 Thread Raoul Duke

thanks, all, for the notes! i will try those out.

sincerely.

--~--~-~--~~~---~--~~
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: What is Clojure NOT good for?

2009-03-13 Thread e
On Fri, Mar 13, 2009 at 11:31 AM, opus111  wrote:

>
> Here's my experience...
>
> I was primarily interested in Clojure as a scripting language.  I
> wanted a nice layer to control code written in Java.  I had used
> Groovy successfully, but missed macros and an extensible syntax.  I
> used to work at Lisp Machines, so I jumped on a LISP that compiled to
> the JVM.
>
> Unfortunately, while I love Clojure for algorithms and stretching my
> brain, it is not very good for scripting.  This is because it is
> really too different from Java.  Clojure programming requires that you
> do things the "Clojure way".  Therefore, a Clojure wrapper does not
> map very well to a set of Java objects; calling Clojure from Java is
> clunky; and debugging lazy code that invokes Java is difficult.
> Clojure is best when everything is written in Clojure.
>
> Some day Clojure programs will be able to take advantage of parallel
> hardware.  Then there will be a performance reason to write core
> algorithms in Clojure.  Unfortunately Java is still significantly
> faster this year.
>
> So for me, Clojure is beautiful, coding is a joy, and Clojure is the
> future... but I can not use it for work yet.
>
> Peter
>

not knowing much about it, what role could ANT play to satisfy your
scripting needs.  it seems like it could be a good way to glue together bits
of code ... but maybe that way too high level ... like on the level of batch
files in dos.

--~--~-~--~~~---~--~~
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: errors?

2009-03-13 Thread Stephen C. Gilardi


On Mar 13, 2009, at 7:50 PM, Raoul Duke wrote:


i'm up to date with the clojure jar. the error messages i get seem
awfully terse and not particularly helpful in learning what i'm doing
wrong. for example, with the code below, when i try (bs 0 (vector 1 2
3)) i get "java.lang.ClassCastException:
clojure.lang.LazilyPersistentVector (NO_SOURCE_FILE:0)". swapping the
order of args in the 2nd 'nth' call fixes it.  is there no way to get
Clojure to help me out a little with such things?


So just to be clear, you found the error in your code and now you'd  
like to know if Clojure could have pointed you to it more quickly,  
right?


First, using Java 1.6 would help some. It gives both the source and  
destination types for a class cast error:


java.lang.ClassCastException: clojure.lang.LazilyPersistentVector  
cannot be cast to java.lang.Number (NO_SOURCE_FILE:0)


Clojure lets you see the stack trace associated with an exception at  
the repl. When the repl catches an exception, it binds it to the var  
*e. You can see its stack trace with (.printStackTrace *e). That stack  
trace includes a lot of Java-level stuff that can make it more  
difficult to parse visually than it has to be.


There are two contribs that can help make finding the problem easier.

Here's a session using clojure.contrib.stacktrace and  
clojure.contrib.repl_ln to point to the line of the error:



% java -cp clojure.jar:../clojure-contrib/clojure-contrib.jar  
clojure.contrib.repl_ln

Clojure
1:1 user=> (defmulti bs (fn [find data] (count data)))
#'user/bs
1:2 user=> (defmethod bs 0 [find data] -1)
#
1:3 user=> (defmethod bs 1 [find data]
 (if
 (= (nth data 0) find)
   0
   -1))
#
1:8 user=> (defmethod bs :default [find data]
 (let [lo 0
hi (count data)
mid (/ (+ lo hi) 2)
testv (nth mid data)]
   -42))
#
1:14 user=> (bs 0 (vector 1 2 3))
java.lang.ClassCastException: clojure.lang.LazilyPersistentVector  
cannot be cast to java.lang.Number (repl-1:14)

1:15 user=> (use 'clojure.contrib.stacktrace)
nil
1:16 user=> (e)
java.lang.ClassCastException: clojure.lang.LazilyPersistentVector  
cannot be cast to java.lang.Number

 at clojure.core/nth (core.clj:892)
user/fn (:12)
clojure.lang.MultiFn.invoke (MultiFn.java:152)
user/eval (:14)
clojure.lang.Compiler.eval (Compiler.java:4522)
clojure.core/eval (core.clj:1738)
clojure.main$repl__5665$read_eval_print__5677.invoke (main.clj:176)
clojure.main$repl__5665.doInvoke (main.clj:193)
nil
1:17 user=>


clojure.contrib.repl_ln provides (by default) the line number as part  
of the prompt. clojure.contrib.stacktrace provides the "e" convenience  
function that prints a more readable version of the stack trace that's  
part of *e.


Looking at the output of (e), you can see that your call to "nth" is  
the problem and that you're calling it on the 12th input line from  
this repl which (counting down from line 8) is the line that begins  
"testv".


From there, (doc nth) and looking at how its argument list(s) match  
up with your code leads to the fix.


--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: version of -> short-circuiting on nil

2009-03-13 Thread Laurent PETIT
Issue 34 ( http://code.google.com/p/clojure-contrib/issues/detail?id=34 )
created with patch (both -?> and .?.  defined in clojure.contrib.core,  with
unit tests in clojure.contrib.core.tests

-- 
Laurent

3/13 Laurent PETIT 

> OK, so I think the consensus is on the names .?. and -?> . No problem with
> me.
>
> I'm willing to write the patch, but which patch ? I mean, do these macros
> deserve their own file (maybe not) ?
> Maybe adding them to the existing clojure.contrib.macros ?
> Or else, I was thinking about creating a new file named
> clojure.contrib.core since these are slight variants of existing core
> functions ?
>
> 2009/3/13 Stephen C. Gilardi 
>
>
>> On Mar 12, 2009, at 9:45 PM, Mark Volkmann wrote:
>>
>>>
>>> On Thu, Mar 12, 2009 at 5:04 PM, Stephen C. Gilardi 
>>> wrote:
>>>

 I like these:

   .?.
   -?>

>>>
>>  Given a choice between the two, I'd choose -?>
>>>
>>
>> The proposal was for naming "nil-safe" versions of the existing .. and ->
>> functions.
>>
>> (-> nil (. toString)) ==> NullPointerException
>>
>> (-?> nil (. toString)) ==> nil
>>
>>
>> (.. nil (toString)) ==> NullPointerException
>>
>> (.?. nil (toString)) ==> nil
>>
>>
>> Note: these are just simple examples. The point isn't the one argument,
>> literal nil case, but the case where many operations are "chained" or
>> "threaded" and at each point the propagated result may be nil.
>>
>> --Steve
>>
>>
>
>
>

--~--~-~--~~~---~--~~
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: errors?

2009-03-13 Thread James Reeves

On Mar 13, 11:50 pm, Raoul Duke  wrote:
> i'm up to date with the clojure jar. the error messages i get seem
> awfully terse and not particularly helpful in learning what i'm doing
> wrong. for example, with the code below, when i try (bs 0 (vector 1 2
> 3)) i get "java.lang.ClassCastException:
> clojure.lang.LazilyPersistentVector (NO_SOURCE_FILE:0)". swapping the
> order of args in the 2nd 'nth' call fixes it.  is there no way to get
> Clojure to help me out a little with such things?

In the REPL, *e gives you the last thrown exception. You can then call
printStackTrace on it:

(.printStackTrace *e)

There's also clojure.contrib.stacktrace in Clojure-Contrib, and Mark's
clj-backtrace (http://github.com/mmcgrana/clj-backtrace/tree/master),
which give you more readable stacktraces than the standard Java
method.

- James
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



errors?

2009-03-13 Thread Raoul Duke

hi,

i'm up to date with the clojure jar. the error messages i get seem
awfully terse and not particularly helpful in learning what i'm doing
wrong. for example, with the code below, when i try (bs 0 (vector 1 2
3)) i get "java.lang.ClassCastException:
clojure.lang.LazilyPersistentVector (NO_SOURCE_FILE:0)". swapping the
order of args in the 2nd 'nth' call fixes it.  is there no way to get
Clojure to help me out a little with such things?

thanks for any clues :)

(defmulti bs (fn [find data] (count data)))
(defmethod bs 0 [find data] -1)
(defmethod bs 1 [find data]
  (if
  (= (nth data 0) find)
0
-1))
(defmethod bs :default [find data]
  (let [lo 0
hi (count data)
mid (/ (+ lo hi) 2)
testv (nth mid data)]
-42))

--~--~-~--~~~---~--~~
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: error messages with clojure-mode.el?

2009-03-13 Thread Raoul Duke

i just tried using (load-file "foo.clj") to see if that loaded file
line numbers, but the errors still say no source found zero sorry
charlie. :-(

On Fri, Mar 13, 2009 at 4:41 PM, Raoul Duke  wrote:
> hi,
>
> when i have a repl going and get errors, it says NO_SOURCE_FILE:0 so
> it is hard for newbie-me to figure out what i'm doing wrong in my
> syntax. does slime do something more helpful here? am i mis-diagnosing
> the issue? any other helpful thoughts?
>
> thanks!
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



error messages with clojure-mode.el?

2009-03-13 Thread Raoul Duke

hi,

when i have a repl going and get errors, it says NO_SOURCE_FILE:0 so
it is hard for newbie-me to figure out what i'm doing wrong in my
syntax. does slime do something more helpful here? am i mis-diagnosing
the issue? any other helpful thoughts?

thanks!

--~--~-~--~~~---~--~~
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: mocking in clojure

2009-03-13 Thread Stephen C. Gilardi


On Mar 13, 2009, at 4:10 PM, Stuart Sierra wrote:


Hi Allen,
Sorry I haven't kept up with this. I think, though, that it's best to
have it as a standalone library in clojure-contrib, so that people can
use it with other testing frameworks if they want to.
-Stuart


Allen,

I see you have a contributor agreement on file. I'll be happy to help  
check this in if you like. Please open an issue at:


http://code.google.com/p/clojure-contrib/issues/list

and attach a patch to it that creates the new lib.

Thanks,

--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: mocking in clojure

2009-03-13 Thread Stuart Sierra

Hi Allen,
Sorry I haven't kept up with this. I think, though, that it's best to
have it as a standalone library in clojure-contrib, so that people can
use it with other testing frameworks if they want to.
-Stuart

On Mar 13, 3:20 pm, Allen Rohner  wrote:
> > > Any other options out there?
>
> I posted a patch for test-is a while ago that never made it in, and I
> don't know 
> why.http://groups.google.com/group/clojure/browse_frm/thread/883d4833f869...
>
> The patch handles creating stub functions, you can specify the return
> value of functions and assert that the function is called the correct
> number of times.
>
> Allen
--~--~-~--~~~---~--~~
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: mocking in clojure

2009-03-13 Thread Allen Rohner


>
> > Any other options out there?

I posted a patch for test-is a while ago that never made it in, and I
don't know why.
http://groups.google.com/group/clojure/browse_frm/thread/883d4833f869f764/47a45325c8f29599?lnk=gst&q=test-is+expect+patch#47a45325c8f29599

The patch handles creating stub functions, you can specify the return
value of functions and assert that the function is called the correct
number of times.

Allen


--~--~-~--~~~---~--~~
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: mocking in clojure

2009-03-13 Thread Matt Clark

test-expect actually only depends on test-is for its own tests, and
I'm planning on breaking the tests out into their own file.  I thought
it was an interesting idea having the tests and code in the same file,
but in practice it ended up being less attractive than anticipated.

- Matt

On Mar 13, 7:39 am, Korny Sietsma  wrote:
> Hi folks - are there any frameworks out there for mocking?
> Stubbing functions is pretty straightforward (and I see that fact comes with
> a stubbing function built in), but I'd really like something that can do
> mocking and mock expectations - something similar to stub, but with checking
> that the stubbed calls actually happen an expected number of times.
>
> A bit of googling 
> findshttp://github.com/mclark/test-expect/tree/masterwhichlooks nice,
> though I'm not sure about depending on test-is (I was
> planning to use 'fact'),
> and a blank project athttp://github.com/amitrathore/conjure/tree/master
> and not much else.
>
> Any other options out there?
>
> - Korny
> --
> Kornelis Sietsma  korny at my surname dot com
> kornys on gmail, twitter, facebook, etc.
> "Every jumbled pile of person has a thinking part
> that wonders what the part that isn't thinking
> isn't thinking of"
--~--~-~--~~~---~--~~
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: VimClojure 2

2009-03-13 Thread Meikel Brandmeyer

Hi,

Am 13.03.2009 um 16:13 schrieb Mark Volkmann:


The version of the Vim that my Mac uses when a launch it from a
Terminal window isn't ancient. It's 7.2.22. It seems likely that the
issue is related to configuration instead of the version of Vim being
used. What happens if you try to use VimClojure features from a Vim
session that is started from a Terminal window?


My OS X own vim is also 7.2.22 and it works perfectly from the Terminal.
I can't find a difference in your configuration compared to mine.

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


resultset-seq - keywords corresponding to column names containing "_"

2009-03-13 Thread pc

Hi,

Would it be better if resultset-seq mapped column names like ITEM_ID
to ":item-id" rather than ":item_id"?

I am using a variation of Itay Maman's Application Context Pattern
which, among other things, keeps state in a map wrapped in a closure.
I have a lot of keywords being passed around. that access the map.

For keys related to resultsets I am forced to used keys like :item_id
rather than ":item-id" which, frankly, makes it hard to remember what
I have to type. In particular, the functions that use data in the
state map should not be concerned about where it originally came from.
So some sort of naming convention base on "_" for data that came from
a database and "-" for other stuff, would never work.

I realize that this is probably way too late. And maybe the current
way is better anyway.

pc


--~--~-~--~~~---~--~~
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: What is Clojure NOT good for?

2009-03-13 Thread opus111

Here's my experience...

I was primarily interested in Clojure as a scripting language.  I
wanted a nice layer to control code written in Java.  I had used
Groovy successfully, but missed macros and an extensible syntax.  I
used to work at Lisp Machines, so I jumped on a LISP that compiled to
the JVM.

Unfortunately, while I love Clojure for algorithms and stretching my
brain, it is not very good for scripting.  This is because it is
really too different from Java.  Clojure programming requires that you
do things the "Clojure way".  Therefore, a Clojure wrapper does not
map very well to a set of Java objects; calling Clojure from Java is
clunky; and debugging lazy code that invokes Java is difficult.
Clojure is best when everything is written in Clojure.

Some day Clojure programs will be able to take advantage of parallel
hardware.  Then there will be a performance reason to write core
algorithms in Clojure.  Unfortunately Java is still significantly
faster this year.

So for me, Clojure is beautiful, coding is a joy, and Clojure is the
future... but I can not use it for work yet.

Peter

--~--~-~--~~~---~--~~
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: VimClojure 2

2009-03-13 Thread Meikel Brandmeyer

Hi,

Am 13.03.2009 um 15:02 schrieb Mark Feeney:


So you could try \rf, but for me this still doesn't quite work for
me.  If I have just one file:

foo.clj

(ns foo)
(+ 1 1)

I can't \ef it.  I get the same "line 23" error you get.  If I \rf it
I get:

(clojure.core/load "/foo")
#

I've tried making sure the path to foo.clj is on my classpath, but
that doesn't appear to work either.  Not really sure what's up.


Make sure, that the file is in the Classpath of the *server* not
the client. The client is only a proxy transferring in- and output
between the shell and the server. So the important part for
Java things like the Classpath is the server.


Work-arounds I've used:

1) don't set a namespace (just work in the user ns implicitly)
2) temporarily change your ns macro to put you in the user ns.  i.e.
in my example above, changing (ns foo) to (ns user) works, since the
user ns always exists.
3) Bring up the REPL (\sr) and execute your ns macro there before
\ef'ing or \et'ing your file.


These all work, because you circumvent the classpath.


Tons of promise with this new version of VimClojure.  Just some bugs
(or user education?) to get through first.


I boldly claim, that that's user education. 95% of problems
stem from misuse by the user. The above case of \ef vs. \rf
is how Clojure works. \rf goes the rigth way through require
setting up the namespace correctly. \ef is just a convenience.
But that's not a reason for being lazy. If you don't setup the
environment correctly, things won't work.

But VimClojure is not perfect. I will try make it more robust
and to point out such things in the docs.

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: VimClojure 2

2009-03-13 Thread Mark Volkmann

On Fri, Mar 13, 2009 at 8:45 AM, Meikel Brandmeyer  wrote:
> Hi,
>
> Am 13.03.2009 um 13:45 schrieb Mark Volkmann:
>
>>> Hi Mark, I'm also running on OSX 10.5. I couldn't get it working with
>>> the vim that comes with leopard - vim version 7.0.x
>
>> So this casts a new light on the problem. It appears to be specific to
>> the vim that is a standard part of Mac OS X.
>
> Ah. Ok. I use MacVim.app and it works fine. I would recommend
> it without hesitating.
>
> Please note: I cannot support stone age vim versions. I simply
> don't have the time to install and test all those versions. I only
> guarantee a working setup for reasonable recent versions.
>
> If I would support such old version (once someone complained
> with a Vim 6.something), I would have to re-implement 90% of
> the now available library functions. That's certainly not a Good
> Thing.

The version of the Vim that my Mac uses when a launch it from a
Terminal window isn't ancient. It's 7.2.22. It seems likely that the
issue is related to configuration instead of the version of Vim being
used. What happens if you try to use VimClojure features from a Vim
session that is started from a Terminal window?

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~-~--~~~---~--~~
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: VimClojure 2

2009-03-13 Thread Albert Cardona

Hi Meikel,

Thank you for the prompt response.

> I will point this out more clearly in the documentation.



And future users will be greateful for that!

VimClojure is looking great Meikel.

Albert

-- 
Albert Cardona
http://albert.rierol.net


--~--~-~--~~~---~--~~
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: Clojure code: reserve lists (parens) for forms? (canonical ns)

2009-03-13 Thread Stuart Sierra

On Mar 13, 10:05 am, "Stephen C. Gilardi"  wrote:
> Should we consider changing the canonical form for ns to use vectors  
> for all of its sequential sub-forms?

One thing to consider: "ns" is a bit special,
because :import/:use/:require/:load mimic the syntax and behavior of
the functions import/use/require/load.  So (:use ...) can be read,
casually, as a "call".

The "import" function also uses lists instead of vectors.

Just muddying the waters a bit. :)  I agree that vectors are, strictly
speaking, the more consistent choice.  But lists are not a bad
choice.  One could also ask for key-value arguments:

(ns com.example.foo
  :use [clojure.contrib.duck-streams]
  :import [[java.util Map ArrayList]])

But I don't think there's much to gain by changing it.

-Stuart Sierra
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Clojure code: reserve lists (parens) for forms? (canonical ns)

2009-03-13 Thread Stephen C. Gilardi
I've seen discussions over time suggesting that Clojure's readability  
is enhanced by having more bracketing characters in play that just  
parentheses. I agree with that.


I recall Chouser (corrections welcome) noting that in Clojure code,  
parentheses are used primarily for "forms" (applications of special  
forms, macros and functions) and perhaps a good goal would be to avoid  
using them elsewhere. Doing so would more strongly enforce the close  
association between parentheses and "calls".


I experimented with this in an "ns" form and found that because of the  
coolness of the seq abstraction, it appears that all uses of lists in  
an "ns" form can be replaced by vectors and still work the same.


Here's an example:

Currently the canonical form for ns is a mixture of lists and vectors  
within its clauses:


(ns clojure.contrib.miglayout.internal
  (:import (java.awt Component))
  (:use (clojure.contrib
 [except :only (throwf)]
 [fcase :only (fcase)])))

If we reserved parentheses only for the ns form itself, this could  
become:


(ns clojure.contrib.miglayout.internal
  [:import [java.awt Component]]
  [:use [clojure.contrib
 [except :only [throwf]]
 [fcase :only [fcase)

The ns form is an interesting case because Rich has expressed a vision  
that it will be parsed and used not only by Clojure itself, but also  
by tools/IDEs to determine what a source file contains and what it  
depends on. As such, its "acceptable syntax" is governed (even more  
than elsewhere in Clojure code) not primarily by "what works in  
Clojure", but rather by "what is its canonical, documented syntax".


Should we consider changing the canonical form for ns to use vectors  
for all of its sequential sub-forms?


Benefits:

- canonical form would be easier to describe
- less to remember and get right than with the current mixed 
syntax
- makes it clear that (:use ...), for example, is not a "call"
- supports the "parentheses imply form application" notion

Downside:

	- Nested uses of square brackets are arguably less readable than a  
mixture.

- matching brackets by eye is easier when there's a variety

--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: VimClojure 2

2009-03-13 Thread Mark Feeney

I've been struggling with the same issues (on Windows, not that it
appears to matter).

The "line 23" in the error means the 23rd line of the function
vimclojure#ExecuteNailWithInput(nail, input, ...) in vimfiles/autoload/
vimclojure.vim.  It's unrelated to the code you're trying to execute.

I dug into this a bit and discussed with Meikel offline (next time
I'll just post to the list!).  There is a feature/bug with the way
VimClojure deals with files that use namespaces.  It seems a ns must
exist before VimClojure can evaluate code in that ns.  There's a
facility in place to make that happen (\rf), but I think there are
still some issues (or maybe just user error on my part):

>From Meikel in email:


To evaluate the functions in the right namespace we have to
change there, obviously. In foo.clj there is no namespace so
the forms are evaluated in the user namespace. This one is
always there as the Repl system used by VimClojure ensures
that.

In foo2.clj there is a namespace defined, but it is not created,
yet. That is a problem. Consider the following setup:

foo2.clj:
(in-ns 'test)

foo3.clj:
(ns test
 (:use some-other-stuff)
 (:load "foo2"))

What should VimClojure do when \ef'ing foo2.clj? Just creating
the namespace doesn't work, because then some-other-stuff
is missing. Also there were some special cases with :refer-clojure
where namespace must or must not exist before. I have to
check on that one. Maybe it's already obsolete.

However: Just creating the namespace doesn't work. The first
time loading the namespace use \rf (RequireFile). This uses
require to load the namespace and is setting up everything in
the right way. Afterwards you can use \ef to reload single files.

Maybe I should add this to the docs.


So you could try \rf, but for me this still doesn't quite work for
me.  If I have just one file:

foo.clj

(ns foo)
(+ 1 1)

I can't \ef it.  I get the same "line 23" error you get.  If I \rf it
I get:

(clojure.core/load "/foo")
#

I've tried making sure the path to foo.clj is on my classpath, but
that doesn't appear to work either.  Not really sure what's up.

Work-arounds I've used:

1) don't set a namespace (just work in the user ns implicitly)
2) temporarily change your ns macro to put you in the user ns.  i.e.
in my example above, changing (ns foo) to (ns user) works, since the
user ns always exists.
3) Bring up the REPL (\sr) and execute your ns macro there before
\ef'ing or \et'ing your file.

Tons of promise with this new version of VimClojure.  Just some bugs
(or user education?) to get through first.


Mark.



On Mar 13, 8:42 am, Albert Cardona  wrote:
> Since this is a thread on VimClojure. First of all to say I am looking
> forward to vimclojure working perfectly. Here are some problems I don't
> understand:
>
> If I open a .clj file without the ng server running, it complains loudly
> and does not switch on syntax highlighting for clojure. Why no syntax on?
>
> So I launch the ng.
>
> The ng server is running happily, and on launching it reported:
>
>    NGServer started on 127.0.0.1, port 2113.
>
> Then I acess a .clj file. It 'works' fine, but I can't execute anything.
> Here's a snipped of a file test/patch.clj, opened from vim as "vim
> test/patch.clj", plus the overlayed error mesage triggered on pushing
> \ef to execute the whole file:
>
> -8<
> (ns test.patch
>   (:import (ij.gui OvalRoi Roi ShapeRoi)
>            (ij IJ ImagePlus)
>            (ij.process ByteProcessor)
>            (ini.trakem2.display Display Patch Selection)
>            (mpicbg.trakem2.transform MovingLeastSquaresTransform)))
>
> (defn punch-alpha-hole
>   "Create an alpha hole right in the middle of an image."
>   [patch]
>   (let [ip (.getImageProcessor patch)
> Error detected while processing function
> vimclojure#EvalFile..vimclojure#Execute
> NailWithInput:
> line   23:
> E605: Exception not caught: Couldn't execute Nail! ng
> de.kotka.vimclojure.nails.
> Repl '-r' '-n' 'test.patch' '-f' 'test/patch.clj'  8<--
>
> The error points to line 23, which is the first let binding here:
>
> 8<--
> (defn punch-alpha-hole
>   "Create an alpha hole right in the middle of an image."
>   [patch]
>   (let [ip (.getImageProcessor patch)
>       
> 8<--
>
> The above (complete) function runs just fine, if I run it by means other
> than vimclojure.
>
> What is vimclojure expecting? The classpath of the ng is correct and
> contains all necessary jar files. I cannot see what is wrong.
>
> I would appreciate help in understanding what the error means. Thanks.
>
> Albert
>
> --
> Albert Cardonahttp://albert.rierol.net
--~--~-~--~~~---~--~~
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 thi

Re: Some help for tool builders...

2009-03-13 Thread Christophe Grand

pmf a écrit :
> On Mar 13, 1:19 pm, Eric Thorsen  wrote:
>   
>> I come across some functions in clojure/core that are really useful in
>> tool building but often are private.
>> Is it possible to make these public?
>> 
>
> I'm using the following hack to access private functions (for example
> generate-class is private):
>
> ;; define another var pointing to the function in question
> (def wrapper #'generate-class)
>
> ;; use the new var
> (wrapper whatever args it needs)
>   

Or you can simply yell at the var until it yields its value: 
@#'clojure.core/generate-class

It has the value that line noise makes easy to spot places where you 
depend on a var that is not part of the public interface.

Christophe

-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.blogspot.com/ (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
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: VimClojure 2

2009-03-13 Thread Meikel Brandmeyer

Hi,

Am 13.03.2009 um 13:45 schrieb Mark Volkmann:


Hi Mark, I'm also running on OSX 10.5. I couldn't get it working with
the vim that comes with leopard - vim version 7.0.x



So this casts a new light on the problem. It appears to be specific to
the vim that is a standard part of Mac OS X.


Ah. Ok. I use MacVim.app and it works fine. I would recommend
it without hesitating.

Please note: I cannot support stone age vim versions. I simply
don't have the time to install and test all those versions. I only
guarantee a working setup for reasonable recent versions.

If I would support such old version (once someone complained
with a Vim 6.something), I would have to re-implement 90% of
the now available library functions. That's certainly not a Good
Thing.

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: VimClojure 2

2009-03-13 Thread Meikel Brandmeyer

Hi Albert,

Am 13.03.2009 um 13:42 schrieb Albert Cardona:

If I open a .clj file without the ng server running, it complains  
loudly
and does not switch on syntax highlighting for clojure. Why no  
syntax on?


This happens for me if I open a file via the NerdTree plugin.
I'm not sure why this is happening. A simple :e will fix it. But
I would file this currently under "don't do it", ie. if you set
clj_want_gorilla, make sure the server is running. I will try
to make this more robust, so when no server is running the
fallback is the static behaviour as without clj_want_gorilla.
(Or start a server, depending on how easily this can be
done from inside vim)

Then I acess a .clj file. It 'works' fine, but I can't execute  
anything.

Here's a snipped of a file test/patch.clj, opened from vim as "vim
test/patch.clj", plus the overlayed error mesage triggered on pushing
\ef to execute the whole file:


This is no problem of your script nor is it a problem of vimclojure.
This is a misuse of \ef although a very subtle one. I will add a
note to the documentation. Let me explain:


-8<
(ns test.patch
 (:import (ij.gui OvalRoi Roi ShapeRoi)
  (ij IJ ImagePlus)
  (ij.process ByteProcessor)
  (ini.trakem2.display Display Patch Selection)
  (mpicbg.trakem2.transform MovingLeastSquaresTransform)))



8<--


When evaluating the file, vimclojure first tries to change the
namespace to test.patch. This namespace is not loaded and
hence you get an error. (When you execute the ng command
from the error message manually, will get a corresponding
exception from the clojure side).

But we cannot simply create the namespace if it doesn't exist.
Consider a second file, which is loaded for the namespace
via the :load directive in the ns form. In this file there is only
a in-ns at the top. Imagine we simply created the namespace
and evaled the code. Then all the above imports were missing.

So the Right Way is to use \rf (RequireFile) the first time to
set up the namespace correctly (it is loaded via a require
call). Then you may use \ef to reload single files afterwards.

It is important to understand that \el (EvalLine), \eb (EvalBlock),
\ep (EvalParagraph) and \ef (EvalFile) do not work on
the structure of the code like \rf, \et or \me do. I added them
because they were requested, but you have to take care that
you pay attention to what you are doing. Although I admit
that this case is a little bit tricky.

I will point this out more clearly in the documentation.

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: VimClojure 2

2009-03-13 Thread Yasuto TAKENAKA

Do you try to run the command, ./ng
de.kotka.vimclojure.nails.NamespaceOfFile ?

The following is the result when I tried to run this after starting a
ngserver:

> cd your-vimcljure-directory
>./ng  de.kotka.vimclojure.nails.NamespaceOfFile
java.lang.ClassNotFoundException:
de.kotka.vimclojure.nails.NamespaceOfFile
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:
301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:
320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.martiansoftware.nailgun.NGSession.run(Unknown Source)

I also have  the same problem you confronted.  As I am a beginner java
and clojure,
I mistake setting up  CLASSPATH value.

On 3月13日, 午後8:55, Mark Volkmann  wrote:
> On Thu, Mar 12, 2009 at 6:05 PM, Kyle Schaffrick  wrote:
>
> >> Here are the errors I'm getting.
>
> >> Error detected while processing function
> >> vimclojure#ExecuteNailWithInput:
> >> line   23:
> >> E605: Exception not caught: Couldn't execute Nail! ng
> >> de.kotka.vimclojure.nails.N
> >> amespaceOfFile  >> v920635/0
> >> Error detected while processing /Users/Mark/.vim/ftplugin/clojure.vim:
> >> line  131:
> >> E171: Missing :endif
> >> Error detected while processing function 9_LoadFTPlugin:
> >> line   17:
> >> E170: Missing :endfor
>
> > I got this exact error also at first. It turned out there was an
> > extraneous file in my .vim from an older version of Gorilla, pretty sure
> > it was ~/.vim/after/ftplugin/clojure.vim.
>
> > Deleting this file and restarting Vim fixed it for me.
>
> I deleted all the files related to VimClojure and Gorilla from under
> my .vim directory and then copied the VimClojure files there again,
> but I'm still getting the same error.
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
--~--~-~--~~~---~--~~
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: "08" and "09" are invalid numbers, but "01" through "07" are fine?

2009-03-13 Thread David Sletten


On Mar 13, 2009, at 3:07 AM, Michael Wood wrote:
>
> This is pretty standard behaviour.
>
> On the other hand, it's not universal.
>
> sbcl:
>
> * 07
>
> 7
> * 08
>
> 8
>

Common Lisp uses a separate syntax for binary/octal/hex literals. Legal:
#b1011, #o377, #xDEADBEEF, #36rZZZ (Base 36 anyone?)
Illegal:
#b2, #o8, #xQUICKSAND

(Of course, #36rCLOJURE => 27432414842 :-) )

Aloha,
David Sletten



--~--~-~--~~~---~--~~
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: "08" and "09" are invalid numbers, but "01" through "07" are fine?

2009-03-13 Thread Michael Wood

On Fri, Mar 13, 2009 at 2:14 PM, Luke VanderHart
 wrote:
>
> Well! You learn something new every day.
>
> Ironically, I knew about octal, but back in the day when I was
> learning Java, the book I was reading didn't have a typeface that
> distinguished O and 0 very well, and since I never had to use them I
> never was corrected. Interesting.

This is pretty standard behaviour.  Here's Python:

>>> 07
7
>>> 08
  File "", line 1
08
 ^
SyntaxError: invalid token
>>> 010
8
>>>

And perl:

$ perl -e 'print 07, "\n";'
7
$ perl -e 'print 08, "\n";'
Illegal octal digit '8' at -e line 1, at end of line
Execution of -e aborted due to compilation errors.

Although perl gives you a better error message.

And the Unix "printf" command line tool:

$ printf "%d\n" 07
7
$ printf "%d\n" 08
-bash: printf: 08: invalid number
0

And C:

$ gcc -c /tmp/octal.c
/tmp/octal.c:7:20: error: invalid digit "8" in octal constant
/tmp/octal.c: In function 'main':
/tmp/octal.c:9: error: expected ';' before '}' token

I don't know Ruby, but it appears to do the same:

$ ruby
print 07, "\n"
print 08, "\n"
-:2: Illegal octal digit
print 08, "\n"
^

On the other hand, it's not universal.

sbcl:

* 07

7
* 08

8

-- 
Michael Wood 

--~--~-~--~~~---~--~~
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: Some help for tool builders...

2009-03-13 Thread pmf

On Mar 13, 1:19 pm, Eric Thorsen  wrote:
> I come across some functions in clojure/core that are really useful in
> tool building but often are private.
> Is it possible to make these public?

I'm using the following hack to access private functions (for example
generate-class is private):

;; define another var pointing to the function in question
(def wrapper #'generate-class)

;; use the new var
(wrapper whatever args it needs)

I.e. simply assign the "private" function to another var; since it's
the metadata that contains the "private"-modifier and the metadata
does not get copied over to the wrapper-var, you can access the
function by using the wrapper-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
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: VimClojure 2

2009-03-13 Thread Mark Volkmann

On Fri, Mar 13, 2009 at 7:27 AM, Adrian Cuthbertson
 wrote:
>
> Hi Mark, I'm also running on OSX 10.5. I couldn't get it working with
> the vim that comes with leopard - vim version 7.0.x
>
> I first downloaded and tried MacVim 7.2 from
> http://code.google.com/p/macvim/ but I couldn't unpack the .tbz files.
>
> I then tried the Vim.app 7.2 from
> http://sourceforge.net/projects/macosxvim/ and this works
> fantastically. I'm not sure what the difference is between this and
> MacVim - there's not much documentation.
>
> The setup was easy - I just installed from the .dmg and created a
> .gvimrc in addition to my .vimrc and .vim directory as before. The
> only problem I had was in getting vim to see the ng client but that
> was solved as per my previous post.

I already had Vim.app installed, but hadn't tried running VimClojure
commands from it. I just tried at it worked! I didn't add a .gvimrc
file. The .vimrc file I already had was sufficient.

So this casts a new light on the problem. It appears to be specific to
the vim that is a standard part of Mac OS X.

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~-~--~~~---~--~~
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: VimClojure 2

2009-03-13 Thread Albert Cardona


Since this is a thread on VimClojure. First of all to say I am looking 
forward to vimclojure working perfectly. Here are some problems I don't 
understand:

If I open a .clj file without the ng server running, it complains loudly 
and does not switch on syntax highlighting for clojure. Why no syntax on?

So I launch the ng.

The ng server is running happily, and on launching it reported:

   NGServer started on 127.0.0.1, port 2113.


Then I acess a .clj file. It 'works' fine, but I can't execute anything. 
Here's a snipped of a file test/patch.clj, opened from vim as "vim 
test/patch.clj", plus the overlayed error mesage triggered on pushing 
\ef to execute the whole file:


-8<
(ns test.patch
  (:import (ij.gui OvalRoi Roi ShapeRoi)
   (ij IJ ImagePlus)
   (ij.process ByteProcessor)
   (ini.trakem2.display Display Patch Selection)
   (mpicbg.trakem2.transform MovingLeastSquaresTransform)))

(defn punch-alpha-hole
  "Create an alpha hole right in the middle of an image."
  [patch]
  (let [ip (.getImageProcessor patch)
Error detected while processing function 
vimclojure#EvalFile..vimclojure#Execute
NailWithInput:
line   23:
E605: Exception not caught: Couldn't execute Nail! ng 
de.kotka.vimclojure.nails.
Repl '-r' '-n' 'test.patch' '-f' 'test/patch.clj' http://albert.rierol.net


--~--~-~--~~~---~--~~
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: Some help for tool builders...

2009-03-13 Thread Stephen C. Gilardi


On Mar 13, 2009, at 8:19 AM, Eric Thorsen wrote:


I come across some functions in clojure/core that are really useful in
tool building but often are private.
Is it possible to make these public?


An alternative to private that I've used in some of my contribs is to  
have a separate namespace for internal implementation details. This  
allows one to control exactly what public API is supported while still  
allowing access to the internals if someone really needs them.


For an example of this, please see clojure.contrib.miglayout which has  
exactly one public entry point and the supporting functions in  
clojure.contrib.miglayout.internal.


clojure.core is a tougher case because the entire language isn't  
available early on, but perhaps something like this could be made to  
work for at least some of the functions you're requesting.


--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: VimClojure 2

2009-03-13 Thread Adrian Cuthbertson

Hi Mark, I'm also running on OSX 10.5. I couldn't get it working with
the vim that comes with leopard - vim version 7.0.x

I first downloaded and tried MacVim 7.2 from
http://code.google.com/p/macvim/ but I couldn't unpack the .tbz files.

I then tried the Vim.app 7.2 from
http://sourceforge.net/projects/macosxvim/ and this works
fantastically. I'm not sure what the difference is between this and
MacVim - there's not much documentation.

The setup was easy - I just installed from the .dmg and created a
.gvimrc in addition to my .vimrc and .vim directory as before. The
only problem I had was in getting vim to see the ng client but that
was solved as per my previous post.

Hope that helps.

On Fri, Mar 13, 2009 at 1:51 PM, Mark Volkmann
 wrote:
>
> On Fri, Mar 13, 2009 at 2:50 AM, Adrian Cuthbertson
>  wrote:
>>
>> I think the " could be a problem in generating your path in .vimrc. Try...
>> let vimclojure#NailgunClient='/your_path/vimclojure-2.0.0/ng'
>>
>> and don't forget also for .vimrc
>> let g:clj_want_gorilla = 1
>
> I fixed the "let vimclojure" line to be just like yours and I already
> had the clj_want_gorilla line, but I'm getting the same error. Here
> are all the lines I added to my .vimrc.
>
> let g:clj_want_gorilla=1
> let g:clj_highlight_builtins=1
> let g:clj_highlight_contrib=1
> let g:clj_paren_rainbow=1
> let 
> vimclojure#NailgunClient='/Users/Mark/Documents/Programming/Languages/Clojure/vimclojure-2.0.0/ng'
>
> BTW, I'm running on a Mac with OS X 10.5.
>
>> On Fri, Mar 13, 2009 at 2:09 AM, Yasuto TAKENAKA  
>> wrote:
>>>
>>> In my environment, same error occurs ... although I have erased
>>> Gorilla and previous vimclojure packages. I install it using my
>>> installer script. If wrong, let me know.
>>> --
>>> #!/bin/sh
>>> # installer.sh - a simple vimclojure installer.
>>> # Please rewrite CLOJURE, CLOJURECONTRIB and VIMCLOJUREHOME.
>>> #   The example is that CLOJURE is ~/opt/clojure/clojure.jar,
>>> #   that CLOJURECONTRIB is ~/opt/clojure-contrib/clojure-contrib.jar
>>> #   and that VIMCLOJUREHOME is ~/opt/vimclojure .
>>>
>>> CLOJURE="${HOME}/opt/clojure/clojure.jar"
>>> CLOJURECONTRIB="${HOME}/opt/clojure-contrib/clojure-contrib.jar"
>>> NAILGUNCLIENT="ng"
>>> VIMCLOJUREHOME="${HOME}/opt/vimclojure"
>>>
>>> cp -r {autoload,doc,ftdetect,ftplugin,indent,syntax} ${HOME}/.vim
>>> ant -Dnailgun-client=${NAILGUNCLIENT} -Dclojure.jar=${CLOJURE} -
>>> Dclojure-contrib.jar=${CLOJURE-CONTRIB}
>>>
>>> # ./ngserver is a shell script for clojure server of vimclojure.
>>>
>>> echo '#!/bin/sh' > ngserver
>>> echo java -cp ${CLOJURE}:${CLOJURECONTRIB}:${VIMCLOJUREHOME}/
>>> vimclojure.jar com.martiansoftware.nailgun.NGServer 127.0.0.1 >>
>>> ngserver
>>> chmod 755 ngserver
>>>
>>> # echo let vimclojure#NailgunClient=\"${VIMCLOJUREHOME}/ng\">> $
>>> {HOME}/.vimrc
>>> --
>>>
>>> On 3月13日, 午前5:30, Mark Volkmann  wrote:
 On Mar 12, 3:21 pm, Mark Volkmann  wrote:

 > The README.txt file doesn't describe the files that need to be copied
 > to ~/.vim. I'm getting errors starting Vim now. I suspect it's because
 > I haven't copied all the necessary files to my ~/.vim directory. Which
 > files do I need to copy?

 Here is the copy command I used:

 cp -r {autoload,bin,doc,ftdetect,ftplugin,indent,syntax} ~/.vim

 Here are the errors I'm getting.

 Error detected while processing function
 vimclojure#ExecuteNailWithInput:
 line   23:
 E605: Exception not caught: Couldn't execute Nail! ng
 de.kotka.vimclojure.nails.N
 amespaceOfFile >>> v920635/0
 Error detected while processing /Users/Mark/.vim/ftplugin/clojure.vim:
 line  131:
 E171: Missing :endif
 Error detected while processing function 9_LoadFTPlugin:
 line   17:
 E170: Missing :endfor

 I do have nailgun running. The window it's in says "NGServer started
 on 127.0.0.1, port 2113."
>>>
>>> >
>>>
>>
>> >
>>
>
>
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
>
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Some help for tool builders...

2009-03-13 Thread Eric Thorsen

I come across some functions in clojure/core that are really useful in
tool building but often are private.
Is it possible to make these public?

spread
assert-args
sigs
libspec?
root-resource
root-directory

Let me know and I'll submit a patch.

Thanks,
Eric



--~--~-~--~~~---~--~~
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: "08" and "09" are invalid numbers, but "01" through "07" are fine?

2009-03-13 Thread Luke VanderHart

Well! You learn something new every day.

Ironically, I knew about octal, but back in the day when I was
learning Java, the book I was reading didn't have a typeface that
distinguished O and 0 very well, and since I never had to use them I
never was corrected. Interesting.

Thanks!



On Mar 12, 5:14 pm, Shawn Hoover  wrote:
> On Thu, Mar 12, 2009 at 5:13 PM, Meikel Brandmeyer  wrote:
> > Hi,
>
> > Am 12.03.2009 um 22:08 schrieb levand:
>
> >  Seems like there's a bug here. All the digits less than 8 work. If
> >> leading zeros aren't allowed, at least the behavior ought to be
> >> consistent.
>
> > Leading zeros indicate octal, which has no digits like 8 or 9...
>
> > In so far it's not a bug nor is it inconsistent, I guess.
>
> Indeed. And if you just use 0-7 and it's all good:
> user> 010
> 8
--~--~-~--~~~---~--~~
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: VimClojure 2

2009-03-13 Thread Mark Volkmann

On Thu, Mar 12, 2009 at 6:05 PM, Kyle Schaffrick  wrote:
>
>> Here are the errors I'm getting.
>>
>> Error detected while processing function
>> vimclojure#ExecuteNailWithInput:
>> line   23:
>> E605: Exception not caught: Couldn't execute Nail! ng
>> de.kotka.vimclojure.nails.N
>> amespaceOfFile > v920635/0
>> Error detected while processing /Users/Mark/.vim/ftplugin/clojure.vim:
>> line  131:
>> E171: Missing :endif
>> Error detected while processing function 9_LoadFTPlugin:
>> line   17:
>> E170: Missing :endfor
>
> I got this exact error also at first. It turned out there was an
> extraneous file in my .vim from an older version of Gorilla, pretty sure
> it was ~/.vim/after/ftplugin/clojure.vim.
>
> Deleting this file and restarting Vim fixed it for me.

I deleted all the files related to VimClojure and Gorilla from under
my .vim directory and then copied the VimClojure files there again,
but I'm still getting the same error.

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~-~--~~~---~--~~
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: VimClojure 2

2009-03-13 Thread Mark Volkmann

On Fri, Mar 13, 2009 at 2:50 AM, Adrian Cuthbertson
 wrote:
>
> I think the " could be a problem in generating your path in .vimrc. Try...
> let vimclojure#NailgunClient='/your_path/vimclojure-2.0.0/ng'
>
> and don't forget also for .vimrc
> let g:clj_want_gorilla = 1

I fixed the "let vimclojure" line to be just like yours and I already
had the clj_want_gorilla line, but I'm getting the same error. Here
are all the lines I added to my .vimrc.

let g:clj_want_gorilla=1
let g:clj_highlight_builtins=1
let g:clj_highlight_contrib=1
let g:clj_paren_rainbow=1
let 
vimclojure#NailgunClient='/Users/Mark/Documents/Programming/Languages/Clojure/vimclojure-2.0.0/ng'

BTW, I'm running on a Mac with OS X 10.5.

> On Fri, Mar 13, 2009 at 2:09 AM, Yasuto TAKENAKA  wrote:
>>
>> In my environment, same error occurs ... although I have erased
>> Gorilla and previous vimclojure packages. I install it using my
>> installer script. If wrong, let me know.
>> --
>> #!/bin/sh
>> # installer.sh - a simple vimclojure installer.
>> # Please rewrite CLOJURE, CLOJURECONTRIB and VIMCLOJUREHOME.
>> #   The example is that CLOJURE is ~/opt/clojure/clojure.jar,
>> #   that CLOJURECONTRIB is ~/opt/clojure-contrib/clojure-contrib.jar
>> #   and that VIMCLOJUREHOME is ~/opt/vimclojure .
>>
>> CLOJURE="${HOME}/opt/clojure/clojure.jar"
>> CLOJURECONTRIB="${HOME}/opt/clojure-contrib/clojure-contrib.jar"
>> NAILGUNCLIENT="ng"
>> VIMCLOJUREHOME="${HOME}/opt/vimclojure"
>>
>> cp -r {autoload,doc,ftdetect,ftplugin,indent,syntax} ${HOME}/.vim
>> ant -Dnailgun-client=${NAILGUNCLIENT} -Dclojure.jar=${CLOJURE} -
>> Dclojure-contrib.jar=${CLOJURE-CONTRIB}
>>
>> # ./ngserver is a shell script for clojure server of vimclojure.
>>
>> echo '#!/bin/sh' > ngserver
>> echo java -cp ${CLOJURE}:${CLOJURECONTRIB}:${VIMCLOJUREHOME}/
>> vimclojure.jar com.martiansoftware.nailgun.NGServer 127.0.0.1 >>
>> ngserver
>> chmod 755 ngserver
>>
>> # echo let vimclojure#NailgunClient=\"${VIMCLOJUREHOME}/ng\">> $
>> {HOME}/.vimrc
>> --
>>
>> On 3月13日, 午前5:30, Mark Volkmann  wrote:
>>> On Mar 12, 3:21 pm, Mark Volkmann  wrote:
>>>
>>> > The README.txt file doesn't describe the files that need to be copied
>>> > to ~/.vim. I'm getting errors starting Vim now. I suspect it's because
>>> > I haven't copied all the necessary files to my ~/.vim directory. Which
>>> > files do I need to copy?
>>>
>>> Here is the copy command I used:
>>>
>>> cp -r {autoload,bin,doc,ftdetect,ftplugin,indent,syntax} ~/.vim
>>>
>>> Here are the errors I'm getting.
>>>
>>> Error detected while processing function
>>> vimclojure#ExecuteNailWithInput:
>>> line   23:
>>> E605: Exception not caught: Couldn't execute Nail! ng
>>> de.kotka.vimclojure.nails.N
>>> amespaceOfFile >> v920635/0
>>> Error detected while processing /Users/Mark/.vim/ftplugin/clojure.vim:
>>> line  131:
>>> E171: Missing :endif
>>> Error detected while processing function 9_LoadFTPlugin:
>>> line   17:
>>> E170: Missing :endfor
>>>
>>> I do have nailgun running. The window it's in says "NGServer started
>>> on 127.0.0.1, port 2113."
>>
>> >
>>
>
> >
>



-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



mocking in clojure

2009-03-13 Thread Korny Sietsma
Hi folks - are there any frameworks out there for mocking?
Stubbing functions is pretty straightforward (and I see that fact comes with
a stubbing function built in), but I'd really like something that can do
mocking and mock expectations - something similar to stub, but with checking
that the stubbed calls actually happen an expected number of times.

A bit of googling finds
http://github.com/mclark/test-expect/tree/masterwhich looks nice,
though I'm not sure about depending on test-is (I was
planning to use 'fact'),
and a blank project at http://github.com/amitrathore/conjure/tree/master
and not much else.

Any other options out there?

- Korny
-- 
Kornelis Sietsma  korny at my surname dot com
kornys on gmail, twitter, facebook, etc.
"Every jumbled pile of person has a thinking part
that wonders what the part that isn't thinking
isn't thinking of"

--~--~-~--~~~---~--~~
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: Speed issues vs. Python

2009-03-13 Thread Christophe Grand

It wont solve your performance problem but I think that your python code 
translates to:

(defn f[a b c]
  (+ (* c c c c) (* b b b) (* a a)))

(count
  (into #{} 
(for [c primes :while (< (f (first primes) (first primes) c) limit)
  b primes :while (< (f (first primes) b c) limit)
  a primes :let [x (f a b c)] :while (< x limit)]
  x)))


Could you run your tests with -XX:+PrintGCDetails passed to the jvm?

Christophe

tristan a écrit :
> Hi guys,
>
> I'm loving Clojure, but i'm having a lot of trouble writing programs
> in it that run as fast as my python equivalents.
> One example is code i've written for projecteuler.net problem 87 (for
> those who don't want to see any solutions don't click the links
> below :))
> my python version 
> http://github.com/tristan/project-euler-code/blob/4a17bc271b4b2743ee1d5b5692f86f963c6bcc7b/0087.py
> runs in ~4 seconds (timed using cygwin "time python 0087.py" whereas
> my clojure version 
> http://github.com/tristan/project-euler-code/blob/4a17bc271b4b2743ee1d5b5692f86f963c6bcc7b/0087.clj
> takes over 20 seconds (time gotten from (time call in the code). This
> is quite disheartening for me as well since i wrote the python version
> in about a minute and haven't even thought about optimizations yet. It
> was just written as a test since i was unhappy with the speed of my
> clojure version even after re-writing it a few times and shaving off
> about 20 seconds from my original.
>
> I'm sure there must be something i'm doing wrong, or thinking wrongly
> about hence why i'm not getting the speed i need. Can anyone suggest
> any alternate ways to write this? or anything to speed it up? I really
> enjoy programming in Clojure, but speed is starting to become an issue
> with me.
>
> Thanks
> -Tristan
> >
>
>   


-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.blogspot.com/ (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
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: r994 UTF8 addition broke latin-1 characters (ISO-8859-1) - WAS: Re: Unicode, accented characters

2009-03-13 Thread Christophe Grand

here is some background info on the change:
http://groups.google.com/group/clojure/browse_thread/thread/123ef17d7c650018/e1da76a4a273aa5a

max3000 a écrit :
> The default character set on WinXP (which I use) is windows-1252
> (cp1252). Check out http://www.rgagnon.com/javadetails/java-0505.html.
>
> If I were to change my source file encodings to UTF-8 that would
> probably get me some mileage. Of course, I would have to use an editor
> that supports it and not all editors would (on windows). However, it
> wouldn't change anything in the REPL. Presumably, stdin in Java is
> tied to the platform's default encoding and there is probably no way
> to change that. My understanding is that clojure assumes reading a
> file and reading stdin is the same thing encoding-wise. That's a
> faulty assumption.
>   

I think that forcing source files to be UTF-8 is a good thing when 
sharing code.

On the subject of the REPL, what about adding a property (eg 
"clojure.repl.encoding") to override the default? (I'm still ambivalent 
on this subject: I don't know which default (utf-8 or plaftorm) is best.)

Christophe


-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.blogspot.com/ (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
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: Speed issues vs. Python

2009-03-13 Thread André Thieme

On 12 Mrz., 07:48, tristan  wrote:
> my clojure version 
> http://github.com/tristan/project-euler-code/blob/4a17bc271b4b2743ee1...

Not about speed, but about readability:
(loop [c primes n #{}]
  (let [r (loop [b primes n n]
   (let [r (loop [a primes n n]
  ...)))

You should think about using automatic destructuring of a, b and c.
You call many times (first a), (first b) and (first c).

If you say you want to call the first of the a primes fa and their
rest ra then you could say:
(loop [[fa & ra] primes ..

Now instead of (first a) you just write fa.
And instead of (rest a)  you just write ra.
Same goes with fb and rb, and fc and rc.
This will make your code much more readable.
--~--~-~--~~~---~--~~
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: version of -> short-circuiting on nil

2009-03-13 Thread Laurent PETIT
OK, so I think the consensus is on the names .?. and -?> . No problem with
me.

I'm willing to write the patch, but which patch ? I mean, do these macros
deserve their own file (maybe not) ?
Maybe adding them to the existing clojure.contrib.macros ?
Or else, I was thinking about creating a new file named clojure.contrib.core
since these are slight variants of existing core functions ?

2009/3/13 Stephen C. Gilardi 

>
> On Mar 12, 2009, at 9:45 PM, Mark Volkmann wrote:
>
>>
>> On Thu, Mar 12, 2009 at 5:04 PM, Stephen C. Gilardi 
>> wrote:
>>
>>>
>>> I like these:
>>>
>>>   .?.
>>>   -?>
>>>
>>
>  Given a choice between the two, I'd choose -?>
>>
>
> The proposal was for naming "nil-safe" versions of the existing .. and ->
> functions.
>
> (-> nil (. toString)) ==> NullPointerException
>
> (-?> nil (. toString)) ==> nil
>
>
> (.. nil (toString)) ==> NullPointerException
>
> (.?. nil (toString)) ==> nil
>
>
> Note: these are just simple examples. The point isn't the one argument,
> literal nil case, but the case where many operations are "chained" or
> "threaded" and at each point the propagated result may be nil.
>
> --Steve
>
>

--~--~-~--~~~---~--~~
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: VimClojure 2.0.0 released (merged with Gorilla)

2009-03-13 Thread Meikel Brandmeyer

Hi,

Am 13.03.2009 um 09:08 schrieb MattH:


I noticed that the  and  key bindings used for the
history navigation work fine in MacVim.app, but not from the terminal
in OS X.


I don't use Vim in a terminal anymore. The I don't do much testing  
there.



So for any VimClojurians on OS X with the same problem, suggested
workarounds:
- use MacVim.app, or


+1 Definitively a good idea!


- add alternative mappings in autoload/vimclojure.vim
(look for "imapClojureReplUpHistory",
and substitute  for another key)


It shouldn't be necessary to edit the VimClojure files directly.
You can put the following in your .vimrc.

function SetupMyVCRepl()
imapClojureReplUpHistory
imapClojureReplDownHistory
endfunction

autocmd FileType * if &ft == "clojure" && exists("b:vimclojure_repl")  
| call SetupMyVCRepl() | endif


This should work (at least it did when I tested it). If there is already
a binding VimClojure will skip the default. And this is more robust
against updates.

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: VimClojure 2.0.0 released (merged with Gorilla)

2009-03-13 Thread Meikel Brandmeyer

Hi,

Am 13.03.2009 um 05:51 schrieb rzeze...@gmail.com:


1) In the preview window it says "Use \p to close this buffer!", but I
have m LocalLeader mapped to ",".  I'm guessing maybe you hardcoded
this by accident?


Yes. I should read the maplocalleader option to show the right key.  
Will be fixed.



2) When doing a macroexpand (me or m1), the cursor is moved into the
REPL buffer.  Is this on purpose?  I'd prefer it to stay in it's
original buffer and not move.


Uh. This one will become trickier. Cursor movement in vim windows
Up to now I avoided that like the devil the holy water... But it seems I
have to look into it.

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: Performance tips for Clojure

2009-03-13 Thread Christophe Grand

Christian Vest Hansen a écrit :
> I think that count is O(n) for lists, no?
>   

Count is O(1) for lists but O(n) for a chain of conses.

Clojure
user=> (let [l (apply list (range 10))] (time (dotimes [_ 100] 
(count l
"Elapsed time: 169.710116 msecs"
nil
user=> (let [l (apply list (range 40))] (time (dotimes [_ 100] 
(count l
"Elapsed time: 167.664046 msecs"
nil
user=> (let [l (reduce #(cons %2 %1) nil (range 10))] (time (dotimes 
[_ 100] (count l
"Elapsed time: 662.121862 msecs"
nil
user=> (let [l (reduce #(cons %2 %1) nil (range 100))] (time 
(dotimes [_ 100] (count l
"Elapsed time: 5316.110567 msecs"
nil


-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.blogspot.com/ (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
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: Performance tips for Clojure

2009-03-13 Thread Christian Vest Hansen

On Fri, Mar 13, 2009 at 7:49 AM, Chouser  wrote:
>
> On Fri, Mar 13, 2009 at 2:18 AM, Sergio  wrote:
>>
>> There are a couple of obvious ones, but also some others that I
>> haven't seen documented (like, map is much faster on lists than on
>> vectors since rest is O(1) for lists).
>
> You're right that 'rest' is O(1) for lists, but it's O(1) for vectors as well.
>
> Your blog post include this table:
>
>> rest - O(1) for lists. O(n) for vectors.
>> count - O(1) for lists and vectors

I think that count is O(n) for lists, no?

>> nth - O(n) for lists. O(1) for vectors.
>> cons - O(1) for lists, O(n) for vectors
>
> This has a couple errors.  Both 'rest' and 'cons' are O(1) on vectors.
> I'm not sure what in the source code led you to believe otherwise.
> Both 'rest' and 'cons' create a seq from the vector, but this is an
> O(1) operation.  You can also run some timing experiments and see that
> 'map' is at least as fast on vectors as on lists.
>
>  (defn timemap [c]
>    (time
>      (dotimes [i 100]
>        (last (map identity c)
>
>  (timemap (into [] (range 1)))  ==> "Elapsed time: 158.464048 msecs"
>  (timemap (into [] (range 10))) ==> "Elapsed time: 1690.745615 msecs"
>
> Note that multiplying the length of the vector by 10 increased the
> time by roughly 10 -- this suggests an O(n) operation, as we would
> expect.
>
>  (timemap (into () (range 1)))  ==> "Elapsed time: 185.460957 msecs"
>  (timemap (into () (range 10))) ==> "Elapsed time: 1821.346964 msecs"
>
> Again we see evidence of 'map' being O(n), but when walking across a
> list it appears to run slightly *slower* than across a vector, though
> probably not by enough to be significant.
>
>
> We can even time 'rest' itself:
>
>  (defn timerest [c]
>    (time
>      (dotimes [i 100]
>        (rest c
>
>  (timerest (into [] (range 1)))  ==> "Elapsed time: 125.826519 msecs"
>
> If 'rest' were O(n) on vectors, we should be able to multiply the
> length of the vector by 100 and see the time go up by roughly 100x:
>
>  (timerest (into [] (range 100)))  ==> "Elapsed time: 147.096976 msecs"
>
> The amount of time it takes to build the vector goes up significantly,
> but the timed part, calling 'rest' a million times, doesn't take
> anywhere near 100 times longer.
>
> --Chouser
>
> >
>



-- 
Venlig hilsen / Kind regards,
Christian Vest Hansen.

--~--~-~--~~~---~--~~
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: VimClojure 2.0.0 released (merged with Gorilla)

2009-03-13 Thread MattH

Thanks Meikel, this is really useful!

I noticed that the  and  key bindings used for the
history navigation work fine in MacVim.app, but not from the terminal
in OS X.

So for any VimClojurians on OS X with the same problem, suggested
workarounds:
- use MacVim.app, or
- add alternative mappings in autoload/vimclojure.vim
 (look for "imapClojureReplUpHistory",
and substitute  for another key)
--~--~-~--~~~---~--~~
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: VimClojure 2

2009-03-13 Thread Adrian Cuthbertson

I think the " could be a problem in generating your path in .vimrc. Try...
let vimclojure#NailgunClient='/your_path/vimclojure-2.0.0/ng'

and don't forget also for .vimrc
let g:clj_want_gorilla = 1

Rgds, Adrian.

On Fri, Mar 13, 2009 at 2:09 AM, Yasuto TAKENAKA  wrote:
>
> In my environment, same error occurs ... although I have erased
> Gorilla and previous vimclojure packages. I install it using my
> installer script. If wrong, let me know.
> --
> #!/bin/sh
> # installer.sh - a simple vimclojure installer.
> # Please rewrite CLOJURE, CLOJURECONTRIB and VIMCLOJUREHOME.
> #   The example is that CLOJURE is ~/opt/clojure/clojure.jar,
> #   that CLOJURECONTRIB is ~/opt/clojure-contrib/clojure-contrib.jar
> #   and that VIMCLOJUREHOME is ~/opt/vimclojure .
>
> CLOJURE="${HOME}/opt/clojure/clojure.jar"
> CLOJURECONTRIB="${HOME}/opt/clojure-contrib/clojure-contrib.jar"
> NAILGUNCLIENT="ng"
> VIMCLOJUREHOME="${HOME}/opt/vimclojure"
>
> cp -r {autoload,doc,ftdetect,ftplugin,indent,syntax} ${HOME}/.vim
> ant -Dnailgun-client=${NAILGUNCLIENT} -Dclojure.jar=${CLOJURE} -
> Dclojure-contrib.jar=${CLOJURE-CONTRIB}
>
> # ./ngserver is a shell script for clojure server of vimclojure.
>
> echo '#!/bin/sh' > ngserver
> echo java -cp ${CLOJURE}:${CLOJURECONTRIB}:${VIMCLOJUREHOME}/
> vimclojure.jar com.martiansoftware.nailgun.NGServer 127.0.0.1 >>
> ngserver
> chmod 755 ngserver
>
> # echo let vimclojure#NailgunClient=\"${VIMCLOJUREHOME}/ng\">> $
> {HOME}/.vimrc
> --
>
> On 3月13日, 午前5:30, Mark Volkmann  wrote:
>> On Mar 12, 3:21 pm, Mark Volkmann  wrote:
>>
>> > The README.txt file doesn't describe the files that need to be copied
>> > to ~/.vim. I'm getting errors starting Vim now. I suspect it's because
>> > I haven't copied all the necessary files to my ~/.vim directory. Which
>> > files do I need to copy?
>>
>> Here is the copy command I used:
>>
>> cp -r {autoload,bin,doc,ftdetect,ftplugin,indent,syntax} ~/.vim
>>
>> Here are the errors I'm getting.
>>
>> Error detected while processing function
>> vimclojure#ExecuteNailWithInput:
>> line   23:
>> E605: Exception not caught: Couldn't execute Nail! ng
>> de.kotka.vimclojure.nails.N
>> amespaceOfFile > v920635/0
>> Error detected while processing /Users/Mark/.vim/ftplugin/clojure.vim:
>> line  131:
>> E171: Missing :endif
>> Error detected while processing function 9_LoadFTPlugin:
>> line   17:
>> E170: Missing :endfor
>>
>> I do have nailgun running. The window it's in says "NGServer started
>> on 127.0.0.1, port 2113."
>
> >
>

--~--~-~--~~~---~--~~
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: Performance tips for Clojure

2009-03-13 Thread Mark Engelberg

list doesn't do what you think it does.  You've just created a list of
one element.

On Fri, Mar 13, 2009 at 12:10 AM, Sergio  wrote:
> (def ls (list (range 100)))

--~--~-~--~~~---~--~~
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: What is Clojure NOT good for?

2009-03-13 Thread knubee

> Is it fair to say that Clojure shines in algorithmic processing, string
> processing, concurrency management, but that there are better choices in
> other areas:

not an answer, but a follow-on question: how well does clojure
currently support multimedia programming? i realize it supports it to
the extent that java does, but i am curious about the existence or
plans for clojure libraries for graphics, animations, audio, gui
widgets, etc.

i see there is a clojure wrapper for the processing language, but a)
that means an additional layer between clojure and java, and b) the
library examples suggest that there is still some amount of directly
invoking java (rather than having clojure-level procedures).


--~--~-~--~~~---~--~~
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: VimClojure 2

2009-03-13 Thread Yasuto TAKENAKA

In my environment, same error occurs ... although I have erased
Gorilla and previous vimclojure packages. I install it using my
installer script. If wrong, let me know.
--
#!/bin/sh
# installer.sh - a simple vimclojure installer.
# Please rewrite CLOJURE, CLOJURECONTRIB and VIMCLOJUREHOME.
#   The example is that CLOJURE is ~/opt/clojure/clojure.jar,
#   that CLOJURECONTRIB is ~/opt/clojure-contrib/clojure-contrib.jar
#   and that VIMCLOJUREHOME is ~/opt/vimclojure .

CLOJURE="${HOME}/opt/clojure/clojure.jar"
CLOJURECONTRIB="${HOME}/opt/clojure-contrib/clojure-contrib.jar"
NAILGUNCLIENT="ng"
VIMCLOJUREHOME="${HOME}/opt/vimclojure"

cp -r {autoload,doc,ftdetect,ftplugin,indent,syntax} ${HOME}/.vim
ant -Dnailgun-client=${NAILGUNCLIENT} -Dclojure.jar=${CLOJURE} -
Dclojure-contrib.jar=${CLOJURE-CONTRIB}

# ./ngserver is a shell script for clojure server of vimclojure.

echo '#!/bin/sh' > ngserver
echo java -cp ${CLOJURE}:${CLOJURECONTRIB}:${VIMCLOJUREHOME}/
vimclojure.jar com.martiansoftware.nailgun.NGServer 127.0.0.1 >>
ngserver
chmod 755 ngserver

# echo let vimclojure#NailgunClient=\"${VIMCLOJUREHOME}/ng\">> $
{HOME}/.vimrc
--

On 3月13日, 午前5:30, Mark Volkmann  wrote:
> On Mar 12, 3:21 pm, Mark Volkmann  wrote:
>
> > The README.txt file doesn't describe the files that need to be copied
> > to ~/.vim. I'm getting errors starting Vim now. I suspect it's because
> > I haven't copied all the necessary files to my ~/.vim directory. Which
> > files do I need to copy?
>
> Here is the copy command I used:
>
> cp -r {autoload,bin,doc,ftdetect,ftplugin,indent,syntax} ~/.vim
>
> Here are the errors I'm getting.
>
> Error detected while processing function
> vimclojure#ExecuteNailWithInput:
> line   23:
> E605: Exception not caught: Couldn't execute Nail! ng
> de.kotka.vimclojure.nails.N
> amespaceOfFile  v920635/0
> Error detected while processing /Users/Mark/.vim/ftplugin/clojure.vim:
> line  131:
> E171: Missing :endif
> Error detected while processing function 9_LoadFTPlugin:
> line   17:
> E170: Missing :endfor
>
> I do have nailgun running. The window it's in says "NGServer started
> on 127.0.0.1, port 2113."

--~--~-~--~~~---~--~~
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: r994 UTF8 addition broke latin-1 characters (ISO-8859-1) - WAS: Re: Unicode, accented characters

2009-03-13 Thread max3000

I paste below what I got. It's doing something for sure, but just for
*out* I think.

Thanks.


user=> (println "abcd")
����abcd
nil
user=> (binding [*in* (new LineNumberingPushbackReader (new
InputStreamReader
System/in))
  *out* (new OutputStreamWriter System/out)]
  (println "abcd"))
abcd
nil
user=>
(binding [*in* (new LineNumberingPushbackReader (new InputStreamReader
System/in))]
  (println "abcd"))
����abcd
nil
user=> (binding [*out* (new OutputStreamWriter System/out)]
  (println "abcd"))

abcd
nil


On Mar 13, 3:09 am, Michael Wood  wrote:
> On Fri, Mar 13, 2009 at 8:46 AM, max3000  wrote:
>
> > Any news on this item? Does what I'm saying make sense?
>
> > I understand most people who use clojure are probably English-speaking
> > and couldn't care less about internationalization, but this has to be
> > addressed if clojure is to get any semblance of semi-mainstream
> > adoption. In fact, one of the reasons I chose clojure myself is
> > because internationalization is a solved problem in Java (and hence I
> > though in clojure as well). If the perception is that the problem is
> > "limited" to Windows, well, that's 90% of the deployed PCs out there.
>
> > Since the fix seems so trivial and requires changes in only about 5
> > lines of code, I'm not sure what prevents this from being fixed. At
> > least, is there a clojure bug tracking site where I could add this
> > issue?
>
> What happens if you do this:
>
> ;; untested
> (binding [*in* (new LineNumberingPushbackReader (new InputStreamReader
> System/in))
>   *out* (new OutputStreamWriter System/out)]
>   (your-code-here))
>
> --
> Michael Wood 
--~--~-~--~~~---~--~~
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: Miller-Rabin pseudo-primality test

2009-03-13 Thread Tassilo Horn

Jerry K  writes:

Hi Jerry,

> Glad your problem is resolved.  Miller-Rabin is quite zippy...  and
> practical for real use.  If you want a next cool exercise to take a
> crack at, the direction one often goes is to improve the speed of the
> underlying multiplications using the FFT...

I looked at wikipedia and there seem to be some other alternatives, too,
like Karatsuba or Toom–Cook multiplication.  Maybe I'll dig into those
when I find some time to experiment.

Bye,
Tassilo
-- 
They say  curiosity killed the cat.  This is false.  Chuck Norris killed
the cat. Every single one of them.

--~--~-~--~~~---~--~~
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: Performance tips for Clojure

2009-03-13 Thread Sergio

Sorry =( I am horribly mistaken
I should have taken my time before posting..
But still, I really thought cons on vectors was O(n) base on
PersistentVector.java, line 148 (The version I'm reading is not the
current SVN head, so I don't know if it is that line for you)
Here is the snippet:

if(tail.length < 32)
{
Object[] newTail = new Object[tail.length + 1];
System.arraycopy(tail, 0, newTail, 0, tail.length);
newTail[tail.length] = val;
return new PersistentVector(meta(), cnt + 1, shift, root, 
newTail);
}
I thought it was O(n) because of the System.arraycopy. I'm guessing
that for length<32 that is considered "constant" and the rest of the
cons function does something else.

Here is the microbenchmark that made me think map was slower on
vectors:

(def ls (list (range 100)))
(def vc (vec (range 100)))

(time (dorun (map (fn [x]) ls)))
"Elapsed time: 3.184435 msecs"

(time (dorun (map (fn [x]) vc)))
"Elapsed time: 498.535303 msecs"

Maybe you can explain it to me (On my blog I posted that maybe it was
because map was converting the vector to a seq and that was O(n), but
you just told me that converting vector to seq is O(n).


On Mar 13, 12:49 am, Chouser  wrote:
> On Fri, Mar 13, 2009 at 2:18 AM, Sergio  wrote:
>
> > There are a couple of obvious ones, but also some others that I
> > haven't seen documented (like, map is much faster on lists than on
> > vectors since rest is O(1) for lists).
>
> You're right that 'rest' is O(1) for lists, but it's O(1) for vectors as well.
>
> Your blog post include this table:
>
> > rest - O(1) for lists. O(n) for vectors.
> > count - O(1) for lists and vectors
> > nth - O(n) for lists. O(1) for vectors.
> > cons - O(1) for lists, O(n) for vectors
>
> This has a couple errors.  Both 'rest' and 'cons' are O(1) on vectors.
> I'm not sure what in the source code led you to believe otherwise.
> Both 'rest' and 'cons' create a seq from the vector, but this is an
> O(1) operation.  You can also run some timing experiments and see that
> 'map' is at least as fast on vectors as on lists.
>
>   (defn timemap [c]
>     (time
>       (dotimes [i 100]
>         (last (map identity c)
>
>   (timemap (into [] (range 1)))  ==> "Elapsed time: 158.464048 msecs"
>   (timemap (into [] (range 10))) ==> "Elapsed time: 1690.745615 msecs"
>
> Note that multiplying the length of the vector by 10 increased the
> time by roughly 10 -- this suggests an O(n) operation, as we would
> expect.
>
>   (timemap (into () (range 1)))  ==> "Elapsed time: 185.460957 msecs"
>   (timemap (into () (range 10))) ==> "Elapsed time: 1821.346964 msecs"
>
> Again we see evidence of 'map' being O(n), but when walking across a
> list it appears to run slightly *slower* than across a vector, though
> probably not by enough to be significant.
>
> We can even time 'rest' itself:
>
>   (defn timerest [c]
>     (time
>       (dotimes [i 100]
>         (rest c
>
>   (timerest (into [] (range 1)))  ==> "Elapsed time: 125.826519 msecs"
>
> If 'rest' were O(n) on vectors, we should be able to multiply the
> length of the vector by 100 and see the time go up by roughly 100x:
>
>   (timerest (into [] (range 100)))  ==> "Elapsed time: 147.096976 msecs"
>
> The amount of time it takes to build the vector goes up significantly,
> but the timed part, calling 'rest' a million times, doesn't take
> anywhere near 100 times longer.
>
> --Chouser
--~--~-~--~~~---~--~~
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: r994 UTF8 addition broke latin-1 characters (ISO-8859-1) - WAS: Re: Unicode, accented characters

2009-03-13 Thread Michael Wood

On Fri, Mar 13, 2009 at 8:46 AM, max3000  wrote:
>
> Any news on this item? Does what I'm saying make sense?
>
> I understand most people who use clojure are probably English-speaking
> and couldn't care less about internationalization, but this has to be
> addressed if clojure is to get any semblance of semi-mainstream
> adoption. In fact, one of the reasons I chose clojure myself is
> because internationalization is a solved problem in Java (and hence I
> though in clojure as well). If the perception is that the problem is
> "limited" to Windows, well, that's 90% of the deployed PCs out there.
>
> Since the fix seems so trivial and requires changes in only about 5
> lines of code, I'm not sure what prevents this from being fixed. At
> least, is there a clojure bug tracking site where I could add this
> issue?

What happens if you do this:

;; untested
(binding [*in* (new LineNumberingPushbackReader (new InputStreamReader
System/in))
  *out* (new OutputStreamWriter System/out)]
  (your-code-here))

-- 
Michael Wood 

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---