Re: Multimethods derive

2009-06-08 Thread Konrad Hinsen

On 08.06.2009, at 04:26, Stuart Sierra wrote:

 If it is, it would be very useful to have something that is the
 ancestor of everything (like T in common lisp).

 This has been thought about, at least: http://clojure.org/todo
 I think the question is... what should the universal ancestor be?  For
 classes, it's java.lang.Object.  But derive allows you to create
 relationships outside the Java class hierarchy.  So for now, defining
 your own root ancestor is the way to proceed.

See also my patch that creates such a universal root type (the  
keyword :root):

http://groups.google.com/group/clojure/browse_thread/thread/ 
bc5193304c1ab2e3/77e5d53d8ccd6b10?lnk=gstq=%3Aroot#77e5d53d8ccd6b10

Of course, it is not a good idea to write code relying on an  
unofficial patch, I don't even use it myself for production code. But  
the patch illustrates that this can be done, and my tests have not  
shown any undesirable side effects.

Konrad.


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



Re: Multimethods derive

2009-06-08 Thread Peter Salvi

On Jun 8, 3:51 pm, Konrad Hinsen konrad.hin...@laposte.net wrote:

 See also my patch that creates such a universal root type [...]

Nice! That's exactly what I was thinking about

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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: VimClojure v2.1.1 is released

2009-06-08 Thread Emeka
Sure, I sent a private mail because I didn't want to increase noise in is
group. I used the mail address you left on vimclojure site to reach you.

I just learned about user.home. So I can simplify
also the .vim installation of the plugin.

Beautiful, when is it coming out?

Emeka




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



Re: What books have helped you wrap your brain around FP and Clojure?

2009-06-08 Thread dulanov

Just see http://en.wikibooks.org/wiki/Clojure_Programming/Further_Reading

