Re: Java 7, nio, and createFile

2009-10-29 Thread youngblood.carl

Works beautifully. Thank you sir.

On Oct 28, 10:40 pm, Alex Osborne  wrote:
> youngblood.carl wrote:
> > When I try and call createFile from clojure:
> > (.createFile path)
>
> > I get an exception that there is no field named createFile.
>
> If I remember correctly variable argument Java methods, which is what
> that "..." syntax means:
>
>    abstract Path createFile(FileAttribute... attrs) {}
>
> are actually just syntactic sugar for an array argument:
>
>    abstract Path createFile(FileAttribute[] attrs) {}
>
> so try:
>
>    (.createFile path (make-array FileAttribute 0))
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Java 7, nio, and createFile

2009-10-28 Thread youngblood.carl

Howdy all,

I'm trying to call the createFile method from the Path class specified
here:
http://java.sun.com/javase/7/docs/api/java/nio/file/Path.html


The following text:
The following code snippet creates a file with default attributes:

Path file = ...;
try {
file.createFile();   //Create the empty file with default
permissions, etc.
} catch (FileAlreadyExists x) {
System.err.format("file named %s already exists%n", file);
} catch (IOException x) {
//Some other sort of failure, such as permissions.
System.err.format("createFile error: %s%n", x);
}

from:
http://java.sun.com/docs/books/tutorial/essential/io/file.html

describes how you can call createFile without any parameters even
though the method signature in the api only has one version of the
method taking a FileAttribute object.


When I try and call createFile from clojure:
(.createFile path)

I get an exception that there is no field named createFile. This makes
perfect sense to me since there is no public method with an explicit
signature taking zero args, so clojure is looking for a field.
However, based on a test program in java and the tutorial text, the
method works great without any parameters. Is there any way to force
clojure to try and call the method? Passing nil as an argument gets a
null pointer exception.

I could create a FileAttribute object easily if I was running on a
Posix filesystem, but I'd like this to work on DOS as well.

Thanks!
Carl
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Shell script

2009-03-30 Thread youngblood.carl

Hey Ya'll,

If you're ever wondering where something is defined, I put together
this shell script tonight. Just save it, chmod it to be executable,
and run ./foo.sh text-to-search-for

#!/bin/sh
find . -name "*.jar" | xargs -tn1 -I "%" sh -c 'jar tf "%" | grep .clj
| xargs -tn1 unzip -p "%" | grep -H --color '$1

I know the -H is extraneous in the final grep but I find the
formatting helps it stand out when it gets a hit.

Best,
Carl
--~--~-~--~~~---~--~~
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: swank-clojure + slime

2009-03-08 Thread youngblood.carl

Phil,

I am much obliged for the detailed help. I downloaded clojure as the
archive available from google code rather than using svn.

So the docs at http://clojure.org/api are out of date then?

Thanks,
Carl

On Mar 8, 2:15 pm, Phil Hagelberg  wrote:
> "youngblood.carl"  writes:
> > Thanks Lucio, but you can see on git-hub that the head version of
> > core.clj uses lazy-seq:
>
> >http://github.com/jochu/swank-clojure/blob/349cb3b93a7bd8bcc86ffd0fd5...
>
> The lazy-seq macro is what replaced lazy-cons. Swank-clojure *has* been
> updated to use lazy-seq; I think you've got it backwards. It's software
> that contains calls to lazy-cons that needs to be updated.
>
> It sounds more likely that your copy of Clojure is out of date. Are you
> pulling from the sourceforge SVN by any chance?
>
> It would probably be a good idea to make it so the last commit in the SF
> repo is simply a README saying "don't use this anymore; use the current
> repository at [...]" and remove all the code in it just to avoid these
> problems in the future.
>
> If you're having trouble keeping your versions straight and updating,
> you should try using M-x clojure-install from within Emacs. Recent
> versions of clojure-mode have this included. It will check out Clojure,
> Contrib, SLIME, and Clojure-swank and configure Emacs to use those
> newly-checked out versions for you. It is very straightforward and seems
> to work well for everyone I've talked with. Give it a shot and let me
> know how it works for you.
>
> -Phil
--~--~-~--~~~---~--~~
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: swank-clojure + slime

2009-03-08 Thread youngblood.carl

Thanks for linking Clojure Box, that is cool.

If anyone wants to try my fix I've branched swank-clojure on github
and committed the change.
http://github.com/doncarlosx/swank-clojure/tree/master


On Mar 8, 9:39 am, christophe turle  wrote:
> Same problem here.
>
> my solution : i'm currently using Clojure Box -http://clojure.bighugh.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
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: swank-clojure + slime

2009-03-08 Thread youngblood.carl

Thanks Lucio, but you can see on git-hub that the head version of
core.clj uses lazy-seq:

http://github.com/jochu/swank-clojure/blob/349cb3b93a7bd8bcc86ffd0fd5415d84ed5f4028/swank/core.clj

