Re: Jython Interoperability problem

2010-11-09 Thread Rasmus Svensson
2010/10/29 Dilvan dil...@gmail.com:
   Any clues?

I don't know much about how Jython works, but from the stack trace it
seems like Clojure cannot load its source files from the classpath.
Are there other ways to add jars to the classpath in Jython?

// raek

-- 
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: Jython Interoperability problem

2010-11-09 Thread Rasmus Svensson
It seems like this is a class loader issue... The guys working on
clojure-ant-tasks seems to have hit the same problem:

https://github.com/jmcconnell/clojure-ant-tasks/issues#issue/5/comment/223478

I also found these two issues:

http://dev.clojure.org/jira/browse/CLJ-260

http://dev.clojure.org/jira/browse/CLJ-379

It seems like it should be possible to make a workaround, but
unfortunately I don't have any experience at all with how class
loaders work. So I'm afraid I'm out of advice...

// raek

-- 
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: could clojure be androids joker card

2010-11-09 Thread faenvie
hi aaron,

what i initially thought of, is an alternate technologie-stack. that's
far from being a realistic option today and may not be realistic
at all:

(i guess this has a timeframe of 4-8 years)

leave java completely out. base clojure on android's/linux's
process- and memory-model and low level system-services.
let the clojure-compiler produce performance-optimized bytecode
(dalvik executables/dex-files).

preconditions:

- implementing clojure in clojure (- java-independant clojure)

- implement higher level android services and apis (java-packages
android.*)
in clojure (- java-independant android)

realistic or not ... the implementation of clojure in clojure offers
fascinating possibilities ... and it's a task that is worked on -
today.

have a successful time

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


- related error in clojure 1.2

2010-11-09 Thread Carlos Moscoso
user= (- {:a 1} (keyword a))

java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot
be cast to java.lang.String (NO_SOURCE_FILE:0)

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


macroexpand

2010-11-09 Thread Kenan Hneide
Hello,

I am very new to Clojure, so please bear with me.  I was reading
Programming Clojure and while reading about Macros, (specifically
Symbol Capture) I had the following question, could it be possible to
expand the macro into an anonymous function and evaluate that? For
example:

(defmacro bench [expr] `(let [start# (System/nanoTime)
result# ~expr] {:result result# :elapsed (- (System/nanoTime)
start#)}))

would be expanded as :

(macroexpand-1 '(bench f))

(clojure.core/let [start__154__auto__ (System/nanoTime)
result__155__auto__ f] {:result result__155__auto__, :elapsed
(clojure.core/- (System/nanoTime) start__154__auto__)})

instead, couldn't it be expanded to

((fn[f] (clojure.core/let [start (System/nanoTime) result f] {:result
result, :elapsed (clojure.core/- (System/nanoTime) start)}))  f)

My thinking is that the anonymous function would protect the scope of
the let bindings inside of it which will make something like :

(let [start 0] (bench f)) run correctly without capturing the start
from the higher let binding.  I would like to know if this would work,
and if not, why.  The only thing I can see this helping with is
removing the need for result# syntax, and the compiler keeping track
of unique symbols in the same scope

Thanks,
-Kenan

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


macro debugger

2010-11-09 Thread Sunil S Nandihalli
Hello everybody,
 Today I just googled for macro-debugger and found the following ...
http://docs.racket-lang.org/macro-debugger/index.html

I have not completely explored it yet .. however, I was wondering if there
is something similar for clojure.. is it possible to develop one?

Thanks,
Sunil.

-- 
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: How to rewrite code to avoid bashing transients in-place?

2010-11-09 Thread Chris Perkins
On Nov 8, 4:45 pm, Greg g...@kinostudios.com wrote:

 I must say it would be really nice if this was considered kosher.. as it does 
 work just fine. It would also be useful to know why transient bashing is 
 frowned upon.


It's not that it's frowned upon - it simply doesn't work. Functions
that operate on transients (conj!, assoc!, etc) return the modified
data-structure, just like their non-transient counterparts. It just so
happens that due to an implementation detail, they sometimes return
the same instance, modified in-place, that you passed to them. The key
word there is sometimes - you can't count on that behavior. If you
have been working with small collections, and bashing in-place is
working for you, you've just been lucky. Your luck will not last ;)

- Chris

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

2010-11-09 Thread nicolas.o...@gmail.com
If you want that, you don't need macro.

(defn bench [f]
  (let [start ...
result (f)] ; note the call to f
 ))

But you would have to call it with:

(bench #(expr)) or (bench (fn [] expr))

You cannot do it directly because it would evaluate expr before the
call to bench.

This one of the usual use of macros: altering evaluation order.
(bench, or, and)

Somehow, I think both are useful

(defn bench-fn [f])

(defmacro bench [expr] `(bench-fn ~expr))

