Re: "Getting Started" is NOT starting for me...

2008-09-20 Thread Christopher Taylor

btw, showMessageDialog being a static method, isn't the preferred syntax

(javax.swing.JOptionPane/showMessageDialog nil "Hello World!")

both versions work here (standard OSX Java).

$ java -version
java version "1.5.0_13"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13- 
b05-237)
Java HotSpot(TM) Client VM (build 1.5.0_13-119, mixed mode, sharing)

   --Chris

On 19.09.2008, at 19:25, cliffc wrote:

>
> I downloaded clojure to my pc. I tried the "Getting Started" page:
>
>  user=> (+ 1 2 3)
>  6
>
> Worked great...  next step:
>
>  user=> (. javax.swing.JOptionPane (showMessageDialog nil "Hello
> World"))
>
> This hangs for me; the java process is idle.  No output, no dialog box
> or GUI.  I'm using HotSpot 1.6.0_07 -client.
>
> Thanks,
> Cliff
> >


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



default parameters question

2008-09-20 Thread AlamedaMike

Consider:

user=> (defn foo [ {:keys [a b] :or {c 5}} ]
 (list a b))
#'user/foo

Note that the key of the default entry for "c" is not in the formal
parameter list.

user=> (foo 7)
(nil nil)
user=> (foo {:a 3 :b 4})
(3 4)
user=> (foo {:a 3 :c 4})
(3 nil)

The second is of course correct. The last form's behaviour seems
reasonable, assuming that the defn will not be flagged as a compiler
error due to a mismatch with the list of formal parameters.

The first seems troublesome under any set of assumptions I can come up
with. I would expect either a map parameter (for use with param names)
or a two actual parameters (to bind by position with the formal params
in the [a b] list, in case I didn't want to use the named params).
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



packaging App (cross-platform) without scripts, only jar

2008-09-20 Thread Pascal

I needed a single jar file that if you double clicked
on it (be in Mac OS X or Windows) it will just launch
my Clojure App.

No CLASSPATH or bash or anything, cross platform.

I didn't found anything like these so I just made it
(I know it's not difficult, let say this is for Newbie!)

The archi is:
  - one App on directory: Let say Blop/
  - inside one jar: Launcher.jar (double click to start)
  - and 2 directories:
- clj/ : with your clojure sources, the entry point must be
  named: main.clj
- jar/ : with your needed jar, including:  clojure.jar

Look for the "Launcher.jar" file in this Google group.
Here is the source:
(note: Inspired freely from clojure.lang.Script  java class)


import java.io.OutputStreamWriter;
import java.io.IOException;

import clojure.lang.RT;
import clojure.lang.Compiler;


public class Launcher {
public static void main(String[] args) throws Exception {
try {
RT.processCommandLine(args);// must do that...
Compiler.loadFile("clj/main.clj");

} finally {
OutputStreamWriter w = (OutputStreamWriter) 
RT.OUT.get();
try {
w.flush();
w.close();
} catch(IOException e) {
e.printStackTrace();
}
} // try
} // main
}

The Manifest must add:

Main-Class: Launcher
Class-Path: jar/clojure.jar



As an example I zipped the "Ant" example from Rich Hickey
(only made small modification at the end so that it start right away),
with the lastest (20080916) Clojure.jar .
Look for the "Ant_App.zip" file in this Google group.

Am I re-inventing the wheel ?
Brgds.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Suggest two argument "into-array" with explicit type

2008-09-20 Thread Stephen C. Gilardi

I needed an empty array of Strings to pass to a Java function. The  
first place I considered was "into-array", but without an array  
element to work with, it returns an array of Object.

I suggest that into-array be extended to allow a second argument that  
gives the type of the elements in the destination array explicitly.  
This would be useful for the case I'm after (an empty array), but also  
in general if one has a seq of objects compatible with a destination  
type, but where the first item in the seq may or may not be exactly  
that type.

Proposed doc:
-
clojure/into-array
([aseq] [aseq type])
  Returns a typed array containing the contents of aseq. If type
  is not provided, it defaults to the class of the first item in aseq.
  All items in aseq must be of a class compatible with the
  destination type.

Pending that proposed change, I came up with this:

(java.lang.reflect.Array/newInstance String 0)

--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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Suggest two argument "into-array" with explicit type

2008-09-20 Thread Rich Hickey



On Sep 20, 11:04 am, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
> I needed an empty array of Strings to pass to a Java function. The
> first place I considered was "into-array", but without an array
> element to work with, it returns an array of Object.
>
> I suggest that into-array be extended to allow a second argument that
> gives the type of the elements in the destination array explicitly.
> This would be useful for the case I'm after (an empty array), but also
> in general if one has a seq of objects compatible with a destination
> type, but where the first item in the seq may or may not be exactly
> that type.
>
> Proposed doc:
> -
> clojure/into-array
> ([aseq] [aseq type])
>   Returns a typed array containing the contents of aseq. If type
>   is not provided, it defaults to the class of the first item in aseq.
>   All items in aseq must be of a class compatible with the
>   destination type.
>
> Pending that proposed change, I came up with this:
>
> (java.lang.reflect.Array/newInstance String 0)
>

Hmm.. there is already make-array for the latter:

(make-array String 0)

find-doc is your friend :)

As far as into-array taking a type, I'm fine with that, but the type
should come first.

Rich

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: packaging App (cross-platform) without scripts, only jar

2008-09-20 Thread budu

Thanks a lot! It's funny that you wrote this post now because I was
about to try to figure it out myself this week-end.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Suggest two argument "into-array" with explicit type

2008-09-20 Thread Stuart Sierra

On Sep 20, 11:16 am, Rich Hickey <[EMAIL PROTECTED]> wrote:
> As far as into-array taking a type, I'm fine with that, but the type
> should come first.

That would be useful when you need to create an array of an abstract
type, like an interface.  I posted a version here:
http://groups.google.com/group/clojure/msg/1c02773d070decd5

-Stuart
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: "Star-Vars" for the repl to provide recent values, shorten error messages

2008-09-20 Thread Mike Hinchey

I added support for *1 *2 *3 in my fork of swank-clojure (for emacs/
slime), http://github.com/mikehinchey/swank-clojure.

I did one thing different which is to not reset the vars if the eval
is one of the vars themselves.  Rich noted most CL repls don't do
this, but it seems useful to me.  Thoughts?

user> :a
:a
user> :b
:b
user> :c
:c
user> *1
:c
user> *2
:b
user> *3
:a
user> (list *1 *2 *3)
(:c :b :a)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Cells in Clojure

2008-09-20 Thread kyle smith

Maybe you could attach a cell to a JComponent and call setEnabled as
necessary.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: "Star-Vars" for the repl to provide recent values, shorten error messages

2008-09-20 Thread Stephen C. Gilardi
On Sep 20, 2008, at 7:27 PM, Mike Hinchey wrote:

> I added support for *1 *2 *3 in my fork of swank-clojure (for emacs/
> slime), http://github.com/mikehinchey/swank-clojure.


I'm glad to see this support in swank-clojure. Thanks!

> I did one thing different which is to not reset the vars if the eval
> is one of the vars themselves.  Rich noted most CL repls don't do
> this, but it seems useful to me.  Thoughts?

I think it's good idea. It does seem a shame to lose one of these  
values as a result of looking at one. I had considered it, but didn't  
see how to implement it reasonably. Having been shown the way on that  
(thanks!) I'm in favor.

Other thoughts?

--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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Suggest two argument "into-array" with explicit type

2008-09-20 Thread Stephen C. Gilardi
On Sep 20, 2008, at 11:16 AM, Rich Hickey wrote:Hmm.. there is already make-array for the latter:(make-array String 0)find-doc is your friend :)Cool, thanks. I had looked up "array", but hadn't looked carefully at all that it returned.As far as into-array taking a type, I'm fine with that, but the typeshould come first.I've attached a patch. If it gets dropped, I'll upload it as "into-array-type.patch" to the group.Thanks,--Steve


into-array-type.patch
Description: Binary data



Re: Suggest two argument "into-array" with explicit type

2008-09-20 Thread Stephen C. Gilardi

On Sep 20, 2008, at 1:37 PM, Stuart Sierra wrote:

> That would be useful when you need to create an array of an abstract
> type, like an interface.  I posted a version here:
> http://groups.google.com/group/clojure/msg/1c02773d070decd5

It's good to see another use case. Not surprisingly, the Clojure code  
looks remarkably similar to the Java code in my proposed patch. :)

Thanks,

--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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Cells in Clojure

2008-09-20 Thread Stuart Sierra
Exactly.  Here's some demo code, attached, that uses a cell in a
JPanel.  This is a simple example, but maybe it shows how this could
be useful when you have many objects with complex dependencies.
-Stuart

On Sep 20, 7:54 pm, kyle smith <[EMAIL PROTECTED]> wrote:
> Maybe you could attach a cell to a JComponent and call setEnabled as
> necessary.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



square_demo.clj
Description: Binary data


Re: "Getting Started" is NOT starting for me...

2008-09-20 Thread cliffc

A little more info: failed on Windows XP, SP3.
Worked great for me on Linux.

Cliff


On Sep 20, 5:54 am, Christopher Taylor <[EMAIL PROTECTED]> wrote:
> btw, showMessageDialog being a static method, isn't the preferred syntax
>
> (javax.swing.JOptionPane/showMessageDialog nil "Hello World!")
>
> both versions work here (standard OSX Java).
>
> $ java -version
> java version "1.5.0_13"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-
> b05-237)
> Java HotSpot(TM) Client VM (build 1.5.0_13-119, mixed mode, sharing)
>
>    --Chris
>
> On 19.09.2008, at 19:25, cliffc wrote:
>
>
>
> > I downloaded clojure to my pc. I tried the "Getting Started" page:
>
> >  user=> (+ 1 2 3)
> >  6
>
> > Worked great...  next step:
>
> >  user=> (. javax.swing.JOptionPane (showMessageDialog nil "Hello
> > World"))
>
> > This hangs for me; the java process is idle.  No output, no dialog box
> > or GUI.  I'm using HotSpot 1.6.0_07 -client.
>
> > Thanks,
> > Cliff
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---