On Mar 8, 9:02 am, Lucio Fulci  wrote:
> First of all, make sure you use the latest versions of slime, clojure,
> swank-clojre and clojure-mode. It works fine for me on both linux and
> windows.
>
> get latest slime here -http://common-lisp.net/project/slime/
> get latest swank-clojure (your version seems to be outdated) here 
> -http://github.com/jochu/swank-clojure/tree/master
> get lates clojure-mode here -http://github.com/jochu/clojure-mode/tree/master
>
> I hope you know where to get the latest clojure :)
>
> On Sun, Mar 8, 2009 at 5:18 AM, youngblood.carl
> wrote:
>
>
>
> > Howdy all,
>
> > I'm brand new to this scene (where scene means lisp, closure, linux,
> > and emacs), so apologies if this has been addressed. My goal is to
> > make sure I'm up to date before moving forward.
>
> > I set up my emacs/slime development environment like various tutorials
> > suggested, except I received the following errors:
>
> >  *inferior-lisp* 
> > (require 'swank.swank)
>
> > (swank.swank/ignore-protocol-version "2009-03-07")
>
> > (swank.swank/start-server "/tmp/slime.30640" :encoding "iso-latin-1-
> > unix")
>
> > Clojure
> > user=> nil
> > user=> java.lang.Exception: Unable to resolve symbol: lazy-seq in this
> > context (core.clj:70)
> > user=> java.lang.Exception: No such var: swank.swank/ignore-protocol-
> > version (NO_SOURCE_FILE:5)
> > user=> java.lang.Exception: No such var: swank.swank/start-server
> > (NO_SOURCE_FILE:7)
> >  
>
> > I found another post mentioning that a change had been made to clojure
> > which was not backwards compatible with slime. Looking at the clojure
> > api and the above error, it was pretty clear that the culprit is the
> > fun lazy-seq no longer exists.
>
> > I replaced the following code based on what was available in the
> > current clojure api, and what the old code seemed to be doing:
>
> >  core.clj 
> > (defn exception-causes [#^Throwable t]
> >  (lazy-seq
> >    (cons t (when-let [cause (.getCause t)]
> >              (exception-causes cause)
>
> >  => replaced with =>
>
> > (defn exception-causes [#^Throwable t]
> >  (lazy-cons t (when-let [cause (.getCause t)]
> >                 (exception-causes cause
> >  
>
> > Now my slime process starts without errors and successfully connects
> > to the swank server, which no longer bombs from trying to use lazy-
> > seq.
>
> > My concern is my fix above is just coding by coincidence; I don't
> > really understand what is happening beyond the list comprehension and
> > I'm worried that I'm missing something important because it seems like
> > that change would have been made already in swank-clojure if it was
> > that simple.
>
> > On the other hand, if it is a valid fix, if anyone else is having this
> > problem I hope this helps.
>
> > Thanks,
> > Carl
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



swank-clojure + slime

2009-03-07 Thread youngblood.carl

Howdy all,

I'm brand new to this scene (where scene means lisp, closure, linux,
and emacs), so apologies if this has been addressed. My goal is to
make sure I'm up to date before moving forward.

I set up my emacs/slime development environment like various tutorials
suggested, except I received the following errors:

 *inferior-lisp* 
(require 'swank.swank)

(swank.swank/ignore-protocol-version "2009-03-07")

(swank.swank/start-server "/tmp/slime.30640" :encoding "iso-latin-1-
unix")

Clojure
user=> nil
user=> java.lang.Exception: Unable to resolve symbol: lazy-seq in this
context (core.clj:70)
user=> java.lang.Exception: No such var: swank.swank/ignore-protocol-
version (NO_SOURCE_FILE:5)
user=> java.lang.Exception: No such var: swank.swank/start-server
(NO_SOURCE_FILE:7)
 

I found another post mentioning that a change had been made to clojure
which was not backwards compatible with slime. Looking at the clojure
api and the above error, it was pretty clear that the culprit is the
fun lazy-seq no longer exists.

I replaced the following code based on what was available in the
current clojure api, and what the old code seemed to be doing:

 core.clj 
(defn exception-causes [#^Throwable t]
  (lazy-seq
(cons t (when-let [cause (.getCause t)]
  (exception-causes cause)

 => replaced with =>

(defn exception-causes [#^Throwable t]
  (lazy-cons t (when-let [cause (.getCause t)]
 (exception-causes cause
 

Now my slime process starts without errors and successfully connects
to the swank server, which no longer bombs from trying to use lazy-
seq.

My concern is my fix above is just coding by coincidence; I don't
really understand what is happening beyond the list comprehension and
I'm worried that I'm missing something important because it seems like
that change would have been made already in swank-clojure if it was
that simple.

On the other hand, if it is a valid fix, if anyone else is having this
problem I hope this helps.

Thanks,
Carl

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