Re: abysmal multicore performance, especially on AMD processors

2012-12-24 Thread cameron
I've been moving house for the last week or so but I'll also give the 
benchmark another look.
My initial profiling seemed to show that the parallel version was spending 
a significant amount of time in java.lang.isArray,
clojush.pushstate/stack-ref is calling nth on the result of cons, since it 
isn't an instance of clojure.lang.Indexed nth resorts to a series of tests 
before returning the value (including isArray).

I changed clojush.pushstate/push-item implementation to
   (assoc state type (vec (cons value (type state ;; vec added to 
ensure result is indexable

This slowed down my single threaded version a bit but improved my parallel 
speedup from 2x to 3x on an 8 physical core machine. We could easily 
improve this by replacing the cons with conj and updating the code that 
pops the state or by implementing a more efficient indexable stack with 
deftype.

After the change above clojush.interpreter/execute_instruction is looking 
like a hotspot with clojure.lang.ArraySeq creation  seeming to spend more 
time in java.lang.Class.getComponentType() in the parallel version than the 
serial one.

Cameron.

-- 
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: EOF when executing lein trampoline cljsbuild repl-listen

2012-12-24 Thread David Powell
I can confirm the same problem


On Sun, Dec 23, 2012 at 11:30 PM, Mark  wrote:

> Hi,
> I'm trying to make my way through the modern-cljs tutorials and running
> into a blocker:  I'm on tutorial 2 (
> https://github.com/magomimmo/modern-cljs/blob/master/doc/tutorial-02.md?.mdown)
> and when I try lein trampoline cljsbuild repl-listen, I get
>
> Exception in thread "main" clojure.lang.LispReader$ReaderException:
> java.lang.RuntimeException: EOF while reading, starting at line 1
> at clojure.lang.LispReader.read(LispReader.java:215)
> at clojure.core$read.invoke(core.clj:3346)
> at clojure.core$read.invoke(core.clj:3344)
> at clojure.main$eval_opt.invoke(main.clj:295)
> at clojure.main$initialize.invoke(main.clj:316)
> at clojure.main$script_opt.invoke(main.clj:340)
> at clojure.main$main.doInvoke(main.clj:427)
> at clojure.lang.RestFn.invoke(RestFn.java:930)
> at clojure.lang.Var.invoke(Var.java:460)
> at clojure.lang.AFn.applyToHelper(AFn.java:235)
> at clojure.lang.Var.applyTo(Var.java:532)
> at clojure.main.main(main.java:37)
> Caused by: java.lang.RuntimeException: EOF while reading, starting at line
> 1
> at clojure.lang.Util.runtimeException(Util.java:170)
> at clojure.lang.LispReader.readDelimitedList(LispReader.java:1117)
> at clojure.lang.LispReader$ListReader.invoke(LispReader.java:962)
> at clojure.lang.LispReader.read(LispReader.java:180)
> ... 11 more
>
> I figure the reader is trying to load the project.clj but I'm executing
> from the project's root directory.  I'm using lein 2.0 preview 10 on a
> Windows 7 machine if that matters.
>
>
>  --
> 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

Call namespace's functions from a record

2012-12-24 Thread Christian Sperandio
Hi,

I'm testing the use of records in Clojure and I have some issues when I try 
to call function of another namespaces from the record.

For testing purposes, I defined this record:

(ns test-record.component
  (:use test-record.utils))

(defprotocol Hierarchical
  "Protocol for tree."
  (children? [node] "children?"))

(defrecord Component [parent children name]
  Hierarchical
  (children? [node] (an-utils-function node)))

And I declared this namespace:

(ns test-record.utils)

(defn an-utils-function
  [c]
  (println (:name c)))

Very simple, isn't it?

But when I run this code in a REPL, I get an exception:

user=> (import 'test_record.component.Component)
test_record.component.Component
user=> (def c (Component. nil [] "The Root"))
#'user/c
user=>  (.children? c)
IllegalStateException Attempting to call unbound fn: 
#'test-record.utils/an-utils-function  clojure.lang.Var$Unbound.throwArity 
(Var.java:43)


Can I use functions of another namespaces from a record's code?

Thanks.



-- 
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: Call namespace's functions from a record

2012-12-24 Thread Jim - FooBar();
Lose the "." - call children? like this: (children? c) and make sure you 
can see the test-record.component namespace from your user ns (apart 
from importing the record class).


HTH,

Jim

On 24/12/12 11:55, Christian Sperandio wrote:

Hi,

I'm testing the use of records in Clojure and I have some issues when 
I try to call function of another namespaces from the record.


For testing purposes, I defined this record:

(ns test-record.component
  (:use test-record.utils))

(defprotocol Hierarchical
  "Protocol for tree."
  (children? [node] "children?"))

(defrecord Component [parent children name]
  Hierarchical
  (children? [node] (an-utils-function node)))

And I declared this namespace:

(ns test-record.utils)

(defn an-utils-function
  [c]
  (println (:name c)))

Very simple, isn't it?

But when I run this code in a REPL, I get an exception:

user=> (import 'test_record.component.Component)
test_record.component.Component
user=> (def c (Component. nil [] "The Root"))
#'user/c
user=>  (.children? c)
IllegalStateException Attempting to call unbound fn: 
#'test-record.utils/an-utils-function 
 clojure.lang.Var$Unbound.throwArity (Var.java:43)



Can I use functions of another namespaces from a record's code?

Thanks.



--
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: Call namespace's functions from a record

2012-12-24 Thread Christian Sperandio

I thought the import was enough.

And my error with the "." came from the fact Component is a compiled 
class and I believed I had to follow the Java standard writing.


Thank for your help.



On 12/24/2012 01:42 PM, Jim - FooBar(); wrote:
Lose the "." - call children? like this: (children? c) and make sure 
you can see the test-record.component namespace from your user ns 
(apart from importing the record class).


HTH,

Jim

On 24/12/12 11:55, Christian Sperandio wrote:

Hi,

I'm testing the use of records in Clojure and I have some issues when 
I try to call function of another namespaces from the record.


For testing purposes, I defined this record:

(ns test-record.component
  (:use test-record.utils))

(defprotocol Hierarchical
  "Protocol for tree."
  (children? [node] "children?"))

(defrecord Component [parent children name]
  Hierarchical
  (children? [node] (an-utils-function node)))

And I declared this namespace:

(ns test-record.utils)

(defn an-utils-function
  [c]
  (println (:name c)))

Very simple, isn't it?

But when I run this code in a REPL, I get an exception:

user=> (import 'test_record.component.Component)
test_record.component.Component
user=> (def c (Component. nil [] "The Root"))
#'user/c
user=>  (.children? c)
IllegalStateException Attempting to call unbound fn: 
#'test-record.utils/an-utils-function 
 clojure.lang.Var$Unbound.throwArity (Var.java:43)



Can I use functions of another namespaces from a record's code?

Thanks.



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


--
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: Call namespace's functions from a record

2012-12-24 Thread Jim - FooBar();
You are sort of correct...It's not an *error* per ce (it will still 
work) but since you're going through a protocol it is a bit suicidal to 
use interop...Just use the protocol... :)


Jim

On 24/12/12 12:52, Christian Sperandio wrote:

I thought the import was enough.

And my error with the "." came from the fact Component is a compiled 
class and I believed I had to follow the Java standard writing.


Thank for your help.



On 12/24/2012 01:42 PM, Jim - FooBar(); wrote:
Lose the "." - call children? like this: (children? c) and make sure 
you can see the test-record.component namespace from your user ns 
(apart from importing the record class).


HTH,

Jim

On 24/12/12 11:55, Christian Sperandio wrote:

Hi,

I'm testing the use of records in Clojure and I have some issues 
when I try to call function of another namespaces from the record.


For testing purposes, I defined this record:

(ns test-record.component
  (:use test-record.utils))

(defprotocol Hierarchical
  "Protocol for tree."
  (children? [node] "children?"))

(defrecord Component [parent children name]
  Hierarchical
  (children? [node] (an-utils-function node)))

And I declared this namespace:

(ns test-record.utils)

(defn an-utils-function
  [c]
  (println (:name c)))

Very simple, isn't it?

But when I run this code in a REPL, I get an exception:

user=> (import 'test_record.component.Component)
test_record.component.Component
user=> (def c (Component. nil [] "The Root"))
#'user/c
user=>  (.children? c)
IllegalStateException Attempting to call unbound fn: 
#'test-record.utils/an-utils-function 
 clojure.lang.Var$Unbound.throwArity (Var.java:43)



Can I use functions of another namespaces from a record's code?

Thanks.



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


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

inserting code into reify methods

2012-12-24 Thread nkonovalov
Hi.

I have a java interface.
Something like this this.

public interface ITest {
void printHello();
void printName(String name);
}

And i get an implementation using reify.

(def impl (reify macrotest.ITest
  (^void printHello [this]
(println "Hello world!"))
  (^void printName [this ^String name]
(println (str "Hello, " name
)

Also a have a validation method:
(defn validate-state [] (println "Some validation code here"))

So to add it into implementation i have to add int into every method 
manually 

(def impl (reify ITest
  (^void printHello [this]
*(validate-state)*
(println "Hello world!"))
  (^void printName [this ^String name]
   * (validate-state)*
(println (str "Hello, " name
)

Is it possible to make a macros that would get the validation method and 
insert this *(validate-state) *into the begining of each method in reify 
automatically.

Something like that?

(def impl (reify-with-validation *validate-state* ITest
  (^void printHello [this]
(println "Hello world!"))
  (^void printName [this ^String name]
(println (str "Hello, " name
)

Any thoughts on how to do 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: EOF when executing lein trampoline cljsbuild repl-listen

2012-12-24 Thread David Powell
Ah, cool.  I can confirm that this works for me in leiningen HEAD.


On Mon, Dec 24, 2012 at 6:08 AM, George Oliver wrote:

>
>
> On Sunday, December 23, 2012 3:30:53 PM UTC-8, Mark wrote:
>>
>>
>> I figure the reader is trying to load the project.clj but I'm executing
>> from the project's root directory.  I'm using lein 2.0 preview 10 on a
>> Windows 7 machine if that matters.
>>
>
>
> This might be a Windows + trampoline problem. See
> https://groups.google.com/d/msg/clojure/J0imbgVWh5I/lXL8DlvJxAoJ .
>
>
>
> --
> 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: Use repeat with a function argument

2012-12-24 Thread Ben Wolfson
of course repeat works with functions:

user=> (take 4 (map #(% 4) (repeat inc)))
(5 5 5 5)

On Sun, Dec 23, 2012 at 11:56 PM, Marko Topolnik
 wrote:
> repeat is not supposed to work with functions, but there's repeatedly.
>
>
> On Monday, December 24, 2012 4:20:23 AM UTC+1, Andrew Care wrote:
>>
>> I'm trying to use repeat with a function argument. This works:
>>
>> (reduce + (filter (fn [number] (zero? (some #{0} (map mod (take 2 (repeat
>> 9)) [3 5] (range 1 1000)))
>>
>> This doesn't:
>>
>> (reduce + (filter (fn [number] (zero? (some #{0} (map mod (take 2 (repeat
>> number)) [3 5] (range 1 1000)))
>>
>> Why can I use (repeat 9) and not (repeat number)?
>
> --
> 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



-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks,
which may be sweet, aromatic, fermented or spirit-based. ... Family
and social life also offer numerous other occasions to consume drinks
for pleasure." [Larousse, "Drink" entry]

-- 
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: EOF when executing lein trampoline cljsbuild repl-listen

2012-12-24 Thread David Powell
Ah, cool.  This is fixed in leiningen HEAD.
Though "lein ring server" doesn't work in HEAD.


On Mon, Dec 24, 2012 at 6:08 AM, George Oliver wrote:

>
>
> On Sunday, December 23, 2012 3:30:53 PM UTC-8, Mark wrote:
>>
>>
>> I figure the reader is trying to load the project.clj but I'm executing
>> from the project's root directory.  I'm using lein 2.0 preview 10 on a
>> Windows 7 machine if that matters.
>>
>
>
> This might be a Windows + trampoline problem. See
> https://groups.google.com/d/msg/clojure/J0imbgVWh5I/lXL8DlvJxAoJ .
>
>
>
> --
> 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: inserting code into reify methods

2012-12-24 Thread juan.facorro
Here's a possible implementation:

(ns macro-test
  (:require [clojure.pprint :as p]))

(defn get-args-index [x]
  (first (filter identity (map-indexed #(when (vector? %2) %1) x

(defn insert-at [x y i]
  (concat (take (inc i) x) (list y) (drop (inc i) x)))

(defmacro reify-with-validation [f interface & body]
  (let [i(map get-args-index body)
body (map #(insert-at %1 (list f) %2) body i)]
`(reify ~interface ~@body)))

I tested the expansion with the following code:

(def with-validation (macroexpand-1 
'(reify-with-validation validate-state ITest
  (^void printHello [this]
(println "Hello world!"))
  (^void printName [this ^String name]
(println (str "Hello, " name))

(p/pprint with-validation)

Here's an example using the macro with clojure.lang.ISeq:

(def x (reify-with-validation #(println "validating") clojure.lang.ISeq
  (^String toString [this]
(println "toString()"))
  (first [this]
(println "first()"))
  (next [this]
(println "next()"))
  (more [this]
(println "more()"))
  (cons [this o]
(println "cons()"

(.toString x)
(.first x)
(.next x)
(.more x)
(.cons x nil)

Which outputs:

validating
toString()
validating
first()
validating
next()
validating
more()
validating
cons()

Hope it helps,

Juan

On Monday, December 24, 2012 10:35:35 AM UTC-3, nkonovalov wrote:
>
> Hi.
>
> I have a java interface.
> Something like this this.
>
> public interface ITest {
> void printHello();
> void printName(String name);
> }
>
> And i get an implementation using reify.
>
> (def impl (reify macrotest.ITest
>   (^void printHello [this]
> (println "Hello world!"))
>   (^void printName [this ^String name]
> (println (str "Hello, " name
> )
>
> Also a have a validation method:
> (defn validate-state [] (println "Some validation code here"))
>
> So to add it into implementation i have to add int into every method 
> manually 
>
> (def impl (reify ITest
>   (^void printHello [this]
> *(validate-state)*
> (println "Hello world!"))
>   (^void printName [this ^String name]
>* (validate-state)*
> (println (str "Hello, " name
> )
>
> Is it possible to make a macros that would get the validation method and 
> insert this *(validate-state) *into the begining of each method in reify 
> automatically.
>
> Something like that?
>
> (def impl (reify-with-validation *validate-state* ITest
>   (^void printHello [this]
> (println "Hello world!"))
>   (^void printName [this ^String name]
> (println (str "Hello, " name
> )
>
> Any thoughts on how to do 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: Use repeat with a function argument

2012-12-24 Thread Sean Corfield
He's repeating a function argument, not a function.

Meikel is correct that the second expression causes (some #{0} ...) to
return nil when number is not a multiple of 3 or 5, and then zero? fails.
As he suggests...

(reduce + (filter (fn [number] (some zero? (map mod (take 2 (repeat
number)) [3 5]))) (range 1 1000)))

...works (and returns 233168)

Sean

On Sun, Dec 23, 2012 at 11:56 PM, Marko Topolnik
wrote:

> *repeat* is not supposed to work with functions, but there's *repeatedly.*
>
>
> On Monday, December 24, 2012 4:20:23 AM UTC+1, Andrew Care wrote:
>>
>> I'm trying to use repeat with a function argument. This works:
>>
>> (reduce + (filter (fn [number] (zero? (some #{0} (map mod (take 2 (repeat
>> 9)) [3 5] (range 1 1000)))
>>
>> This doesn't:
>>
>> (reduce + (filter (fn [number] (zero? (some #{0} (map mod (take 2 (repeat
>> number)) [3 5] (range 1 1000)))
>>
>> Why can I use (repeat 9) and not (repeat number)?
>>
>
>

-- 
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: Use repeat with a function argument

2012-12-24 Thread Marko Topolnik
I deleted my answer minutes after posting. The phrase "function argument" 
is ambiguous ("argument to function", "argument which is a function") and I 
jumped to the wrong conclusion.

On Monday, December 24, 2012 7:00:48 PM UTC+1, Sean Corfield wrote:
>
> He's repeating a function argument, not a function.
>
> Meikel is correct that the second expression causes (some #{0} ...) to 
> return nil when number is not a multiple of 3 or 5, and then zero? fails. 
> As he suggests...
>
> (reduce + (filter (fn [number] (some zero? (map mod (take 2 (repeat 
> number)) [3 5]))) (range 1 1000)))
>
> ...works (and returns 233168)
>
> Sean
>
> On Sun, Dec 23, 2012 at 11:56 PM, Marko Topolnik 
> 
> > wrote:
>
>> *repeat* is not supposed to work with functions, but there's *repeatedly.
>> *
>>
>>
>> On Monday, December 24, 2012 4:20:23 AM UTC+1, Andrew Care wrote:
>>>
>>> I'm trying to use repeat with a function argument. This works:
>>>
>>> (reduce + (filter (fn [number] (zero? (some #{0} (map mod (take 2 
>>> (repeat 9)) [3 5] (range 1 1000)))
>>>
>>> This doesn't:
>>>
>>> (reduce + (filter (fn [number] (zero? (some #{0} (map mod (take 2 
>>> (repeat number)) [3 5] (range 1 1000)))
>>>
>>> Why can I use (repeat 9) and not (repeat number)?
>>>
>>
>>

-- 
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: inserting code into reify methods

2012-12-24 Thread Alan Malloy
You don't need any of the typehints in your reify body. The compiler infers 
argument and return types from the interface definition.

On Monday, December 24, 2012 5:35:35 AM UTC-8, nkonovalov wrote:
>
> Hi.
>
> I have a java interface.
> Something like this this.
>
> public interface ITest {
> void printHello();
> void printName(String name);
> }
>
> And i get an implementation using reify.
>
> (def impl (reify macrotest.ITest
>   (^void printHello [this]
> (println "Hello world!"))
>   (^void printName [this ^String name]
> (println (str "Hello, " name
> )
>
> Also a have a validation method:
> (defn validate-state [] (println "Some validation code here"))
>
> So to add it into implementation i have to add int into every method 
> manually 
>
> (def impl (reify ITest
>   (^void printHello [this]
> *(validate-state)*
> (println "Hello world!"))
>   (^void printName [this ^String name]
>* (validate-state)*
> (println (str "Hello, " name
> )
>
> Is it possible to make a macros that would get the validation method and 
> insert this *(validate-state) *into the begining of each method in reify 
> automatically.
>
> Something like that?
>
> (def impl (reify-with-validation *validate-state* ITest
>   (^void printHello [this]
> (println "Hello world!"))
>   (^void printName [this ^String name]
> (println (str "Hello, " name
> )
>
> Any thoughts on how to do 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

Merry Christmas Everybody

2012-12-24 Thread Simone Mosciatti
I just wanted to say

"Merry Christmas" to this wonderful community that during this first (half) 
year learning clojure is really helping me.

Thanks to everybody and best wishes for the holidays

Simone Mosciatti

PS: Here in Italy is just 0.11 AM of the 25th of December aka Christmas...

-- 
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: EOF when executing lein trampoline cljsbuild repl-listen

2012-12-24 Thread Mark
Thanks guys.  I switched to a Linux environment and it works fine.

On Monday, December 24, 2012 3:49:54 AM UTC-8, David Powell wrote:
>
> I can confirm the same problem
>
>
> On Sun, Dec 23, 2012 at 11:30 PM, Mark  >wrote:
>
>> Hi, 
>> I'm trying to make my way through the modern-cljs tutorials and running 
>> into a blocker:  I'm on tutorial 2 (
>> https://github.com/magomimmo/modern-cljs/blob/master/doc/tutorial-02.md?.mdown)
>>   
>> and when I try lein trampoline cljsbuild repl-listen, I get 
>>
>> Exception in thread "main" clojure.lang.LispReader$ReaderException: 
>> java.lang.RuntimeException: EOF while reading, starting at line 1
>> at clojure.lang.LispReader.read(LispReader.java:215)
>> at clojure.core$read.invoke(core.clj:3346)
>> at clojure.core$read.invoke(core.clj:3344)
>> at clojure.main$eval_opt.invoke(main.clj:295)
>> at clojure.main$initialize.invoke(main.clj:316)
>> at clojure.main$script_opt.invoke(main.clj:340)
>> at clojure.main$main.doInvoke(main.clj:427)
>> at clojure.lang.RestFn.invoke(RestFn.java:930)
>> at clojure.lang.Var.invoke(Var.java:460)
>> at clojure.lang.AFn.applyToHelper(AFn.java:235)
>> at clojure.lang.Var.applyTo(Var.java:532)
>> at clojure.main.main(main.java:37)
>> Caused by: java.lang.RuntimeException: EOF while reading, starting at 
>> line 1
>> at clojure.lang.Util.runtimeException(Util.java:170)
>> at clojure.lang.LispReader.readDelimitedList(LispReader.java:1117)
>> at clojure.lang.LispReader$ListReader.invoke(LispReader.java:962)
>> at clojure.lang.LispReader.read(LispReader.java:180)
>> ... 11 more
>>
>> I figure the reader is trying to load the project.clj but I'm executing 
>> from the project's root directory.  I'm using lein 2.0 preview 10 on a 
>> Windows 7 machine if that matters.
>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@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+u...@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: ClojureCLR errors on Mono Linux

2012-12-24 Thread RobertLJ

Shantanu

The best way to get going right now with ClojureCLR is to build it from 
source.  The following is the process to build ClojureCLR on Linux 
(Assuming that the mono development environment is installed).  

1. Download: 
https://github.com/clojure/clojure-clr/archive/clojure-1.4.1.tar.gz
2. Untar clojure-1.4.1.tar.gz
3. Download the NuGet.exe commandline installer: 
http://nuget.codeplex.com/releases . Use the link under Available downloads 
"NuGet.exe Command Line". 
4. set up nuget as per these directions: 
http://monomvc.wordpress.com/2012/03/06/nuget-on-mono/

5. From the terminal in the "lib" directory under clojure-1.4.1 use "nuget" 
to download the dependencies like this:  

A. "nuget install DynamicLanguageRuntime.Net20.Unofficial"
B. "nuget install DynamicLanguageRuntime.Net40.Unofficial"
C. "nuget install NUnit"

6. Copy the assemblies from 
"lib/DynamicLanguageRuntime.Net20.Unofficial/lib/net20" to "lib/DLR/2.0"

7. Copy the assemblies from 
"lib/DynamicLanguageRuntime.Net40.Unofficial/lib/net40" to "lib/DLR/4.0"

8. In a text editor open the "Clojure.Compile.csproj" file located in 
"clojure-1.4.1/Clojure/Clojure.Compile".  Under the "" add 
"mono"  to the sections so it looks like this:

*-Clojure.Compile.csproj 
Edit---*
 mono "$(TargetPath)" clojure.core clojure.core.protocols 
clojure.main clojure.set clojure.zip  clojure.walk clojure.stacktrace 
clojure.template clojure.test clojure.test.tap clojure.test.junit 
clojure.pprint clojure.clr.io clojure.repl clojure.clr.shell clojure.string 
clojure.data clojure.reflect  
*-Clojure.Compile.csproj 
Edit---*

*-NUnit 
Edit--*
9. In a text editor open the "Clojure.Tests.csproj" file located in 
"clojure-1.4.1/Clojure/Clojure.Tests".   Change the "nunit.framework" 
configuration from:

Original Configuration
 
  
..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll
 

Change Configuration to this 

  ..\..\lib\NUnit.2.6.2\lib\nunit.framework.dll

*-NUnit 
Edit--*

10. Finaly from the directory "clojure-clr-clojure-1.4.1/Clojure" run 
either:

MONO_IOMAP=all xbuild build.proj /target:Build /p:Configuration="Release 
4.0" /p:Platform="Any CPU"

or
MONO_IOMAP=all xbuild build.proj /target:Build /p:Configuration="Debug 4.0" 
/p:Platform="Any CPU"

After the build the binaries will be located in 
"clojure-clr-clojure-1.4.1/bin/4.0\{Release || Debug}"


I'm working on streamlining this for for ClojureCLR 1.5.0. Hope this helps.

-Robert



On Wednesday, December 19, 2012 5:37:10 PM UTC-5, Shantanu Kumar wrote:
>
> Here are the steps how to reproduce the issue on 32-bit Ubuntu 12.04:
>
> 1. lein new lein-clr foo
> 2. cd foo
> 3. # edit project.clj to download the dependencies using :clj-dep
> 4. lein clr -v compile :all
>
 

> 5. lein clr -v test
>
> It will show the exact commands being executed. Are the same Clojure 
> binaries supposed to work on 32-bit systems?
>
> Shantanu
>
> On Wednesday, 19 December 2012 13:19:55 UTC+5:30, Shantanu Kumar wrote:
>>
>> Thanks David, and sorry for the insufficient bug details. I tested this 
>> on 64-bit Ubuntu where it works fine; however, the problem shows up on 
>> 32-bit Ubuntu.
>>
>> I will post the exact steps in the evening on how to replicate the issue 
>> on 32-bit Ubuntu.
>>
>> Shantanu
>>
>> On Wednesday, 19 December 2012 02:00:53 UTC+5:30, dmiller wrote:
>>>
>>> Shantanu,
>>>
>>> I created an Ubuntu 12.10 VM running in VirtualBox on my Win7 PC.  
>>> I installed Mono 2.10.8.
>>> I downloaded the zip for ClojureCLR 1.4.0 Debug-4.0.
>>> Extracted.
>>> > mono Clojure.Main.exe  
>>> Runs with no problem.
>>>
>>> > mono Clojure.Compile.exe test.junk
>>> Runs with no problem.
>>>
>>> From the errors you report, I can only guess that some pre-1.4 DLLs are 
>>> being found somehow and loaded.  
>>> For example,  the field clojure.lang.RT.OutVar did not exist in 
>>> ClojureCLR 1.3.
>>>
>>> I do not know how else to help.
>>>
>>> -David
>>>  
>>>
>>>
>>> On Saturday, December 15, 2012 10:17:59 PM UTC-6, Shantanu Kumar wrote:

 This is when using ClojureCLR 1.4.0 Debug-4.0 version.

 Shantanu

 On Sunday, 16 December 2012 09:45:21 UTC+5:30, Shantanu Kumar wrote:
>
> Hi,
>
> I noticed the following ClojureCLR errors using Mono 2.10 on Ubuntu 
> 12.04 (they do not happen on Windows using either .NET or Mono):
>
> 1. when running Clojure.Compile.exe:
>
> Exception: System.MissingFieldException: Field 
> 'clojure.lang.RT.OutVar' not found.
>
> 2. when using Clojure.Main.exe:
>
> Exception: System.TypeLoadException: Could not load type 
> 'Clojure.CljMain' from assembly 'Clojure.Main, Version=1.0

zip-reduce

2012-12-24 Thread JvJ
The other day I wrote this as a utility function because I couldn't find 
anything like it in the zipper libary.  Am I missing something?  Is 
something like this implemented somewhere?

(defn
  zip-reduce
  "Reduce called on a zipper."
  [f acc z]
  (if (zip/end? z)
acc
(recur f (f acc z) (zip/next z

-- 
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: zip-reduce

2012-12-24 Thread Alan Malloy
Probably better to write it more generally, by creating a seq from a zipper 
and then just using the ordinary reduce function on that zip:

(defn zip-seq [f acc z]
  (map node (tree-seq branch? children z)))

(reduce f acc (zip-seq some-zipper))

On Monday, December 24, 2012 6:27:00 PM UTC-8, JvJ wrote:
>
> The other day I wrote this as a utility function because I couldn't find 
> anything like it in the zipper libary.  Am I missing something?  Is 
> something like this implemented somewhere?
>
> (defn
>   zip-reduce
>   "Reduce called on a zipper."
>   [f acc z]
>   (if (zip/end? z)
> acc
> (recur f (f acc z) (zip/next z
>

-- 
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: zip-reduce

2012-12-24 Thread Alan Malloy
Except of course zip-seq doesn't need the f, acc arguments. Sorry about 
that.

On Monday, December 24, 2012 7:18:17 PM UTC-8, Alan Malloy wrote:
>
> Probably better to write it more generally, by creating a seq from a 
> zipper and then just using the ordinary reduce function on that zip:
>
> (defn zip-seq [f acc z]
>   (map node (tree-seq branch? children z)))
>
> (reduce f acc (zip-seq some-zipper))
>
> On Monday, December 24, 2012 6:27:00 PM UTC-8, JvJ wrote:
>>
>> The other day I wrote this as a utility function because I couldn't find 
>> anything like it in the zipper libary.  Am I missing something?  Is 
>> something like this implemented somewhere?
>>
>> (defn
>>   zip-reduce
>>   "Reduce called on a zipper."
>>   [f acc z]
>>   (if (zip/end? z)
>> acc
>> (recur f (f acc z) (zip/next z
>>
>

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