Re: Rebinding vars at compile time

2010-03-07 Thread Konrad Hinsen

On 7 Mar 2010, at 21:03, Benjamin Teuber wrote:


Another idea would be to alter the root binding of *assert* instead. I
guess this solution would work for your own vars, but unfortunately it
is not possible to do this with *assert*:

(def *assert* false)


You cannot use def to change the value of a var in another namespace.  
This is nothing specific to *assert* or to clojure.core.


Here is what you can do instead:

(alter-var-root (var *assert*) (fn [_] false))

However, what you probably want is

(set! *assert* false)

This changes the thread-local value of *assert*, not the root binding.  
Contrary to binding, set! makes a permanent change valid for the rest  
of the thread's lifetime (or until another set!).  Changing the root  
value of *assert* affects other threads doing macro expansion in  
parallel. At the moment the Clojure compiler doesn't do parallel  
compilation, but perhaps one day it will. There could also be  
application code calling eval and thus macro expansion in another  
thread, which could fail because of your modifications to *assert*. So  
better use set!.



I guess users are not allowed to alter root bindings for vars in
clojure.core at all - but it would be better to get an exception
instead of this behaviour - I might submit a ticket for this.


An exception would indeed make sense here.


So, finally, I have come up with this:

(defmacro in-production-mode [& body]
  (binding [*assert* false]
 `(do ~@(clojure.walk/macroexpand-all body

But I feel bad about explicitly calling macroexpand - smells like
directly calling eval to me.


First of all, please don't use clojure.walk/macroexpand-all at all if  
you care about faithful macro expansion. It doesn't treat special  
forms specially, so what you get is not always equivalent to how the  
compiler expands macros.


You can use clojure.contrib.macro-utils/mexpand-all, which does treat  
special forms correctly - at the moment. It has special routines for  
special forms, which have to be kept up to date as Clojure evolves. I  
think they are correct for the 1.2 master branch, and I try to keep  
them up to date of course, but there is always the risk of a delay.


Looking at clojure.contrib.macro-utils, you will see other macros that  
do a full macro expansion of their bodies: macrolet and symbol- 
macrolet. There is no other way to do this, so I don't feel bad about  
it, but like eval this should be done only when inevitable.



- How was *assert* meant to be used?


The normal use is module-wide, by putting

(set! *assert* false)

right after the ns form. This compiles the whole namespace without  
assertions.



- Is it okay to call macroexpand-all on arbitrary code? Or can
anything bad happen if the author of that code is not aware of this
fact?


If done correctly, it should never cause trouble. Nothing in the  
language specification says when macroexpansion happens. The Clojure  
compiler could do a full expansion and then compile. I have  
substantial code using symbol-macrolet in use, but the implicit full  
macro expansion has never caused a single bug.


The undesirable side effect of full macro expansion is that it makes  
debugging more difficult. A single macroexpand-1 on your in-production- 
mode macro will do a full macro expansion, resulting in code that its  
original author might not recognize.


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: I confused myself. How can I solve this simple problem?

2010-03-07 Thread Stephen C. Gilardi
On Mar 7, 2010, at 10:57 PM, CuppoJava wrote:

> Is there an elegant solution to this problem? I'm working around it by
> saving the original println in another variable before creating
> myprintln, but this isn't very clean.

In case by another "variable", you were referring to another "var":

One relatively clean way to capture the old value is in a closure:

user=> (let [println println]
 (defn myprintln [str]
   (println str)
   (println "tacked on")))
#'user/myprintln

This doesn't work in the current head of Clojure because by default, calls to 
functions bound to vars in namespaces whose names begin with "clojure" (e.g., 
clojure.core) are inlined by the compiler. Binding the var has no effect on how 
the compiled code runs. My understanding is that this is an experimental 
optimization that Rich is trying out.

Wrapping println in a bindable wrapper (in the user namespace) proves the 
concept:

user=> (defn _println [x] (println x))
#'user/_println
user=> (let [_println _println]
 (defn myprintln [str]
   (_println str)
   (_println "tacked on")))
#'user/myprintln
user=> (binding [_println myprintln] (_println "Some code"))
Some code
tacked on
nil
user=>

--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: I confused myself. How can I solve this simple problem?

2010-03-07 Thread Phil Hagelberg
On Sun, Mar 7, 2010 at 7:57 PM, CuppoJava  wrote:
> Is there an elegant solution to this problem? I'm working around it by
> saving the original println in another variable before creating
> myprintln, but this isn't very clean.

That's what I generally do, but you could use a let instead:

(let [orig-println println]
  (defn myprintln [str]
   (orig-println str)
   (orig-println "tacked on"))

That would make it more self-contained and would also prevent
orig-println from getting rebound.

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


I confused myself. How can I solve this simple problem?

2010-03-07 Thread CuppoJava
So I just stumbled across this bug in my code, and it arose very
innocently so I wonder if anyone has an elegant solution to this
problem.

There is already a function called (println).

Now I would like to write another version of it, which just tacks some
stuff at the end of what it normally does:

(defn myprintln [str]
  (println str)
  (println "tacked on"))

And now, I would like to run some code using my version of println,
rather than the original.

(binding [println myprintln]
  (println "Some code"))

Do you see the bug?

Is there an elegant solution to this problem? I'm working around it by
saving the original println in another variable before creating
myprintln, but this isn't very clean.

Thanks for your help
  -Patrick

-- 
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: Rebinding vars at compile time

2010-03-07 Thread CuppoJava
I agree that the issue with not being to change the root value of
*assert* seems odd.

But I actually like the macroexpand-all solution. It's done at compile-
time, so performance is not a big problem, and clojure's macroexpand
resolves everything to the proper namespace anyway.

  -Patrick

-- 
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: Leiningen, Clojure and libraries: what am I missing?

2010-03-07 Thread Phil Hagelberg
On Sun, Mar 7, 2010 at 7:57 AM, Mike K  wrote:
> On Mar 4, 4:32 pm, Glen Stampoultzis  wrote:
>>
>> Getting swank-clojure going in Windows is also a pain.  To install it the
>> recommended way via ELPA you need to patch the ELPA source code first.  This
>> isn't documented at the swank-clojure site either.
>
> For others who are struggling with this issue, see the following
> thread.
>
> http://groups.google.com/group/clojure/browse_frm/thread/c4d00ba0f1614c49/3b4e04ef9fb0c8bf?lnk=gst&q=elpa+windows#3b4e04ef9fb0c8bf
>
> I ended the thread with a plea to Phil update the docs wrt this issue,
> but no movement on that front yet.

Sorry, I lost that message when I changed email clients recently. I've
applied the patch along with several others in a branch of my
package.el repository that is slated to be included in Emacs soon:

http://github.com/technomancy/package.el/tree/hax

Could you try the latest from this branch to ensure that it fixes the
issue on Windows?

thanks,
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
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: clojure slides

2010-03-07 Thread Wilson MacGyver
thank you very much, looking through it now!

On Sat, Mar 6, 2010 at 6:02 PM, Tom Hicks  wrote:
> PDF of slides from my presentation at a recent Tucson JUG:
> http://tinyurl.com/yjrnh55
> (licensed as Creative Commons Attribution-Noncommercial). If you need
> the
> Powerpoint email me.
>    regards,
>    -tom
>
> On Mar 3, 8:58 pm, Wilson MacGyver  wrote:
>> Looks like I'll be doing a talk on clojure next week at the local java
>> user group.
>>
>> Any recommendations on slides I can steal? :)
>>
>> --
>> Omnem crede diem tibi diluxisse supremum.
>
> --
> 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



-- 
Omnem crede diem tibi diluxisse supremum.

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


Defn-memo doesn't work for recursive functions

2010-03-07 Thread André Ferreira
;Simple example
(defn fib1 [n]
  (if (or (= 0 n) (= 1 n))
1
(+ (fib1 (- n 1))
  (fib1 (- n 2)

(defn-memo fib2 [n]
  (if (or (= 0 n) (= 1 n))
1
(+ (fib2 (- n 1))
  (fib2 (- n 2)

;workaround for this problem
(declare aux-fib)
(defn-memo fib3 [n]
  (if (or (= 0 n) (= 1 n))
1
(+ (aux-fib (- n 1))
  (aux-fib (- n 2)
(def aux-fib fib3)

(time (fib1 35))
"Elapsed time: 4729.9318 msecs"
14930352
=> (time (fib2 35))
"Elapsed time: 4727.70348 msecs"
14930352
=> (time (fib3 35))
"Elapsed time: 0.875 msecs"
14930352


The recursive call inside fib2 is not memoized because of the way
Clojure expands defn, adding the function name to the generated fn.
So, how to rewrite defn-memo so that fib2 behaves like fib3? It would
be much easier to make defn stop adding the function name to the fn,
but that makes normal recursive functions a little slower, and would
change the behaviour if dynamic scoping was being used in a program.
The problem is that if you change defn-memo so that it doesn't use
defn, you lose all of defn goodness or have to reproduce all of defn's
work inside of defn-memo. Memoization of recursive functions is very
useful, with problems that are normally solved with dynamic program
becoming much simpler and functional when used. Any idea on how to
rewrite defn-memo so that it does the right thing?

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


Re: clojure slides

2010-03-07 Thread Baishampayan Ghose
> Re: Emacs + Slime + paredit. I did not see Clojure listed as supported
> for Slime and paredit. Do you know if:
>
> - AquaEmacs (mac) is a shoe-in?

Works with Carbon Emacs on the Mac. Should work with AquaEmacs too.

> - Can you do all Slime stuff in Clojure? evaluate, macro-expand, docs,
> etc?
> - Same for par-edit

Macro-expand, evaluation, M-. etc. all work like a charm. The debugger
is not as advanced as in CL, but does the job fine. I use Clojure +
SLIME + Paredit daily and it's a charm.

Regards,
BG

-- 
Baishampayan Ghose 
oCricket.com
http://oCricket.com

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


Rebinding vars at compile time

2010-03-07 Thread Benjamin Teuber
Hi!

Yesterday on IRC some of us were struggling with the usage of
dynamically rebound vars inside macros which led to interesting
compile vs run time issues. I've got some questions for the experts at
the very bottom of this post - but before I'd like to explai this
issue for the less experienced macrologists amongst us =)

Let's start with the definition of assert in clojure.core:

(defmacro assert
  "Evaluates expr and throws an exception if it does not evaluate to
 logical true."
  [x]
  (when *assert*
`(when-not ~x
   (throw (new AssertionError (str "Assert failed: " (pr-str
'~x)))

This way setting *assert* to false makes (assert anything) expand to
nil and thus gets rid of all assert statements. This might be useful
to speed up stable but time-critical code in "production mode" without
having to manually remove all assertments. Similar behaviour might be
interesting for debugging output.

So lets say we want to have a macro in-production-mode which used
*assert* to "turn off" assert statements:

(in-production-mode (assert nil))
=> nil

But how can we define this macro? My first idea would have been this:

(defmacro in-production-mode [& body]
   `(binding [*assert* false]
  ~...@body))

But this does not work - the inner assert is still being expanded -
thus giving an exception when used for the example above. This is due
to the difference between compile time and run time in Lisps. That is,
the inner assert is already being macroexpanded at compile time while
the binding only happens at run time when it's too late:

compile time:

(in-production-mode (assert false))
=>
(binding [*assert* false]
   (assert nil))
=> *assert* still true
here
(binding [*assert* false]
  (when-not nil
 (throw ...)))

So we want to make the rebinding happen during compilation. How about
that:

(defmacro in-production-mode [& body]
   (binding [*assert* false]
  `(do ~...@body)))

Doesn't work either - let's look at the steps again:

compile time:

(in-production-mode (assert false))
=>   *assert* false at this point
(do (assert nil))
=>   *assert* true again - we are no
longer in the scope of the call toin-production-mode
(do (when-not nil
   (throw ...)))

Another idea would be to alter the root binding of *assert* instead. I
guess this solution would work for your own vars, but unfortunately it
is not possible to do this with *assert*:

(def *assert* false)

*assert*
=> true

I guess users are not allowed to alter root bindings for vars in
clojure.core at all - but it would be better to get an exception
instead of this behaviour - I might submit a ticket for this.

So, finally, I have come up with this:

(defmacro in-production-mode [& body]
   (binding [*assert* false]
  `(do ~@(clojure.walk/macroexpand-all body

But I feel bad about explicitly calling macroexpand - smells like
directly calling eval to me.
So my questions are:

- Is there a better way to define in-production-mode?
- How was *assert* meant to be used?
- Is it okay to call macroexpand-all on arbitrary code? Or can
anything bad happen if the author of that code is not aware of this
fact?

Cheers and thanks for your answers,
Benjamin

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


building clojure from scratch

2010-03-07 Thread cageface
Takes 15 seconds on my i7 laptop. Gotta love 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


jrclj: library for calling clojure from JRuby

2010-03-07 Thread Kyle R. Burton
Hello,

We've been using Clojure and JRuby on a project at work.  For that
project we've got libraries we implemented in clojure and an
application in JRuby - so that we can call the clojure libraries from
the JRuby code I wrote a library, JRClj, to make api easier to deal
with.  The project is installable via jgem, and is on github here:

 http://github.com/kyleburton/jrclj

The JRuby code then looks like this:

  clj = JRClj.new "clojure.contrib.str-utils"
  puts clj.str_join ":", [1,2,3]
  # prints '1:2:3'

I know cross JVM language invocation has come up on the list before so
I thought the list would be interested in the library.

Best Regards,

Kyle Burton

-- 
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: enclojure install killed netbeans 6.8

2010-03-07 Thread Mark Nutter
On Fri, Mar 5, 2010 at 11:34 PM, strattonbrazil
 wrote:
> Has anyone had problems with netbeans starting with the enclojure
> alpha?  I restarted my session and it died.  Now when I try to run
> netbeans, it throws a classpath exception.  Can I remove this plugin
> or am I missing something in my install?

First of all, do you have the JavaSE module installed and activated in
NetBeans? That's a piece that will definitely crash your IDE if you
try running Clojure without it.

If you need to uninstall the plugin in order to reinstall everything,
and if you're under Linux, look in the .netbeans directory in your
home directory for any file containing '*cloj*' and I think you'll see
pretty quickly where the plugin files are.

$ find ~/.netbeans -name '*cloj*' -print

Not sure where the Windows equivalents live, but if you need help with
that let me know and I can find out.

Mark

-- 
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: Leiningen, Clojure and libraries: what am I missing?

2010-03-07 Thread Mark Nutter
On Sun, Mar 7, 2010 at 10:40 AM, Meikel Brandmeyer  wrote:

> So your point boils down to emacs and lein don't work on Windows. I
> don't know about emacs, but at least for leiningen there is some
> activity at that front (cf. Rob's response).
>
> So I still think: if you have trouble with clojure and Windows, you are
> probably using the wrong tools.

I wrestled with trying to set up emacs and clojure under Windows, but
quickly gave up on trying to do it all by hand and just downloaded
Clojure Box (http://clojure.bighugh.com/), which was about as painless
as I could hope for. I'm still getting my toes wet in Clojure, though,
and have only used it for trying out quick ideas and doing little
quickie tutorial type problems, so I can't say how well it would work
for more industrial-sized projects.

Mark

-- 
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: REPL in a browser

2010-03-07 Thread Angel Java Lopez
There is a Clojure REPL in a browser implementation I know:

http://lotrepls.appspot.com/

Project home
http://code.google.com/p/lotrepls/

They support

   - beanshell *
   - clojure
   - groovy *
   - javascript *
   - python *
   - ruby *
   - scala *
   - scheme

using Google App Engine as backend

Angel "Java" Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

On Sun, Mar 7, 2010 at 7:18 AM, Jozef Wagner  wrote:

> Hi,
>
> I'm wondering how hard it would be to make a clojure REPL accessible
> from a browser. Something like at http://www.simplyscala.com/
>
> Some approaches I have thought of:
> a) Java Applet
> Downsides: need to have Java 1.6 enabled in a browser, less cool
> visual presentation :)
> Upsides (for some): Running locally on a client
>
> b) REPL on a server with javascript frontend
> UI would be handled with the javascript and the client would send
> inputs to the REPL sitting on the server.
> Downsides: Bigger load on the server, needs to secure the underlying
> JVM, so the users cannot access everything through the REPL.
>
> c) Clojurescript (running clojure REPL on top of the javascript)
> Is it even possible? Don't know what is the state of the
> clojurescript. This approach could be implemented so that REPL would
> run either on a client or on the server I think
>
> Any thoughts?
>
> Best,
> JW
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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

Re: Leiningen, Clojure and libraries: what am I missing?

2010-03-07 Thread Mike K
Is anyone familiar with running Maven (and possibly Polygot Maven) on
Windows?  Does it pretty much work as expected?  The learning curve
for Maven looks steeper than for Leiningen, but if it makes up for it
with better documentation and being better-behaved, then it may be
worth it.

   Mike

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


REPL in a browser

2010-03-07 Thread Jozef Wagner
Hi,

I'm wondering how hard it would be to make a clojure REPL accessible
from a browser. Something like at http://www.simplyscala.com/

Some approaches I have thought of:
a) Java Applet
Downsides: need to have Java 1.6 enabled in a browser, less cool
visual presentation :)
Upsides (for some): Running locally on a client

b) REPL on a server with javascript frontend
UI would be handled with the javascript and the client would send
inputs to the REPL sitting on the server.
Downsides: Bigger load on the server, needs to secure the underlying
JVM, so the users cannot access everything through the REPL.

c) Clojurescript (running clojure REPL on top of the javascript)
Is it even possible? Don't know what is the state of the
clojurescript. This approach could be implemented so that REPL would
run either on a client or on the server I think

Any thoughts?

Best,
JW

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


Meta for method definitions

2010-03-07 Thread Terje Norderhaug
What is a good way to get the :file and :line meta information for a  
method?


Getting this meta information for a multi is straight forward:

(meta #'clojure.core/print-method) =>
{:ns #, :name print-method, :file "clojure/ 
core.clj", :line 2314, :tag clojure.lang.MultiFn}


But what about getting this meta information for a method? Such as  
the result from a call to get-method:


(get-method clojure.core/print-method 1)

Calling meta on the result returns nil, even if this is true:

(instance? clojure.lang.IMeta (get-method clojure.core/print-method 1))

-- Terje Norderhaug
  te...@in-progress.com




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


Re: clojure slides

2010-03-07 Thread Sophie
Re: Emacs + Slime + paredit. I did not see Clojure listed as supported
for Slime and paredit. Do you know if:

- AquaEmacs (mac) is a shoe-in?
- Can you do all Slime stuff in Clojure? evaluate, macro-expand, docs,
etc?
- Same for par-edit

Thanks!

On Mar 4, 1:56 pm, Baishampayan Ghose  wrote:
> Wilson MacGyver wrote:
> > Looks like I'll be doing a talk on clojure next week at the local java
> > user group.
>
> > Any recommendations on slides I can steal? :)
>
> Feel free to use mine 
> -http://www.slideshare.net/zaph0d/introduction-to-clojure
>
> Regards,
> BG
>
> --
> Baishampayan Ghose 
> oCricket.com

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


Re: Leiningen, Clojure and libraries: what am I missing?

2010-03-07 Thread Mike K
On Mar 4, 4:32 pm, Glen Stampoultzis  wrote:
>
> Getting swank-clojure going in Windows is also a pain.  To install it the
> recommended way via ELPA you need to patch the ELPA source code first.  This
> isn't documented at the swank-clojure site either.

For others who are struggling with this issue, see the following
thread.

http://groups.google.com/group/clojure/browse_frm/thread/c4d00ba0f1614c49/3b4e04ef9fb0c8bf?lnk=gst&q=elpa+windows#3b4e04ef9fb0c8bf

I ended the thread with a plea to Phil update the docs wrt this issue,
but no movement on that front yet.

   Mike

-- 
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: Leiningen, Clojure and libraries: what am I missing?

2010-03-07 Thread Meikel Brandmeyer
Hi,

On Mon, Mar 08, 2010 at 01:44:44AM +1100, Glen Stampoultzis wrote:

> It seems (from my limited observations) that most of the Clojure developers
> are Linux/Mac people so it's understandable that Windows isn't currently as
> well supported by all tools.

Windows has a fairly big share, I think. There are a lot of posts (blog,
group, pm, IRC, ...) where the classpath starts with C:\Clojure.

My setup was just an example. I gave it because I use it actively, so I
could also answer specific questions. Laurent gave a broader view on the
tool landscape.

So your point boils down to emacs and lein don't work on Windows. I
don't know about emacs, but at least for leiningen there is some
activity at that front (cf. Rob's response).

So I still think: if you have trouble with clojure and Windows, you are
probably using the wrong tools.

Sincerely
Meikel

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


Re: Leiningen, Clojure and libraries: what am I missing?

2010-03-07 Thread Glen Stampoultzis
On 5 March 2010 17:22, Meikel Brandmeyer  wrote:

> Hi,
>
> On Mar 5, 1:03 am, Felix Breuer  wrote:
>
> > I agree that Windows is a second class citizen as far as clojure
> > tools go.
>
> Oh please stop that. I have a stable setup of Gradle + Clojuresque +
> VimClojure on Windows. Granted setting up VimClojure on Windows is
> tricky due to Vim and Windows specifics, but it's doable. However the
> Gradle + Clojuresque part is as easy and trivial as it can get. And
> this setup survived already a few updates of the different components
> without blowing up a single time. I type "gradle runServer" in the
> morning and get a running Jetty/Nailgun combination for dynamic
> development with VimClojure - without thinking a single time about the
> classpath. Which actually consists of several checked out other
> projects (enlive, ring, fleetdb, ...). They were modified non-
> intrusively to use clojuresque instead of maven/ant/lein/whatever as
> build system. It checks the interdependencies and rebuilds the
> required jars if necessary. A change in a dependency is immediately
> picked up. If necessary, I can fix a known-to-work version in my local
> repository with a few commands.
>
> All without virtualbox, VMWare or whatever. So if one tool doesn't
> fill your need, then choose another.
>
> I apologise for sounding a little harsh.
>
>
Hi Meikel, sorry if my email came off as being a bit critical but I'm not
sure what I said was necessarily inaccurate - perhaps a little unhelpful.
 It seems (from my limited observations) that most of the Clojure developers
are Linux/Mac people so it's understandable that Windows isn't currently as
well supported by all tools.  That is meant more as a general observation
than a criticism.

My own problems getting emacs set up were more of an issue with ELPA than
Clojure-Swank in particular.  The Lein setup is a known shortcoming
currently that hopefully will be corrected at some point.  I hope so because
it seems to be becoming a standard in the community.  If my Clojure improves
maybe Windows support is something I can take a look at myself.

-- 
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: Default value for structure

2010-03-07 Thread Manfred Lotz
On Sun, 7 Mar 2010 12:35:27 +0800
Mike Mazur  wrote:

> Hi,
> 
> On Sat, Mar 6, 2010 at 20:36, Manfred Lotz 
> wrote:
> > Now I tried a different way:
> >
> > (defstruct st :a :b)
> >
> > (defn my-struct-map [s & inits]
> >  (let [sm (struct-map s inits)]
> >    (if (= nil (sm :b))
> >      (assoc sm :b 0.0)
> >      sm))
> >  )
> >
> > Unfortunately, the part sm (struct-map s inits) doesn't work. I
> > have no idea what is wrong with my code.
> 
> The problem is with the inits argument passed to struct-map. Your
> method will pass a sequence. For instance, if you invoke
> (my-struct-map st :a 1 :b 2), struct-map is invoked like this:
> (struct-map st (:a 1 :b 2)).
> 

Oh yes, I was not aware of this, although it is pretty logical.

> I didn't know how to fix this myself, but nteon on the IRC helped out
> and pointed me to apply. So, this definition now works for me:
> 
> (defn my-struct-map [s & inits]
>   (let [sm (apply struct-map s inits)]
> (if (= nil (sm :b))
>   (assoc sm :b 0.0)
>   sm)))
> 

Yep, helped.

-- 
Thanks,
Manfred


-- 
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: Default value for structure

2010-03-07 Thread b2m
Hi,

depending on your application you might use defnk (http://
richhickey.github.com/clojure-contrib/def-api.html#clojure.contrib.def/
defnk) to build your struct with default values.

Benjamin

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