On Jun 6, 3:12 pm, Robert Campbell rrc...@gmail.com wrote:
 Going beyond the language-specific Programming Clojure book, what
 other books have best helped you make the (sometimes mind-bending)
 transition from OOP thinking to FP thinking? My bookshelf is piled
 high with OOP books like Design Patterns, Domain Driven Design,
 Analysis Patterns, etc. I've recently ordered:

 - Concepts, Techniques, and Models of Computer Programming (mentioned
 on this/compojure's list)
 - Structure and Interpretation of Computer Programs (highly
 recommended on Stackoverflow, lectures posted online)

 Any others?

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



Re: VimClojure v2.1.1 is released

2009-06-08 Thread J. McConnell
On Sun, Jun 7, 2009 at 6:37 PM, Meikel Brandmeyer m...@kotka.de wrote:

 Am 07.06.2009 um 17:41 schrieb Emeka:

 And it took Meikel three weeks to make out time to talk to me.


 Huh? Did I miss something?


Meikel,

You've been incredibly open and helpful on this list and we all appreciate
it. Thanks for all you've done.

Regards,

- J.

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



Re: Why is this using reflection?

2009-06-08 Thread Chouser

On Fri, Jun 5, 2009 at 5:26 PM, tsuraantsur...@gmail.com wrote:

 I have a function to get the path out of a lucene searcher
 (documentation at
 http://lucene.apache.org/java/2_3_2/api/core/org/apache/lucene/search/IndexSearcher.html).
  The searcher has a Reader, which has a Directory.  The Directory is
 abstract, but in my case I know that it's a FSDirectory, so I declare
 fsdir, and then use its getFile and getPath.  The actual code I'm
 using is:

 (defn searcher-path [ #^IndexSearcher searcher ]
  (let [fsdir #^FSDirectory (.. searcher getIndexReader directory)
        path  #^String (.. fsdir getFile getPath) ]
    path))

 When I compile this with warn-on-reflection, I get that getField and
 getPath cannot be resolved.  Am I doing the hinting wrong somehow?  I
 do have imports in my file for IndexSearcher and FSDirectory, so I'm
 not sure what I'm missing.

I thought it might be fun to try out the new repl-utils expression-info fn on
this.

So first I had to recreate your 'import' line (you might consider including this
kind of detail next time you post a question):

  (import '(org.apache.lucene.search IndexSearcher)
  '(org.apache.lucene.store FSDirectory))

Then in order to use expression-info, I had to adjust your code to make it
a stand-alone expression that returns the value I care about.  Then I wrapped it
in a call to expression-info:

  (expression-info
'(let [#^IndexSearcher searcher nil] ; replaced 'defn' with simple 'let'
   (let [fsdir #^FSDirectory (.. searcher getIndexReader directory)
 path  #^String (.. fsdir getFile getPath)]
 path)))

This just returns 'nil', which is what I'd expect since the reflection warning
already told us the compiler doesn't know the type.  So lets cut out the parts
producing the warning:

  (expression-info
'(let [#^IndexSearcher searcher nil] ; replaced 'defn' with simple 'let'
   (let [fsdir #^FSDirectory (.. searcher getIndexReader directory)]
 fsdir)))

returns:

  {:class org.apache.lucene.store.Directory, :primitive? false}

Now this is interesting.  I thought we'd specifically told it fsdir was an
FSDirectory, but the complier seems to think it's just a Directory.  It appears
to be taking the actual return type of the directory() method over our type
hint.  I don't know if this is a feature or a bug, but perhaps we can be a bit
more insistent.  What happens if we type-hint the local directly instead of the
expression?

  (expression-info
'(let [#^IndexSearcher searcher nil] ; replaced 'defn' with simple 'let'
   (let [#^FSDirectory fsdir (.. searcher getIndexReader directory)]
 fsdir)))

returns:

  {:class org.apache.lucene.store.FSDirectory, :primitive? false}

Well, that seems to have done it.  Using that style in the original expression,
we get:

  (defn searcher-path [#^IndexSearcher searcher]
(let [#^FSDirectory fsdir (.. searcher getIndexReader directory)
  #^String  path  (.. fsdir getFile getPath)]
  path))

That compiles without reflection warnings.

Note also that hinting 'path' as 'String' doesn't really do any good when all we
do is return it:

  user= (expression-info '(searcher-path nil))
  nil

If you want to promise that 'searcher-path' will always return a String so that
the compiler can make further type deductions based on that, you need to hint
the function itself:

  (defn #^String searcher-path [#^IndexSearcher searcher]
(let [#^FSDirectory fsdir (.. searcher getIndexReader directory)]
  (.. fsdir getFile getPath)))

  user= (expression-info '(searcher-path nil))
  {:class java.lang.String, :primitive? false}

--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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Artificial Intelligence in Clojure

2009-06-08 Thread Chouser

On Sat, Jun 6, 2009 at 11:10 PM, maxsumax.su...@gmail.com wrote:

 Hi, i'd like to write some AI in clojure.

 Reading Russel  Norvig's AI: A Modern Approach, which focuses heavily
 on autonomous intelligence agents.

 Has anyone worked with these or other AI in clojure? Any libraries/git
 repos out there?

Genetic programming comes up from time to time.  I haven't
looked at anybody's work on the subject, but there's been
relevant discussions in this Google group.

 Can/should we use clojure agents to encapsulate separate interacting
 autonomous logical/rational agents?

 Finally, in which way should we organize an asynchronous simulation of
 a neural network using clojure concurrency? Are agents a good design
 idea here as well?

This sounds to me like it have many concepts in common with
cells implementations, which have been discussed in the
group several times.  I think there are a couple different
implementations that may have useful ideas for you.

--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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: What books have helped you wrap your brain around FP and Clojure?

2009-06-08 Thread Nathan Hawkins

Programming Erlang is also good. The syntax and message passing
emphasis aren't relevant to Clojure, but Erlang also uses immutable
data, and is definitely a functional language.

On Sat, 6 Jun 2009 13:12:16 +0200
Robert Campbell rrc...@gmail.com wrote:

 
 Going beyond the language-specific Programming Clojure book, what
 other books have best helped you make the (sometimes mind-bending)
 transition from OOP thinking to FP thinking? My bookshelf is piled
 high with OOP books like Design Patterns, Domain Driven Design,
 Analysis Patterns, etc. I've recently ordered:
 
 - Concepts, Techniques, and Models of Computer Programming (mentioned
 on this/compojure's list)
 - Structure and Interpretation of Computer Programs (highly
 recommended on Stackoverflow, lectures posted online)
 
 Any others?
 
  

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



Spam in file section

2009-06-08 Thread Sean Devlin

Not quite sure what the right way to report this is.  There seems to
be some spam in the file report.  The Mathis-Oberg-
Insulating_Guide.pdf seems to be out of place.  My apologies if this
is a false positive.
--~--~-~--~~~---~--~~
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 books have helped you wrap your brain around FP and Clojure?

2009-06-08 Thread Daniel Lyons


On Jun 8, 2009, at 7:24 AM, Nathan Hawkins wrote:

 The syntax and message passing emphasis aren't relevant to Clojure


I don't have any experience with agents in Clojure, but I wonder if  
they be used to similar effect? Agents seem more like data in another  
thread to me than self-recursive functions in another thread, which is  
what Erlang's processes are like, but your remark piques my curiosity.  
Can one be implemented trivially via the other?

—
Daniel Lyons
http://www.storytotell.org -- Tell It!


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



Re: Why is this using reflection?

2009-06-08 Thread tsuraan

 I thought it might be fun to try out the new repl-utils expression-info fn
 on
 this.

Is this just in source control, or is it in a release?  I'm using
1.0.0, and I don't seem to have that function.

 So first I had to recreate your 'import' line (you might consider including
 this
 kind of detail next time you post a question):

Yeah, sorry about that.  I'll remember next time.

 Well, that seems to have done it.  Using that style in the original
 expression,
 we get:

   (defn searcher-path [#^IndexSearcher searcher]
 (let [#^FSDirectory fsdir (.. searcher getIndexReader directory)
   #^String  path  (.. fsdir getFile getPath)]
   path))

 That compiles without reflection warnings.

I thought I had tried this and gotten an error for it; I must have
made a typo and assumed it was an invalid thing to do.  It's certainly
working now :)  Where can I get more info on the expression-info call?
 A google search for expression-info and clojure gives a pdf on
multiple dispatch and nothing else.

 Note also that hinting 'path' as 'String' doesn't really do any good when
 all we
 do is return it:

That's really strange.  The clojure compiler doesn't put types on
functions when the only value returned from a function has an explicit
type?

   user= (expression-info '(searcher-path nil))
   nil

 If you want to promise that 'searcher-path' will always return a String so
 that
 the compiler can make further type deductions based on that, you need to
 hint
 the function itself:

   (defn #^String searcher-path [#^IndexSearcher searcher]
 (let [#^FSDirectory fsdir (.. searcher getIndexReader directory)]
   (.. fsdir getFile getPath)))

   user= (expression-info '(searcher-path nil))
   {:class java.lang.String, :primitive? false}

In the type hinting page, it says type hits can be applied to function
parameters, let-bound names, var names and expressions.  Is the
#^String here being applied to a var name (searcher-path)?  It wasn't
obvious to me that one could do that, although I guess functions names
are variables just like any other names in the system.

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



In let: unpacking maps with accessors too

2009-06-08 Thread samppi

I'd love to be able to do this:

(defstruct person-s :name :gender)
(def name-a (accessor person-s :name))
(def gender-a (accessor person-s :gender))

(def person-1 (struct person-s Jane :female))

(let [{name name-a, gender gender-a, :as person} person-1]
  (println name gender person))

...instead of having to do this:
(let [person person-1, name (name-a person), gender (gender-a person)]
  (println name gender person))

In other words, rather than the rule being that, in a map in a let
binding, the values of symbol keys must be keywords so that the key
symbol is bound to (keyword the-map):
  (let [{name :name} person-1] ...) ; name is bound to (:name
person-1)

...I'd love it if the values of symbol keys could be any symbol, not
just keywords, so that the key symbol is bound to (val-symbol
the-map):
  (let [{name this-is-a-symbol} person-1] ...) ; name is bound to
(this-is-a-symbol person-1)

It's backwards-compatible. But is this possible? Practical?



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



Re: Why is this using reflection?

2009-06-08 Thread J. McConnell
On Mon, Jun 8, 2009 at 11:41 AM, tsuraan tsur...@gmail.com wrote:


  I thought it might be fun to try out the new repl-utils expression-info
 fn
  on
  this.

 Is this just in source control, or is it in a release?  I'm using
 1.0.0, and I don't seem to have that function.


repl-utils is a library in clojure-contrib. Docs here:

http://code.google.com/p/clojure-contrib/wiki/ReplUtilsApiDoc

Source here:

http://code.google.com/p/clojure-contrib/source/browse/trunk/src/clojure/contrib/repl_utils.clj

HTH,

- J.

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



Re: VimClojure v2.1.1 is released

2009-06-08 Thread Meikel Brandmeyer

Hi,

Am 08.06.2009 um 09:15 schrieb Emeka:

Sure, I sent a private mail because I didn't want to increase noise  
in is group. I used the mail address you left on vimclojure site to  
reach you.


Ok. I'm sorry. It must have been stuck in the spam filter.
I searched my mails, but only found the question about
Jacob and Excel.


I just learned about user.home. So I can simplify
also the .vim installation of the plugin.



Beautiful, when is it coming out?


Obviously soon... -.- I introduced more bugs than
I fixed with this release. I will iron the bigger ones
and will do a 2.1.2 soon For that I will throw
another eye on the build process.

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: In let: unpacking maps with accessors too

2009-06-08 Thread Konrad Hinsen

On Jun 8, 2009, at 17:46, samppi wrote:

 ...I'd love it if the values of symbol keys could be any symbol, not
 just keywords, so that the key symbol is bound to (val-symbol
 the-map):
   (let [{name this-is-a-symbol} person-1] ...) ; name is bound to
 (this-is-a-symbol person-1)

 It's backwards-compatible. But is this possible? Practical?

I don't think it could made to be backwards-compatible. The  
documentation states:

Map binding-forms allow you to bind names to parts of associative  
things (not just maps), like maps, vectors, string and arrays (the  
latter three have integer keys).

The current implementation of destructuring map binding forms uses get:

(destructure '[{name :name} person-1])
-  [map__268 person-1 name (clojure.core/get map__268 :name)]

This works as advertised with maps, vectors, strings, etc. Your  
proposal would change the expansion to

-  [map__268 person-1 name (:name map__268)]

That works fine if person-1 is a map, but destructuring a vector with  
a map binding form is no longer possible.


Nothing stops you from defining your own let-like macro with your own  
destructuring rules, of course!

Konrad.

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



Re: The - . nested usage

2009-06-08 Thread Stephen C. Gilardi


On Jun 8, 2009, at 12:38 PM, ronen wrote:


user= (- String. String.)
java.lang.ClassNotFoundException: String. (NO_SOURCE_FILE:7)

expanding the macros involved seems to reveal the issue:

user= (macroexpand-1 `(- String. String.))
(java.lang.String. java.lang.String.)

the . macro isn't expanded.


The trailing dot syntax is used for creating an object given a class  
name:


(String.)

creates a String object.

Nested macros work fine. What were you hoping the above expressions  
would expand to?


Here's an example of - in action:

(- (System/getProperties) (.get java.class.path) .toUpperCase (nth  
3) int (* 2))


--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: The - . nested usage

2009-06-08 Thread ronen

I see, using - with . will not create a chain of new
invocations, the best solution that iv found is:
user= (String. (String.))

user= (macroexpand (String. (String.)))

user= (macroexpand `(String. (String.)))
(new java.lang.String (java.lang.String.))

Nesting is a must :)
Thank you both for your helpful reply

On Jun 8, 10:51 pm, Kevin Downey redc...@gmail.com wrote:
 you need to pass something in.
 example:

 = (- foo String. String.)
 foo

 = (macroexpand '(- String. String.))
 (new String String.)

 = (macroexpand '(- foo String. String.))
 (new String (clojure.core/- foo String.))
 = (macroexpand '(- foo String.))
 (new String foo)

 String. is only treated as new String ...  when it is placed in the
 function position (String. ...)
  in (- String. String.) the first String. is never put in the
 function position, so effectively you get
 (String. String.)



 On Mon, Jun 8, 2009 at 12:38 PM, ronennark...@gmail.com wrote:

  Following a blog post on building large object graphs I was suggested
  with the following solution:
   (def nested-object (- GrandFather. Father. GrandSon.))

  this indeed seems to be correct however fails in even in a simple
  example:

  user= (- String. String.)
  java.lang.ClassNotFoundException: String. (NO_SOURCE_FILE:7)

  expanding the macros involved seems to reveal the issue:

  user= (macroexpand-1 `(- String. String.))
  (java.lang.String. java.lang.String.)

  the . macro isn't expanded.

  Is there a way of applying nested macros?
  (iv searched for applying nested macros with no results).

 --
 And what is good, Phaedrus,
 And what is not good—
 Need we ask anyone to tell us these things?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: The - . nested usage

2009-06-08 Thread Andrew Wagner
Just to be clear, is (String.) a macro? I thought it was just a special
form.

On Mon, Jun 8, 2009 at 3:47 PM, Stephen C. Gilardi squee...@mac.com wrote:


 On Jun 8, 2009, at 12:38 PM, ronen wrote:

 user= (- String. String.)
 java.lang.ClassNotFoundException: String. (NO_SOURCE_FILE:7)

 expanding the macros involved seems to reveal the issue:

 user= (macroexpand-1 `(- String. String.))
 (java.lang.String. java.lang.String.)

 the . macro isn't expanded.


 The trailing dot syntax is used for creating an object given a class name:

 (String.)

 creates a String object.

 Nested macros work fine. What were you hoping the above expressions would
 expand to?

 Here's an example of - in action:

 (- (System/getProperties) (.get java.class.path) .toUpperCase (nth 3)
 int (* 2))

 --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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: The - . nested usage

2009-06-08 Thread Kevin Downey

sure it can, you just need to pass in an initial value.

(- (String.) String. String.) ; works
(- x String. String.) ;works for any x where string has a constructor
that takes something of type x

for example

(- file.txt File. FileReader. BufferedReader.)

will return a buffered reader on file.txt (assuming you import those
classes from java.io)

On Mon, Jun 8, 2009 at 12:59 PM, ronennark...@gmail.com wrote:

 I see, using - with . will not create a chain of new
 invocations, the best solution that iv found is:
 user= (String. (String.))
 
 user= (macroexpand (String. (String.)))
 
 user= (macroexpand `(String. (String.)))
 (new java.lang.String (java.lang.String.))

 Nesting is a must :)
 Thank you both for your helpful reply

 On Jun 8, 10:51 pm, Kevin Downey redc...@gmail.com wrote:
 you need to pass something in.
 example:

 = (- foo String. String.)
 foo

 = (macroexpand '(- String. String.))
 (new String String.)

 = (macroexpand '(- foo String. String.))
 (new String (clojure.core/- foo String.))
 = (macroexpand '(- foo String.))
 (new String foo)

 String. is only treated as new String ...  when it is placed in the
 function position (String. ...)
  in (- String. String.) the first String. is never put in the
 function position, so effectively you get
 (String. String.)



 On Mon, Jun 8, 2009 at 12:38 PM, ronennark...@gmail.com wrote:

  Following a blog post on building large object graphs I was suggested
  with the following solution:
   (def nested-object (- GrandFather. Father. GrandSon.))

  this indeed seems to be correct however fails in even in a simple
  example:

  user= (- String. String.)
  java.lang.ClassNotFoundException: String. (NO_SOURCE_FILE:7)

  expanding the macros involved seems to reveal the issue:

  user= (macroexpand-1 `(- String. String.))
  (java.lang.String. java.lang.String.)

  the . macro isn't expanded.

  Is there a way of applying nested macros?
  (iv searched for applying nested macros with no results).

 --
 And what is good, Phaedrus,
 And what is not good—
 Need we ask anyone to tell us these things?
 




-- 
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?

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



filechooser

2009-06-08 Thread Emeka
Hello Meikel,

I have not been able to resolve this issue. As I mentioned in another
thread, I want to use filechooser to select the excel file.
My code is in this link http://friendpaste.com/wmX89ywgPhdN5hvVBEAbg

Regards,
Emeka

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



Re: The - . nested usage

2009-06-08 Thread ronen

Great! that was the missing bit i was looking for.
thanks for clearing it out

( it seems that String. is indeed a macro)

On Jun 8, 11:05 pm, Kevin Downey redc...@gmail.com wrote:
 sure it can, you just need to pass in an initial value.

 (- (String.) String. String.) ; works
 (- x String. String.) ;works for any x where string has a constructor
 that takes something of type x

 for example

 (- file.txt File. FileReader. BufferedReader.)

 will return a buffered reader on file.txt (assuming you import those
 classes from java.io)



 On Mon, Jun 8, 2009 at 12:59 PM, ronennark...@gmail.com wrote:

  I see, using - with . will not create a chain of new
  invocations, the best solution that iv found is:
  user= (String. (String.))
  
  user= (macroexpand (String. (String.)))
  
  user= (macroexpand `(String. (String.)))
  (new java.lang.String (java.lang.String.))

  Nesting is a must :)
  Thank you both for your helpful reply

  On Jun 8, 10:51 pm, Kevin Downey redc...@gmail.com wrote:
  you need to pass something in.
  example:

  = (- foo String. String.)
  foo

  = (macroexpand '(- String. String.))
  (new String String.)

  = (macroexpand '(- foo String. String.))
  (new String (clojure.core/- foo String.))
  = (macroexpand '(- foo String.))
  (new String foo)

  String. is only treated as new String ...  when it is placed in the
  function position (String. ...)
   in (- String. String.) the first String. is never put in the
  function position, so effectively you get
  (String. String.)

  On Mon, Jun 8, 2009 at 12:38 PM, ronennark...@gmail.com wrote:

   Following a blog post on building large object graphs I was suggested
   with the following solution:
    (def nested-object (- GrandFather. Father. GrandSon.))

   this indeed seems to be correct however fails in even in a simple
   example:

   user= (- String. String.)
   java.lang.ClassNotFoundException: String. (NO_SOURCE_FILE:7)

   expanding the macros involved seems to reveal the issue:

   user= (macroexpand-1 `(- String. String.))
   (java.lang.String. java.lang.String.)

   the . macro isn't expanded.

   Is there a way of applying nested macros?
   (iv searched for applying nested macros with no results).

  --
  And what is good, Phaedrus,
  And what is not good—
  Need we ask anyone to tell us these things?

 --
 And what is good, Phaedrus,
 And what is not good—
 Need we ask anyone to tell us these things?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Exception when reading large quoted form

2009-06-08 Thread Tom Hickey

Hi Jason,

I've run into the same thing. This has come up on the group before,
more info can be found here:
http://groups.google.com/group/clojure/msg/efd607d75d59088e

Cheers,
Tom

On Jun 8, 1:32 pm, Jason Wolfe jawo...@berkeley.edu wrote:
 I get an exception

 Invalid method Code length 70026 in class file user$eval__3286
   0: java.lang.ClassLoader.defineClass1(Native Method)
   1: java.lang.ClassLoader.defineClass(ClassLoader.java:675)
   2: java.lang.ClassLoader.defineClass(ClassLoader.java:520)
   3: clojure.lang.DynamicClassLoader.defineClass
 (DynamicClassLoader.java:42)
   4: clojure.lang.Compiler$FnExpr.getCompiledClass(Compiler.java:3465)
   5: clojure.lang.Compiler$FnExpr.eval(Compiler.java:3476)
   6: clojure.lang.Compiler.eval(Compiler.java:4600)
   7: clojure.core$eval__4610.invoke(core.clj:1730)
   8: swank.commands.basic$eval_region__2568.invoke(basic.clj:36)
   9: swank.commands.basic$eval__2583$listener_eval__2585.invoke
 (basic.clj:50)
  10: clojure.lang.Var.invoke(Var.java:346)
  11: user$eval__3283.invoke(NO_SOURCE_FILE)
  12: clojure.lang.Compiler.eval(Compiler.java:4601)

 by typing the following large quoted form at the REPL.

 http://paste.lisp.org/display/81543

 Removing the quote or some of the elements fixes the problem.  It
 sounds like this is something to do with a JVM method bytecode size
 limitation ... I can work around it for now, but it would be nice if
 this limitation was either documented (i.e., with a descriptive
 exception), or removed somehow.

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



Re: performance concerns (again)

2009-06-08 Thread Robert Lehr

Thanks for the replies.  This post is moderately long as it includes
responses
to most of the replies.

Before I reply to replies, I will quickly describe some add'l data
that I obtained from further tests.  I was lead to a line of
investigation by the description at the following URL:

http://www.coderanch.com/t/419739/Linux-UNIX/JVM-Memory-Linux

I executed a simpler test in Java only, one that prints a simple
Sleeping 30sec message then sleeps for 30sec.  The 30sec delay is so
that I can record the memory allocated by JVM.

* on a Windows XP laptop a 2.2GHz dual-core CPU and 2GB RAM
* on several Linux v2.6 systems w/ 8 cores of ~2.6GHz and 16GB RAM
* on several Linux v2.4 systems w/ the same configs as those w/
the v2.6 kernels

All tests were executed w/ a v6 JVM.

NOTE - Linux version numbers refer to the kernel's version.

In short, only the linux v2.6 kernels showed the exorbitant
memory-utilization that I reported previously.  On both Windows XP and
Linux v2.4, the memory allocated was on the order of MBs, not
HUNDREDS of MBs.

NOTE - in practice, I consider the 10, 11 and 12MBs that I observed to
be on the order of MBs, not TENs of MBs.

One would guess then that the overcommit feature of the Linux v2.6
kernel is causing this impression of exorbitant memory-utilization.
The question remains then whether the overcommit affects the
scalability of the JVM on Linux v2.6 systems.  IOW, for a simple
program that causes the JVM to allocate hundreds of megs of RAM on a
multi-gigabyte system, will the number of JVM instances be severely
limited?  For example, if the JVM allocates 400MB on a 16GB system, is
the total number of JVM instances limited to ~40 (16000/400 or to the
~1300 (16000/12) that I would otherwise expect.  I can explore that
indepedently and share the results here later if anyone is interested.

--- Richard Newman wrote:
rlehr Simply stated, given that it stated clearly in this group that
Clojure
rlehr runs, on average, slower than the JVM, is the JVM's high
memory-
rlehr utilization a non-issue for the Clojure community as well?

 In short: yes.


First, thanks for the info, Richard.

Interesting.  I am now left to wonder if your disposition is typical
of most JVM
developers and deployers.  I'll have to continue asking my inquiry.

 Sure, under load that will increase, but it's still negligible in the
 context of available memory (only a few percent). Additionally, in my
 experience the memory profile of Java server applications is better
 than our C++ applications, which typically experience some bloating or
 memory leak issues.

Is that a positive for Java?  Or a negative for the programmers that
wrote your C++ apps?

 I'd take steady-state 300MB memory consumption any day over a
 startup at 50MB ending up at 1.4GB after a couple of months' uptime
 (a situation I've seen with C++ server applications).

In general, I agree.  But I would need to take into account few other
variables before I made that decision for a specific application.
Consider, for an app that starts at 50MB yet has allocated 1.4GB of
leaked memory after a couple months, that application could easily
restart itself very quickly; and that's a low-cost operation.  I know
it seems like a hack.  But

 So, in short: if you're on a low-resource machine, running graphical
 Java clients: yes, the JVM's memory consumption might concern you,
 as will its startup time.

Errrm - so Java's value is limited to large systems ?  That statement
does not seem to take into account all of the small systems, including
mobile devices, that use Java.  What am I missing here?

 You're probably baffled because your definition of unacceptable is
 very different to most using Java SE/EE.  The JVM is monolithic
 (something Project Jigsaw is trying to fix, precisely to reduce
 memory usage in constrained scenarios), ...

Good point.  However, my definition of acceptable is reasonable in
the most general sense.  I am familiar w/ cost-to-benefit analysis of
the choices that designers make.  For any benefit that a system
provides, there is a limit on the cost that one is willing to pay.

When a comparable C++ progie allocates 40k, I do not consider an
initial allocation of 400MB to be acceptable for any system.  It's
wasteful enough to begin reconsidering whether the benefits of the
system in question are worth the cost.

IOW, when I see a increase of 4 orders of magnitude of attribute A in
exchange for 1 order of magnitude of improvement in attribute B, my
alarms are triggered.  I do my value calculations, start asking
questions and looking for something to kill.  In this case, the JVM
allocating 400MB instead of 40k; I expected something on the order of
MBs, not HUNDREDs of MBs.

NOTE that the above comment is a general statement and does not
reflect my observations of the v6 JVM on Windows XP and Linux v2.4.x.

 ...but it doesn't bother most people running Java services on
 2008/2009-era servers.

If my initial observations were 

Macro Design - by example

2009-06-08 Thread Meikel Brandmeyer

Dear Clojurians,

in the past there were several discussions on the list
regarding the one or the other macro. Please let me
show some design principles, which I believe are good
ideas for macro design.

On the occasion of a question in another thread we will
write a small helper macro to add an action listener to
a Swing component.

Let's start with the code we want to produce.

(.addActionListener component
  (proxy [ActionListener] []
(actionPerformed [evt] (do-something-with evt) (do-more-stuff

This should be easy to translate into a macro.

(defmacro add-action-listener
  [component  body]
  `(.addActionListener ~component
 (proxy [ActionListener] []
   (~'actionPerformed [~'evt] ~...@body

Note the ugly actionPerformed quoting. The invocation
looks like:

(add-action-listener component
  (do-something-with evt)
  (do-more-stuff))

Note that we had to capture evt to get access to
the event, which is passed to the handling code. This
means we get into trouble, when we want to access an
external evt in our handling code. This is ugly.

So we specify the name to use explicitly.

(defmacro add-action-listener
  [component evt  body]
  `(.addActionListener ~component
 (proxy [ActionListener] []
   (~'actionPerformed [~evt] ~...@body

Note the slightly different quoting of evt. Again the
invocation:

(add-action-listener component the-evt
  (do-something-with the-evt)
  (do-more-stuff))

Hurray. We have a working macro. Time for refactoring.
We should ask ourselves: Why do we actually need a macro?
Macro writing is hard and one should keep the macros as
small as possible if not avoiding them at all.

Of course one might argue: Yadda yadda. That's just a
style question. So here is another motivation.

Suppose we have some-handler-fn which we want to us in
our action listener. Using our macro this would look
like this:

(add-action-listener component the-evt
  (some-handler-fn the-evt))

Bleh. Now this is ugly and verbose. We have to think
about a name for a thing which we just immediately pass
on to a function. Why should we bother with such details?
So let's write a function for that.

(defn add-action-listener*
  [component handler]
  (.addActionListener component
(proxy [ActionListener] []
  (actionPerformed [evt] (handler evt)

Now the invocation looks like this:

(add-action-listener* component some-handler-fn)

Much more concise and to the spot. And note: in the
function we didn't have to mess around with strange
quotations. We just chose whatever name we liked for
the event argument without danger of interference.

But wait. Now we implemented the same functionality
twice. We should DRY this moisture.

As we saw, we can easily achieve the desired effect
if we have a handler function. So why not base the
macro on the function?

(defmacro add-action-listener
  [component evt  body]
  `(add-action-listener* ~component (fn [~evt] ~...@body)))

Note the trick: we created a function which takes
the given event name as argument and has body as
it's body. So the event parameter is available in
the body under the given name. The anonymous fn
is then simply passed to the star function.

Ah. More yadda yadda. I don't have handler fns!

So why would it still be a good idea to have the
macro use some driver function?

Suppose you are hunting a bug. Your suspicion is
that there is some trouble with the event handling.
So you want to log some message about the event.
You start changing the macro.

(defmacro add-action-listener
  [component evt  body]
  `(.addActionListener ~component
 (proxy [ActionListener] []
   (~'actionPerformed [~evt] (println Got event: ~evt) ~...@body

And now you can track the event passing. Eh.. well..
Not quite! First you have to recompile all your code
and restart the application. Since a macro gets
expanded at compile time, there is no way to change
the expansion afterwards.

Consider the same change to the function version.
Now all you have to do is to just reload the single
function in the running application. This can be
easily done by environments like SLIME or VimClojure.
Et voila. The next time the function is called you already
get the benefit. Without recompilation of the whole app...

So here the complete macro-function pair + invocation:

(defn add-action-listener*
  [component handler]
  (.addActionListener component
(proxy [ActionListener] []
  (actionPerformed [evt] (handler evt)

(defmacro add-action-listener
  [component evt  body]
  `(add-action-listener* ~component (fn [~evt] ~...@body)))

(add-action-listener component the-evt
  (do-something-with the-evt)
  (do-more-stuff))

(add-action-listener* component some-handler-fn)

So to summarise:

- write the code which you want in your macro
- write a macro which expands into the code with
  variable parts as macro arguments.
- extract the parts which are not required to be
  a macro as a function
- modify the macro to simply call the function


Re: VimClojure v2.1.1 is released

2009-06-08 Thread Meikel Brandmeyer

Hi,

Am 08.06.2009 um 04:35 schrieb e:

That'd be awesome. assume the user doesn't even have vim.  they just  
have jdk. ... and they only care about vim for clojure.  Well, I'd  
want to eventually integrate with svn and git, but I suppose folks  
just drop to a shell for that stuff, typically.


Ok. Here it is: http://bitbucket.org/kotarak/clojure-ball/overview/

Nothing there, yet. But I'll work on it.

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: performance concerns (again)

2009-06-08 Thread Richard Newman

 First, thanks for the info, Richard.

 Interesting.  I am now left to wonder if your disposition is typical
 of most JVM developers and deployers.  I'll have to continue asking  
 my inquiry.

I'm actually not a typical JVM developer -- I come from a Common Lisp  
background, and I avoid writing Java whenever I can -- and I'm most  
definitely not a Java fanboy. Java makes up the minority of my work.  
In fact, I've only started using it for real work in the past couple  
of years, because it happened to be the best tool for the job.

I was responding from the perspective of the times I've deployed Java  
applications, but that's not the majority of my experience.

 Sure, under load that will increase, but it's still negligible in the
 context of available memory (only a few percent). Additionally, in my
 experience the memory profile of Java server applications is better
 than our C++ applications, which typically experience some bloating  
 or
 memory leak issues.

 Is that a positive for Java?  Or a negative for the programmers that
 wrote your C++ apps?

Many of the leaks I've been privy to have been in vendors' binaries or  
in libraries, which are hard to fix!

The rest are 'common or garden' bloat, and would arise in most C++  
applications developed under the same circumstances. I certainly don't  
attribute any exceptional blame to the teams involved.

Part of the reason why GC is so fantastic is that writing truly  
correct memory handling code is actually quite hard, particularly for  
long-running applications, and getting it right is costly. I view GC  
as a good thing. I would not write any new applications in C++, and  
that's been true for several years.

Additionally, applications with GC can outperform those with malloc/ 
free-based approaches, which is fascinating.


 I'd take steady-state 300MB memory consumption any day over a
 startup at 50MB ending up at 1.4GB after a couple of months' uptime
 (a situation I've seen with C++ server applications).

 In general, I agree.  But I would need to take into account few other
 variables before I made that decision for a specific application.
 Consider, for an app that starts at 50MB yet has allocated 1.4GB of
 leaked memory after a couple months, that application could easily
 restart itself very quickly; and that's a low-cost operation.

Unless you have current sessions, and a gentle restart involves  
rerouting traffic.

(I work in a high-availability domain.)

I don't like writing bounce the server as a routine recommendation  
in an ops guide :)


 So, in short: if you're on a low-resource machine, running graphical
 Java clients: yes, the JVM's memory consumption might concern you,
 as will its startup time.

 Errrm - so Java's value is limited to large systems ?

For me, yes.

Put another way: there's no way I'd write Unix utilities in Java  
(because of the startup time). Its applicable domains for me are  
limited. Other people are much more enthusiastic about its  
applicability -- they're running Java on televisions, Blu-ray players,  
mobile handsets, VoIP desk phones, network appliances, cash registers...


 That statement
 does not seem to take into account all of the small systems, including
 mobile devices, that use Java.  What am I missing here?

There are different profiles of Java: ME, SE, EE.

Java ME is a very different beast to an enterprise (*gag*) Java  
application server.

I wouldn't use Java ME either, but that's a different story :)


 IOW, when I see a increase of 4 orders of magnitude of attribute A in
 exchange for 1 order of magnitude of improvement in attribute B, my
 alarms are triggered.  I do my value calculations, start asking
 questions and looking for something to kill.  In this case, the JVM
 allocating 400MB instead of 40k; I expected something on the order of
 MBs, not HUNDREDs of MBs.

I don't see similar measurements to you. My Nailgun server for Clojure  
development, started with -server and -Xmx512M, is at 19MB RSIZE on my  
64-bit Mac. After loading all of my code and its dependencies, that  
jumps to 37MB. After quite a bit of work, it's at 65MB. I rarely see  
it rise above 100MB. My Java app server -- actually deployed and  
handling requests -- on Solaris x86 is at 158MB RSS, which actually  
impresses me given the amount of code loaded.

Those sizes are smaller than some non-Java apps I've deployed  
recently, one of which is hovering around 500MB RSS right now.

Java memory usage no longer enters into the technology choice equation  
for me. It did a few years ago.


 ...but it doesn't bother most people running Java services on
 2008/2009-era servers.

 If my initial observations were true for all cases then I suspect that
 your comment would reflect poorly on your group of most people.
 Sorry.  :(

Indeed, which is why I think either your measurements are flawed, or  
that measuring standalone memory consumption (no matter how  
accurately) is an irrelevant metric for real-world 

Re: What books have helped you wrap your brain around FP and Clojure?

2009-06-08 Thread Daniel Jomphe

I second most of the book suggestions already mentioned (those that
I've read).

If you like reading papers, I strongly suggest you take a look at Can
Programming Be Liberated from the von Neumann Style?:
http://www.stanford.edu/class/cs242/readings/backus.pdf

This paper will help you with two things:

  1. Motivation to investigate deeper FP;
  2. Understanding many core concepts of FP.

If you read this paper, I strongly suggest you schedule some time to
read at least the first 12 pages of his lecture. The first 7 pages
will shed out more light on what’s wrong with imperative languages;
then, the next pages will explain how a language can be implemented on
top of a very small number of sound and simple concepts that can be
used and powerfully combined in all sorts of natural ways to describe
computations.

(Although it could be argued that some of this paper's ideas go even
further than our current FP languages do, they won't hinder your
understanding at all.)

If you'd like to read about Backus' contribution to our field, I think
these are the best links:

  http://en.wikipedia.org/wiki/John_Backus
  http://theory.stanford.edu/~aiken/other/backus.pdf
  http://www-03.ibm.com/ibm/history/exhibits/builders/builders_backus.html

Another paper which helped me understand FP in relation with maths is
Recursion Equations As A Programming Language. Last time I checked
(Jan.), this paper was still not freely available on the web; but you
can read most of its message through Google Books. It's a much easier
read than Backus, but less complete; nonetheless, it's really, really
highly recommended because it's complementary.

Next, I've seen the following mentioned in quite a few places, and I
think the general opinion is that it's also high-quality stuff. I'm
yet to read it. Why Functional Programming Matters:

  http://www.cs.chalmers.se/~rjmh/Papers/whyfp.html

Now, one might argue these papers' goal is more to introduce/motivate
FP over traditional imperative programming. I would oppose to this
that in order to back FP, these papers need to explain FP in very
powerful terms for people; thus, they are great reads for the problem
at hand.



On Jun 8, 11:10 am, Daniel Lyons fus...@storytotell.org wrote:
 On Jun 8, 2009, at 7:24 AM, Nathan Hawkins wrote:

  The syntax and message passing emphasis aren't relevant to Clojure

 I don't have any experience with agents in Clojure, but I wonder if  
 they be used to similar effect? Agents seem more like data in another  
 thread to me than self-recursive functions in another thread, which is  
 what Erlang's processes are like, but your remark piques my curiosity.  
 Can one be implemented trivially via the other?

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



Re: In let: unpacking maps with accessors too

2009-06-08 Thread joshua-choi

Oh, I didn't know that. It makes me wonder, then, why integers were
not implemented as functions of sequential collections: (3
[:a :b :c]).

Ah, well. I guess since let can't be changed, it's then a choice
between using accessors or being more elegant. Thanks for the reply.

On Jun 8, 9:25 am, Konrad Hinsen konrad.hin...@laposte.net wrote:
 On Jun 8, 2009, at 17:46, samppi wrote:

  ...I'd love it if the values of symbol keys could be any symbol, not
  just keywords, so that the key symbol is bound to (val-symbol
  the-map):
    (let [{name this-is-a-symbol} person-1] ...) ; name is bound to
  (this-is-a-symbol person-1)

  It's backwards-compatible. But is this possible? Practical?

 I don't think it could made to be backwards-compatible. The  
 documentation states:

         Map binding-forms allow you to bind names to parts of associative  
 things (not just maps), like maps, vectors, string and arrays (the  
 latter three have integer keys).

 The current implementation of destructuring map binding forms uses get:

         (destructure '[{name :name} person-1])
 -   [map__268 person-1 name (clojure.core/get map__268 :name)]

 This works as advertised with maps, vectors, strings, etc. Your  
 proposal would change the expansion to

 -   [map__268 person-1 name (:name map__268)]

 That works fine if person-1 is a map, but destructuring a vector with  
 a map binding form is no longer possible.

 Nothing stops you from defining your own let-like macro with your own  
 destructuring rules, of course!

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



SWT (Cocoa) from Aquamacs+SLIME?

2009-06-08 Thread Gert Verhoog

Hi everyone,

I've started playing with SWT + Clojure (I know very little about SWT  
and I've just started out with Clojure, so please bear with me) and I  
would like to get it going from within Aquamacs Emacs + SLIME. I'm not  
sure if this is a real Clojure question or more of a Cocoa/Carbon  
specific thing, but since many are using Aquamacs Emacs as a Clojure  
IDE someone may have already seen this.

I'm using Java 1.6 and I've built swt.jar from Eclipe CVS, using  
org.eclipse.swt.cocoa.macosx.x86_64 for the platform specific stuff.

I'm trying a very simple Hello World which runs fine when started from  
a terminal REPL, but from Aquamacs Emacs, it creates an empty window  
(it does't even draw the window borders) and then it just hangs (as if  
the event processing loop never starts). My *inferior-lisp* buffer  
spews a lot of complaints about no autorelease pool being present,  
like this one:

2009-06-09 08:32:01.844 java[4010:20a03] *** _NSAutoreleaseNoPool():  
Object 0x1001b1120 of class NSCFArray autoreleased with no pool in  
place - just leaking

Is it possible at all to run SWT Cocoa from Aquamacs+SLIME?



This is my script, cobbled together from bits and pieces I found online:

(ns main
   (:import (org.eclipse.swt.widgets Display Shell Label)
(org.eclipse.swt SWT)))

(defn swt-loop [display shell]
   (loop []
 (if (.isDisposed shell)
   (.dispose display)
  (do
 (if (not (.readAndDispatch display))
   (.sleep display))
 (recur)

(defn do-it []
   (let [d (Display.)]
 (let [s (Shell. d)]
   (doto (Label. s SWT/CENTER)
 (.setText Hello World!)
 (.setBounds (.getClientArea s)))
   (.open s)
   (swt-loop s d

(do-it)

And here's a command that's equivalent to what I run as a clojure- 
swank-binary:

java -cp clojure-1.0.0.jar:clojure-contrib.jar:swt.jar -server -d64 \
-XstartOnFirstThread -Xdebug \
-Xrunjdwp:transport=dt_socket,server=y,suspend=n clojure.main


Many thanks!
gert



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



Thoughts on bags?

2009-06-08 Thread Richard Newman

The relational operations work on sets. That's often useful, but there  
are situations in which preserving cardinality is more useful. One  
such situation bit me today -- I did some relational operations on  
some spreadsheet-esque data, much as I would in SQL or SPARQL, finally  
projecting to the two columns I cared about before adding up some  
numbers.

The numbers didn't total correctly. A few minutes of reading my code  
narrowed it down to the projection, which of course outputs a set,  
discarding some of my inputs.

Has there been any thinking about supporting a 'bag' sibling of 'set',  
and allowing it to be passed correctly through the relational  
operators? Right now I have a choice between rephrasing my code in non- 
relational terms, or adding a unique value to each item to thwart the  
distinctness semantics. I can't help but think that other people will  
also encounter this.

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



Re: Thoughts on bags?

2009-06-08 Thread Sean Devlin

I think I know what you mean by a bag, but I'm not quite sure.  How
does a bag compare to a set, vector and/or list?

On Jun 9, 1:31 am, Richard Newman holyg...@gmail.com wrote:
 The relational operations work on sets. That's often useful, but there  
 are situations in which preserving cardinality is more useful. One  
 such situation bit me today -- I did some relational operations on  
 some spreadsheet-esque data, much as I would in SQL or SPARQL, finally  
 projecting to the two columns I cared about before adding up some  
 numbers.

 The numbers didn't total correctly. A few minutes of reading my code  
 narrowed it down to the projection, which of course outputs a set,  
 discarding some of my inputs.

 Has there been any thinking about supporting a 'bag' sibling of 'set',  
 and allowing it to be passed correctly through the relational  
 operators? Right now I have a choice between rephrasing my code in non-
 relational terms, or adding a unique value to each item to thwart the  
 distinctness semantics. I can't help but think that other people will  
 also encounter this.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Thoughts on bags?

2009-06-08 Thread Richard Newman

 I think I know what you mean by a bag, but I'm not quite sure.  How
 does a bag compare to a set, vector and/or list?

A bag is also known as a multiset: it's an unordered collection in  
which an item can appear more than once. Think of a set without the  
distinctness.

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