-- 
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: - related error in clojure 1.2

2010-11-09 Thread Sunil S Nandihalli
Hi carlos ..
try the following it will work..
(- {:a 1} ((keyword a)))

clojure needs to know that it needs to coerce the keyword to a function ..
that is why your original thing won't work..
Sunil.


On Tue, Nov 9, 2010 at 5:23 PM, Carlos Moscoso moscoso@gmail.comwrote:

 user= (- {:a 1} (keyword a))

 java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot
 be cast to java.lang.String (NO_SOURCE_FILE:0)

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@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: ANN: slice (a web library for writing and composing snippets of html, css, and js that are written in Clojure)

2010-11-09 Thread Patrik Hedman
Nice work, looks great.

Cheers,
Patrik

2010/11/9 Scott Jaderholm jaderh...@gmail.com

 Slice is an experimental not-production-ready web library for writing and
 composing snippets of html, css, and js that are written in Clojure.

 The motivation is that I wanted the html, css, and js for a slice of a
 webpage to be next to each other in the source, not in three separate files,
 and that I wanted these slices to be functions that could be composed. The
 hope is that this will lead to higher-level widgetish code.

 See https://github.com/scottjad/slice for an overview and
 https://github.com/scottjad/slice/blob/master/src/slice/example.clj for an
 example.

 And yes, I realize designers would hate this. Target is solo developers.

 Feedback welcome.

 Some of you may have seen an old version (https://gist.github.com/518689)
 several months ago that used it's own scoping rules and lots of macros. This
 is a complete rewrite.

 Cheers,
 Scott

  --
 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.comclojure%2bunsubscr...@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: macroexpand

2010-11-09 Thread nicolas.o...@gmail.com
Last point: on very fast bench, the time of a function call is not negligeable.

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

2010-11-09 Thread nicolas.o...@gmail.com
Sorry. Last line should read:


(defmacro bench [expr] `(bench-fn (fn [] ~expr)))

On Tue, Nov 9, 2010 at 1:06 PM, nicolas.o...@gmail.com
nicolas.o...@gmail.com wrote:
 If you want that, you don't need macro.

 (defn bench [f]
  (let [start ...
        result (f)] ; note the call to f
     ))

 But you would have to call it with:

 (bench #(expr)) or (bench (fn [] expr))

 You cannot do it directly because it would evaluate expr before the
 call to bench.

 This one of the usual use of macros: altering evaluation order.
 (bench, or, and)

 Somehow, I think both are useful

 (defn bench-fn [f])

 (defmacro bench [expr] `(bench-fn ~expr))




-- 
Sent from an IBM Model M, 15 August 1989.

-- 
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: - related error in clojure 1.2

2010-11-09 Thread Sunil S Nandihalli
thanks rasmus.. I was completely off on reasoning .
Sunil.

On Tue, Nov 9, 2010 at 6:58 PM, Rasmus Svensson r...@lysator.liu.se wrote:

 2010/11/9 Carlos Moscoso moscoso@gmail.com:
  user= (- {:a 1} (keyword a))

 - is simply a code rewrite macro. You can use macroexpand-1 to see
 how the rewrite is done:

 user= (macroexpand-1 '(- {:a 1} (keyword a)))
 (keyword {:a 1} a)

 As Sunil said, you can get the desired behaviour by adding parentheses:

 user= (macroexpand-1 '(- {:a 1} ((keyword a
 ((keyword a) {:a 1})

 In this simple case, a simple get would be sufficient:

 user= (get {:a 1} (keyword a))
 1

 ...but I guess the code you posted was only the minimal case to
 reproduce the error.

 Sometimes, get-in can also be an alternative to -.

 // raek

 --
 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.comclojure%2bunsubscr...@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: - related error in clojure 1.2

2010-11-09 Thread Rasmus Svensson
2010/11/9 Carlos Moscoso moscoso@gmail.com:
 user= (- {:a 1} (keyword a))

- is simply a code rewrite macro. You can use macroexpand-1 to see
how the rewrite is done:

user= (macroexpand-1 '(- {:a 1} (keyword a)))
(keyword {:a 1} a)

As Sunil said, you can get the desired behaviour by adding parentheses:

user= (macroexpand-1 '(- {:a 1} ((keyword a
((keyword a) {:a 1})

In this simple case, a simple get would be sufficient:

user= (get {:a 1} (keyword a))
1

...but I guess the code you posted was only the minimal case to
reproduce the error.

Sometimes, get-in can also be an alternative to -.

// raek

-- 
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: macro debugger

2010-11-09 Thread Moritz Ulrich
I don't think there's a full-featured macro debugger for clojure, but
clojure has two simple functions called macroexpand and macroexpand-1:

user (doc macroexpand-1 )
-
clojure.core/macroexpand-1
([form])
  If form represents a macro form, returns its expansion,
  else returns form.


On Tue, Nov 9, 2010 at 2:50 PM, Sunil S Nandihalli 
sunil.nandiha...@gmail.com wrote:

 Hello everybody,
  Today I just googled for macro-debugger and found the following ...
 http://docs.racket-lang.org/macro-debugger/index.html

 I have not completely explored it yet .. however, I was wondering if there
 is something similar for clojure.. is it possible to develop one?

 Thanks,
 Sunil.

 --
 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.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en




-- 
Moritz Ulrich
Programmer, Student, Almost normal Guy

http://www.google.com/profiles/ulrich.moritz
BB5F086F-C798-41D5-B742-494C1E9677E8

-- 
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: macro debugger

2010-11-09 Thread Scott Jaderholm
It's not specialized like your link, but I think you can use normal
debugging tools on macros:

(defmacro foo [a]
  (swank.core/break)
  `(list ~a))

And CDT for stepping.

Scott


On Tue, Nov 9, 2010 at 8:50 AM, Sunil S Nandihalli 
sunil.nandiha...@gmail.com wrote:

 Hello everybody,
  Today I just googled for macro-debugger and found the following ...
 http://docs.racket-lang.org/macro-debugger/index.html

 I have not completely explored it yet .. however, I was wondering if there
 is something similar for clojure.. is it possible to develop one?

 Thanks,
 Sunil.

 --
 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.comclojure%2bunsubscr...@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

Being not Lisp is a feature?

2010-11-09 Thread David Sletten
I don't want to start any language wars, but this is funny:
http://gosu-lang.org/comparison.shtml

Have all good days,
David Sletten




-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
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: Being not Lisp is a feature?

2010-11-09 Thread Laurent PETIT
this feature seems to have been specifically created to FUD over clojure :-)

2010/11/9 David Sletten da...@bosatsu.net

 I don't want to start any language wars, but this is funny:
 http://gosu-lang.org/comparison.shtml

 Have all good days,
 David Sletten




 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 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.comclojure%2bunsubscr...@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: Being not Lisp is a feature?

2010-11-09 Thread Ken Wesson
On Tue, Nov 9, 2010 at 12:08 PM, David Sletten da...@bosatsu.net wrote:
 Being not Lisp is a feature?

No, of course not.

It's a bug.

-- 
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: Being not Lisp is a feature?

2010-11-09 Thread Stefan Kamphausen


On Nov 9, 6:08 pm, David Sletten da...@bosatsu.net wrote:
 I don't want to start any language wars, but this is 
 funny:http://gosu-lang.org/comparison.shtml

Yeah, I had a good laugh this morning. ;-)

-- 
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: could clojure be androids joker card

2010-11-09 Thread Alec Battles
Andriod is not Clojure's joker card, Clojure is Andriod's joker card.

--DragonCat

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


refactoring

2010-11-09 Thread .Bill Smith
The most recent Clojure refactoring conversation I've run across is
this, from 2008:
http://groups.google.com/group/clojure/browse_thread/thread/208894ac56d15d2a/8faba94a24f19639?lnk=gstq=refactor#8faba94a24f19639.
Is anyone aware of more recent developments?

Bill Smith
Austin, TX

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

2010-11-09 Thread Laurent PETIT
Yes, tcrayford's clojure-refactoring project:
https://github.com/tcrayford/clojure-refactoring

HTH,

-- 
Laurent

2010/11/9 .Bill Smith william.m.sm...@gmail.com

 The most recent Clojure refactoring conversation I've run across is
 this, from 2008:

 http://groups.google.com/group/clojure/browse_thread/thread/208894ac56d15d2a/8faba94a24f19639?lnk=gstq=refactor#8faba94a24f19639
 .
 Is anyone aware of more recent developments?

 Bill Smith
 Austin, TX

 --
 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.comclojure%2bunsubscr...@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

Clojure vs. serial ports

2010-11-09 Thread Mike Meyer
I'm working on a clojure web app that manipulates the serial
port. Well, uses it, anyway. The basic structure is to create a map
from web-visible names to devices accessible via the serial ports. The
problem is that Clojure and the serial port drivers don't seem to get
along very well.

I'm using the RXTX package (with class names in the gnu.io. hierarchy).

If I open the serial port as part of building up my maps, everything
works fine in testing, but trying to compile the uberwar hangs.

If I wrap the port opening and connection calls in a delay and then
force them when I actually need to use it, the first call fails to do
anything - seems like the .open returns before the port is actually
ready.

Similarly, if I restructure things to open the port before use and
close it afterward, nothing ever happens at all. It's been a while
since I tried this, and I thought at the time the problem was that I
was closing the port to soon; but looking at it now I see that the
open may be failing.

When I try running multiple actions through the port in a loop, only
the first one actually happens.

Yes, I realize only the first of these is really related to Clojure
per se, but figured I'd put them all out on the chance that anyone who
could help with the first one is probably familiar enough with the
RXTX or serial port IO in Java to help with all of them.

 Thanks,
 mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O ascii ribbon campaign - stop html mail - www.asciiribbon.org

-- 
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: macro debugger

2010-11-09 Thread Stuart Campbell
On 10 November 2010 02:50, Moritz Ulrich ulrich.mor...@googlemail.comwrote:

 I don't think there's a full-featured macro debugger for clojure, but
 clojure has two simple functions called macroexpand and macroexpand-1:

 user (doc macroexpand-1 )
 -
 clojure.core/macroexpand-1
 ([form])
   If form represents a macro form, returns its expansion,
   else returns form.


There are some handy SLIME key bindings that can be useful when exploring a
source file:

   - C-c RET - (macroexpand-1) form at point
   - C-c M-m - (macroexpand) form at point

Regards,
Stuart

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
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: macroexpand

2010-11-09 Thread Alan
Clojure is not javascript: scopes provided by functions aren't any
better than those created by let:

(let [start 1]
  (let [start 2]
(println start))
  (println start))

prints 2 1 as you'd expect. You *can* write a macro that will expand
this way, and most of the time it's not a problem since clojure's
variables are immutable - mucking with the inner start won't affect
the outer start. However, the number of times you *should* do this
must be less than 1% of all macros, because there are subtle ways that
it can cause problems. The safety provided by ` fully qualifying
symbols is well worth typing an extra # every now and then.

If you still want to see how to do this, then (a) search recent Group
posts; someone asked this a few days ago, and (b) make sure you
understand why you're doing it.

Good luck, and enjoy Clojure!

On Nov 9, 12:46 am, Kenan Hneide kenan.hne...@gmail.com wrote:
 Hello,

 I am very new to Clojure, so please bear with me.  I was reading
 Programming Clojure and while reading about Macros, (specifically
 Symbol Capture) I had the following question, could it be possible to
 expand the macro into an anonymous function and evaluate that? For
 example:

 (defmacro bench [expr] `(let [start# (System/nanoTime)
 result# ~expr] {:result result# :elapsed (- (System/nanoTime)
 start#)}))

 would be expanded as :

 (macroexpand-1 '(bench f))

 (clojure.core/let [start__154__auto__ (System/nanoTime)
 result__155__auto__ f] {:result result__155__auto__, :elapsed
 (clojure.core/- (System/nanoTime) start__154__auto__)})

 instead, couldn't it be expanded to

 ((fn[f] (clojure.core/let [start (System/nanoTime) result f] {:result
 result, :elapsed (clojure.core/- (System/nanoTime) start)}))  f)

 My thinking is that the anonymous function would protect the scope of
 the let bindings inside of it which will make something like :

 (let [start 0] (bench f)) run correctly without capturing the start
 from the higher let binding.  I would like to know if this would work,
 and if not, why.  The only thing I can see this helping with is
 removing the need for result# syntax, and the compiler keeping track
 of unique symbols in the same scope

 Thanks,
 -Kenan

-- 
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: Jython Interoperability problem

2010-11-09 Thread Dilvan
On Nov 1, 9:24 pm, Mikhail Kryshen mikh...@kryshen.net wrote:
 Clojure's data structures modified for use outside of 
 Clojure:http://github.com/krukow/clj-ds

 Persistent analogue of the Java Collections 
 Framework:http://code.google.com/p/pcollections/

   These libraries only cover persistent collections (lists,
hashtables, etc). I am also using clojure.lang.Ref class (to implement
STMs).
   Are there any libraries that implement clojure.lang.Ref outside
Clojure? Or does anyone knows how to bootstrap Clojure before
creating any object from a persistent collection class? Ref objects
seem to be working without any need for a bootstrap.

--
Dilvan Moreira
http://java.icmc.usp.brdil...@icmc.usp.br

-- 
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 vs. serial ports

2010-11-09 Thread lprefontaine
Hi,

Make sure none of your serial I/O calls are executing while compiling...
If you have anything like global defs that indirectly try to do an I/O
it will get executed as part of the AOT.

I have been playing with AOT a lot in the last two months and got trapped
a couple of time with this. Your code works well when loaded dynamically,
most of your environment setups being ready, after all you expect to run
your app. Then you try to package it and lein stalls...

I got trapped with Spring the first time, it  was trying to load its context at
compile time and connect to a database. Bad idea :)))

Luc P.

Mike Meyer mwm-keyword-googlegroups.620...@mired.org wrote ..
 I'm working on a clojure web app that manipulates the serial
 port. Well, uses it, anyway. The basic structure is to create a map
 from web-visible names to devices accessible via the serial ports. The
 problem is that Clojure and the serial port drivers don't seem to get
 along very well.
 
 I'm using the RXTX package (with class names in the gnu.io. hierarchy).
 
 If I open the serial port as part of building up my maps, everything
 works fine in testing, but trying to compile the uberwar hangs.
 
 If I wrap the port opening and connection calls in a delay and then
 force them when I actually need to use it, the first call fails to do
 anything - seems like the .open returns before the port is actually
 ready.
 
 Similarly, if I restructure things to open the port before use and
 close it afterward, nothing ever happens at all. It's been a while
 since I tried this, and I thought at the time the problem was that I
 was closing the port to soon; but looking at it now I see that the
 open may be failing.
 
 When I try running multiple actions through the port in a loop, only
 the first one actually happens.
 
 Yes, I realize only the first of these is really related to Clojure
 per se, but figured I'd put them all out on the chance that anyone who
 could help with the first one is probably familiar enough with the
 RXTX or serial port IO in Java to help with all of them.
 
  Thanks,
  mike
 -- 
 Mike Meyer m...@mired.org   http://www.mired.org/consulting.html
 Independent Network/Unix/Perforce consultant, email for more information.
 
 O ascii ribbon campaign - stop html mail - www.asciiribbon.org
 
 -- 
 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: How to rewrite code to avoid bashing transients in-place?

2010-11-09 Thread Greg
Ken,

Holy crap. Thank you for this wonderful message.

My apologies for taking a while to respond, but your email has somewhat 
disarmed me. I'm very impressed with your knowledge of math, and I felt at once 
eager to read and understand your email and was taken aback by it, as my math 
skills are a bit rusty unfortunately (a fact I'm not proud of).

 As I said, one wheel makes a and b increase by one mod 3 and the other
 makes b and c increase. Mod is linear -- if a mod 3 cycles by 1, (a +
 b) mod 3 goes up by 1. So each wheel increases b by one, and increases
 exactly one of a and c, so (a + c) mod 3 increases by 1. Since both
 were zero and every move increases both by one (modulo 3), they stay
 equal.


Thanks, that does indeed make it clearer, but I'm still impressed that you saw 
this. I guess you've had more experience with this sort of reasoning than I, 
but still, very well done sir!

 Or you can visualize a 3x3x3 cube [...] Those moves in various combinations 
 give you a
 tilted plane inside the cube that amounts to 9 of its 27 cells. (2 2
 1) happens to be in one of the other two planes of 9 cells at that
 angle.


Indeed, a nice way of visualizing the situation, but one that is far from my 
way of thinking. I guess I really should probably dust off my copy of 
Princeton's Companion to Mathematics... not enough time unfortunately. :-\

 Or you can resort to linear algebra and note right away that you have
 a vector space over Z_3 and two vectors, (1 1 0) and (0 1 1), which
 will span a planar subspace. Their cross product (1 -1 1) should be
 perpendicular.

I see that is true as well... Nicely done sir! :-D

 Or you can resort to group theory...

I am a bit grateful (though still curios) that you chose not to expand on this 
one, as my knowledge of mathematics doesn't extend to group theory, and I 
barely escaped your other examples with my ego intact! :-p

Cheers!

- Greg

On Nov 8, 2010, at 8:20 PM, Ken Wesson wrote:

 On Mon, Nov 8, 2010 at 10:58 PM, Greg g...@kinostudios.com wrote:
 On Nov 8, 2010, at 7:49 PM, Greg wrote:
 So I'm unclear on what 3 (mod 3) means...
 
 I may have answered my own question, let me know:
 
6 = 3 (mod 3)
 
 That means that *both* sides are modulo 3, in which case 0 = 0.
 
 Whereas,
 
(a + c) = 3 != 2 (mod 3)
 
 Makes sense because:
 
0 != 2
 
 Yes; x and y are equal mod 3 if (= (rem x 3) (rem y 3)).
 
 If so, then now the only thing is I'm not sure how you saw that the wheels 
 satisfied that equation in the first place...
 
 As I said, one wheel makes a and b increase by one mod 3 and the other
 makes b and c increase. Mod is linear -- if a mod 3 cycles by 1, (a +
 b) mod 3 goes up by 1. So each wheel increases b by one, and increases
 exactly one of a and c, so (a + c) mod 3 increases by 1. Since both
 were zero and every move increases both by one (modulo 3), they stay
 equal.
 
 Or you can visualize a 3x3x3 cube where the three numbers are x, y, z
 coordinates. You have a starting position in one corner and one move
 goes diagonally parallel to one face and the other goes diagonally
 parallel to the other. Those moves in various combinations give you a
 tilted plane inside the cube that amounts to 9 of its 27 cells. (2 2
 1) happens to be in one of the other two planes of 9 cells at that
 angle.
 
 Or you can resort to linear algebra and note right away that you have
 a vector space over Z_3 and two vectors, (1 1 0) and (0 1 1), which
 will span a planar subspace. Their cross product (1 -1 1) should be
 perpendicular. Projecting (2 2 1) onto that vector is a simple matter
 of a dot product, which comes out to 1, showing that (2 2 1) does not
 lie in the span of those vectors. Since the initial state (3 3 3) = (0
 0 0) (mod 3) is the origin and is in that plane, the target (2 2 1)
 isn't reachable from there using any of those moves in any
 combination.
 (Note that (1 -1 1) dot (a b c) = (a + c - b) which goes right back to
 the invariant of (a + c) mod 3 = b mod 3; that invariant is really
 the dot product with (1 -1 1) must be 0 in disguise.)
 
 Or you can resort to group theory...
 
 -- 
 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: How to rewrite code to avoid bashing transients in-place?

2010-11-09 Thread Greg
 I remember that I simply gave up and assumed that there were no such
 sequence. I admire your systematic approach to this!

Thanks! And it turns out that I was a bit mistaken!

Simon messaged me off-list to let me know that in fact that code is actually 
enterable at that location, but I was just not use the machinery properly... 
(won't go into details as I don't want to spoil it for anyone who happens to be 
playing the game).

- Greg

On Nov 8, 2010, at 10:59 PM, Rasmus Svensson wrote:

 2010/11/9 Greg g...@kinostudios.com:
 I think to answer both questions I should explain the context of this
 problem.
 I'm currently in the process of learning Clojure, and as an ex cerise to
 assist in this endeavor I set about solving a problem presented in the
 classic game called Myst.
 
 One of my favorite games!
 
 I can assuredly inform you all that this
 whole business is a red herring! There is no possible way to obtain 2,2,1
 from any series of left or right turns if you're starting at 3,3,3!
 So don't bother wasting your time trying it. It's a code for something else.
 Clojure tells me so. :-p
 - Greg
 
 I remember that I simply gave up and assumed that there were no such
 sequence. I admire your systematic approach to this!
 
 A red herring indeed, as in many of the puzzles in the Myst games...
 On your request, I could give you a very tiny hint. (I won't reveal
 any details in this mail, in case you prefer to solve it on your own.)
 
 // raek
 
 -- 
 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: How to rewrite code to avoid bashing transients in-place?

2010-11-09 Thread Greg
On Nov 9, 2010, at 4:24 AM, Chris Perkins wrote:
 The key word there is sometimes - you can't count on that behavior. If you
 have been working with small collections, and bashing in-place is
 working for you, you've just been lucky. Your luck will not last ;)

Thanks Chris for that info! Will keep this in mind for the future. :-)

- Greg

 On Nov 8, 4:45 pm, Greg g...@kinostudios.com wrote:
 
 I must say it would be really nice if this was considered kosher.. as it 
 does work just fine. It would also be useful to know why transient bashing 
 is frowned upon.
 
 
 It's not that it's frowned upon - it simply doesn't work. Functions
 that operate on transients (conj!, assoc!, etc) return the modified
 data-structure, just like their non-transient counterparts. It just so
 happens that due to an implementation detail, they sometimes return
 the same instance, modified in-place, that you passed to them. The key
 word there is sometimes - you can't count on that behavior. If you
 have been working with small collections, and bashing in-place is
 working for you, you've just been lucky. Your luck will not last ;)
 
 - Chris
 
 -- 
 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: How to rewrite code to avoid bashing transients in-place?

2010-11-09 Thread Ken Wesson
On Tue, Nov 9, 2010 at 7:25 PM, Greg g...@kinostudios.com wrote:
 I remember that I simply gave up and assumed that there were no such
 sequence. I admire your systematic approach to this!

 Thanks! And it turns out that I was a bit mistaken!

 Simon messaged me off-list to let me know that in fact that code is actually 
 enterable at that location, but I was just not use the machinery properly... 
 (won't go into details as I don't want to spoil it for anyone who happens to 
 be playing the game).

No spoiler here, just a bit of reasoning: as it happens, *any*
operation on the numbers other than the two already available is
likely to make (2 2 1) reachable. (And any that doesn't is redundant
with the two operations you mentioned previously -- this follows from
the vector space representation of the problem, as the operation
becomes addition of a vector that, since (1 1 0) and (0 1 1) span a
hyperplane, must either lie in that span or extend {(1 1 0), (0 1 1)}
to a basis. The latter makes (2 2 1) reachable and the former makes
the new operation equivalent to performing some sequence composed of
the original two moves.)

In particular, if a third operation exists that bumps any single
number in isolation OR bumps all three OR bumps the first and the
third, (2 2 1) becomes reachable. (All three operations cycle (a - b +
c) modulo 3, so move out of that hyperplane -- changing only one of a,
b, and c by 1 changes (a - b + c) either up or down by 1, whereas
increasing all three by 1 increases a + c twice as much as it
decreases -b, and so increases (a - b + c) by one.

Back to the vector space: with the (1 1 0) and (0 1 1) moves, any
state y is reachable from x if and only if y dot (1 -1 1) = x dot (1
-1 1) (same hyperplane parallel to the one through the origin those
vectors span); (a - b + c) is just (a b c) dot (1 -1 1). In fact you
can compute this for other (linearly independent) pairs of moves; if
the moves (represented as vectors) are p and q then y is reachable
from x with them if and only if y dot (p x q) = x dot (p x q).

So if you encounter any other puzzles in Myst that seem similar, it
may be that the same math can be used to analyze them.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
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: Being not Lisp is a feature?

2010-11-09 Thread Santosh Rajan
The negative of a feature is also considered a feature by people who
don't get it. ;-)

On Tue, Nov 9, 2010 at 10:38 PM, David Sletten da...@bosatsu.net wrote:
 I don't want to start any language wars, but this is funny:
 http://gosu-lang.org/comparison.shtml

 Have all good days,
 David Sletten




 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 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



-- 
http://hi.im/santosh

-- 
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: Being not Lisp is a feature?

2010-11-09 Thread Brisance
Easy transition from Java, and Java has a checkmark.

-- 
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: ANN: slice (a web library for writing and composing snippets of html, css, and js that are written in Clojure)

2010-11-09 Thread Kyle Cordes
On Tue, Nov 9, 2010 at 1:04 AM, Scott Jaderholm jaderh...@gmail.com wrote:
 And yes, I realize designers would hate this. Target is solo developers.


I think there is a place, for teams (not only for solo developers),
for mechanisms that make it possible to write an entire many-layer
application in one language. One obvious language to attempt that with
at the moment is JavaScript (Node.js on the server, a gizmo for
writing JavaScript which writes your HTML and CSS, etc.). But Clojure
is also a possibility to achieve it, given something like slice plus a
Clojure web stack.

I like the idea of using one language across layers, because that
makes it easier to apply abstractions that cross the layers.

-- 
Kyle Cordes
http://kylecordes.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: Being not Lisp is a feature?

2010-11-09 Thread lprefontaine
Gosu - standard athlete on performance enhancing drugs (EPO, steroids, ...)
Clojure - genetically modified athlete 

A big generation gap, comparison stops here, no need to discuss details :)))

Luc P.

David Sletten da...@bosatsu.net wrote ..
 I don't want to start any language wars, but this is funny:
 http://gosu-lang.org/comparison.shtml
 
 Have all good days,
 David Sletten
 
 
 
 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 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: Being not Lisp is a feature?

2010-11-09 Thread Baishampayan Ghose
Luc,

 Gosu - standard athlete on performance enhancing drugs (EPO, steroids, ...)
 Clojure - genetically modified athlete

 A big generation gap, comparison stops here, no need to discuss details :)))

Your sense of humour never fails to amuse me; it was great meeting you
at Clojure Conj :)

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.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