Re: Advice on state handling for a multiplayer poker app

2013-04-11 Thread Cedric Greevey
What about a map of table IDs to agents?

The map itself only needs to change if an event creates or destroys a
table. Anything else impacts a single table, and can be sent off to that
table's agent. An agent makes sense to hold each single table, as tables
undergo sequential transformations triggered by incoming external events.

Similarly, a map of user IDs to agents can track everyone's play-money.

The code that translates between incoming network events and sends to
agents is pretty much completely decoupled from the way the latter work, as
well; it won't need to be changed, for instance, if you start persisting
user information to a database. The money-handling agent for a user just
needs to now post an update to the backing database, and your startup code
needs to load the database data to initialize the agent contents on a
restart, and presto, you now have long term persistent user accounts and
money amounts, without touching the network/agent-send code, only the
functions applied to the agents.

So, sorting incoming network events and calling the appropriate business
logic becomes a concern completely separated from implementing that
business logic, and from the server-side DAL, and from the outgoing
networking. (The agents would need to also generate outgoing network
packets to update clients on the state changes they should know about. For
example, if a player gets dealt a 5 of hearts, their client needs to be
told that -- the others shouldn't, of course, as otherwise it would enable
someone with a hacked client to cheat by peeking at other players' cards.)

Timers can also be managed in a similar manner; for example, for each
connected client a fold-timeout agent can be created, and when the player
moves, the agent is sent something like this:

(defn timeout-set [[_ player]]
  (let [a *agent*]
(future (Thread/sleep (+ 50 timeout-duration)) (send-off a
timeout-check)))
  [(+ timeout-duration (System/currentTimeMillis)) player])

which depends on this:

(defn timeout-check [[timeout-time player]]
  (if (<= timeout-time (System/currentTimeMillis))
(do
  (send-off player timed-out)
  [Long/MAX_VALUE player])
[timeout-time player]))

which will send "timed-out" to the player-agent if they don't move for
timeout-duration milliseconds. When the player moves, timeout-set both sets
the earliest time they may now time out (current time + timeout-duration)
and creates a sleeping thread that will wake up a little bit later than
then and send the agent a timeout-check. (Since *agent* won't be the same
in that thread and when it wakes up, it's saved into a closed-over local in
timeout-set.) The timeout-check function sees if the agent's stored timeout
value has been exceeded; if not the player must have moved again in the
interim and it returns the agent's current state, leaving it undisturbed.
Otherwise, it maxes out the timeout time and sends a timed-out signal to
the player's agent. The player can't get timed out a second time until
moving again first, which would bring the timeout time back down out of the
stratosphere. The timeout time for a player would also be set to this when
there was no hand in progress, and on first connecting.

Of course, the above could need to be adapted to your needs. Also, I'm
unsure how big a thread pool you'd get with future; very many connected
clients might swamp it with long-sleeping threads. Using the executor
framework stuff from Java might be a better idea, or even more agents (and
send-off rather than send), if you want it to scale, though using a future
makes the example code above very simple and easy to understand.

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [ANN] Instaparse 1.0.0

2013-04-11 Thread Dmitry Kakurin
Hi Mark,
Brilliant work, thank you!

I was playing with your arithmetic parser from tutorial, and noticed the 
following definition for add and sub:

"expr = add-sub
  = mul-div | add | sub
 add = add-sub <'+'> mul-div
 sub = add-sub <'-'> mul-div
...

And I realize now that the ordering "add-sub <'+'> mul-div" here is 
very deliberate.
What should be my intuition for your parser for 
default ambiguity resolution rules? (sorry, I'm not familiar [yet] with 
GLL parsers)
Is it guaranteed to be non-greedy, i.e. it consumes as little as possible?
The docs section "No Grammar Left Behind" is somewhat fuzzy about it.

If I were writing LALR parser I would do (along with defining precedence 
and associativity rules for op) something like:

 expr = expr op expr | ...

And for LL parser I would do:

 add = mul-div <'+'> add-sub

(i.e. reverse ordering compared to yours).

But your parser rules are somewhat new to me.
Both variations are accepted:

 add = add-sub <'+'> add-sub
 add = mul-div <'+'> add-sub

And in both cases some generated parsers are correct (arithmetically 
speaking :-) ), but I'd like to understand rules for the first/default 
parser.
Could you clarify it a little please?

Great docs, BTW.

Thanks, Dmitry.

On Monday, April 8, 2013 10:18:39 PM UTC-7, puzzler wrote:
>
> Instaparse is an easy-to-use, feature-rich parser generator for Clojure.  
> The two stand-out features:
>
> 1. Converts standard EBNF notation for context-free grammars into an 
> executable parser.  Makes the task of building parsers as lightweight and 
> simple as working with regular expressions.
>
> 2. Works with *any* context-free grammar.  This means you don't have to 
> learn the esoteric subtleties of LR, LL, LALR or any other specialized 
> subset.  Left-recursion, right-recursion, ambiguous grammars -- instaparse 
> handles it all.
>
> Example:
>
> (def as-and-bs
>   (parser
> "S = AB*
>  AB = A B
>  A = 'a'+
>  B = 'b'+"))
>
> => (as-and-bs "abbbbb")
> [:S
>  [:AB [:A "a" "a" "a" "a" "a"] [:B "b" "b" "b"]]
>  [:AB [:A "a" "a" "a" "a"] [:B "b" "b"]]]
>
> https://github.com/Engelberg/instaparse for full feature list and 
> extensive tutorial.
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Advice on state handling for a multiplayer poker app

2013-04-11 Thread George Oliver


On Thursday, April 11, 2013 2:35:03 PM UTC-7, James Adams wrote:
>
>
> How would you do this?  All thoughts welcome and appreciated
>

To simplify matters you could think about decoupling the incoming game 
events from the state changes; for example, have a queue hold game events 
and then serially apply those to the game state (which in that case could 
simply be contained in a map). 

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Advice on state handling for a multiplayer poker app

2013-04-11 Thread Dave Sann
have a look at this for a discussion of exactly that question.

http://clj-me.cgrand.net/2011/10/06/a-world-in-a-ref/



https://github.com/cgrand/megaref



On Friday, 12 April 2013 07:35:03 UTC+10, James Adams wrote:
>
> Hi,
>
> I'm new to Clojure and trying to write a multiplayer poker web app.  I'm 
> looking for advice early on regarding state management.
>
> I'm using aleph and compojure for the communications with actions from 
> players coming in through compojure on different threads of the netty 
> server. 
> When a message arrives I check which rooms it corresponds based on the url 
> then update that rooms game state.
>
> I could store all state in (def rooms (atom {})) with the keys being the 
> room name and each room containing users and the game state but this would 
> require that I deref & swap! for every change to the state in any room 
> which would seem to be a bottleneck.
>
> Timers are also needed to fold a player if they don't move in time.
>
> How would you do this?  All thoughts welcome and appreciated
>
> Thanks
>
> James  
>
>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Macros in ClojureScript

2013-04-11 Thread Colin Fleming
Hi Kevin,

That message means that Clojure can't find the file containing your macros
on the classpath. Looking at it, you appear to have the macro file in your
src-cljs directory. I've never used ClojureScript, but maybe that should be
in your src directory since it's Clojure and not ClojureScript?

Cheers,
Colin


On 11 April 2013 20:14, Kevin De Valck  wrote:

> I'm currently building a project in clojurescript where I need to create
> some macros. And I don't manage to get it to work.
> What I'm currently doing is comparable with what you did in core.logic for
> clojurescript:
> https://github.com/clojure/core.logic/tree/master/src/main/clojure/cljs/core/logic
>
> I have create a file src-cljs/jsrefact/macros/macros.clj containing a
> macro defined in clojure.
> Aftwards from my project: src-cljs/jsrefact/core.cljs i try to use the
> macrosby putting in de namespace:
> (:use-macros [jsrefact.macros.macros :only
> [equals]])
>
> For the compilation I use cljsbuild, and this doesn't give any errors.
> But when I try to load the namespace of core.cljs in the REPL it gives
> this error:
>
> java.io.FileNotFoundException: Could not locate
> jsrefact/macros/macros__init.class or jsrefact/macros/macros.clj on
> classpath:
> at clojure.lang.RT.load(RT.java:432)
>  at clojure.lang.RT.load(RT.java:400)
> at clojure.core$load$fn__4890.invoke(core.clj:5415)
> at clojure.core$load.doInvoke(core.clj:5414)
>  at clojure.lang.RestFn.invoke(RestFn.java:408)
> ...
> at clojure.lang.AFn.applyToHelper(AFn.java:163)
>  at clojure.lang.Var.applyTo(Var.java:532)
> at clojure.main.main(main.java:37)
> java.io.FileNotFoundException: Could not locate
> jsrefact/macros/macros__init.class or jsrefact/macros/macros.clj on
> classpath:
> nil
>
> I suppose that this error says that the macro file is not compiled but how
> can I solve this?
>
>
> On Wednesday, September 14, 2011 2:57:16 AM UTC+2, David Nolen wrote:
>>
>> You can reference macros defined in *clojure* files that are on your
>> classpath like this:
>>
>> (ns my.namespace
>>   (:require-macros [my.macros :as my])
>>
>> The ClojureScript compiler will use these macros to expand your
>> ClojureScript source.
>>
>> Works great.
>>
>> David
>>
>> On Tue, Sep 13, 2011 at 6:31 PM, Timothy Baldridge wrote:
>>
>>> While working with ClojureScript I came across a interesting question.
>>> When compiling cljs files, how does Clojure handle macros? Normally
>>> macros are run at compile-time, but in this case the compile-time
>>> platform is completely different than the run time platform. My guess
>>> is that the compiler assumes that clojure.core.first (for instance)
>>> functions exactly the same for both the JVM and the JS versions of
>>> Clojure, but I could be wrong there. The only other possibility I can
>>> see is if ClojureScript has some internal JS VM it uses only for macro
>>> expanding.
>>>
>>> So what is the situation here?
>>>
>>> Thanks for your time,
>>>
>>> Timothy
>>>
>>> --
>>> “One of the main causes of the fall of the Roman Empire was
>>> that–lacking zero–they had no way to indicate successful termination
>>> of their C programs.”
>>> (Robert Firth)
>>>
>>> --
>>> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an

Advice on state handling for a multiplayer poker app

2013-04-11 Thread James Adams
Hi,

I'm new to Clojure and trying to write a multiplayer poker web app.  I'm 
looking for advice early on regarding state management.

I'm using aleph and compojure for the communications with actions from 
players coming in through compojure on different threads of the netty 
server. 
When a message arrives I check which rooms it corresponds based on the url 
then update that rooms game state.

I could store all state in (def rooms (atom {})) with the keys being the 
room name and each room containing users and the game state but this would 
require that I deref & swap! for every change to the state in any room 
which would seem to be a bottleneck.

Timers are also needed to fold a player if they don't move in time.

How would you do this?  All thoughts welcome and appreciated

Thanks

James  



-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Infer state

2013-04-11 Thread Catonano
Hello people,

I was wondering if Infer ( https://github.com/aria42/infer#readme ) is
still developed and if it is in use somewhere.

I´ve been plaiyng with Cascalog but I read that with Infer you can
prototipe on a single machine and then scale up to an Hadoop cluster if
needed with a reasonable effort

But I see that the last committ was 3 years ago and there´s not a single
example in the readme file.

Thanks
Cato

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: loading proxied classes outside of clojure

2013-04-11 Thread Cedric Greevey
You could use genclass and AOT compilation. I'm not sure of any other way.


On Thu, Apr 11, 2013 at 3:30 PM, Jim - FooBar(); wrote:

> since classes generated by proxy reside on memory how would the standard
> java.net.URLClassolader find them? is there a way to emit the class on disk?
>
> Jim
>
> --
> --
> 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+unsubscribe@**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 unsubscribe from this group and stop receiving emails from it, send an
> email to 
> clojure+unsubscribe@**googlegroups.com
> .
> For more options, visit 
> https://groups.google.com/**groups/opt_out
> .
>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




ANN Money 1.2.0

2013-04-11 Thread Michael Klishin
ClojureWerkz Money [1] is a Clojure library that deals with monetary
amounts and currencies.
It is built on top of Joda Money.

Release notes for 1.2.0:
http://blog.clojurewerkz.org/blog/2013/04/11/money-1-dot-2-0-is-released/

1. https://github.com/clojurewerkz/money
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




loading proxied classes outside of clojure

2013-04-11 Thread Jim - FooBar();
since classes generated by proxy reside on memory how would the standard 
java.net.URLClassolader find them? is there a way to emit the class on disk?


Jim

--
--
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Zookeeper and Riak experiment

2013-04-11 Thread gerardc
Hi all,

I released a simple prototype on Github of the Epochal Time model described 
by Rich Hickey in his talk "The Language of the System".

It uses Zookeeper for co-ordination and Riak as a data-store, all behind a 
simple Compojure app.

I'd be cool to get some feedback on it if anyone is 
interested: https://github.com/gerardc/remi

Many Thanks,

Gerard

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Difficulty working with complex protobuf objects [protobuf "0.6.2"]

2013-04-11 Thread Alan Malloy
0.6.2 is six months old. I don't think anything about this has changed 
since then, but you should at least try [org.flatland/protobuf "0.7.2"] and 
see if that does what you expect.

On Thursday, April 11, 2013 8:39:12 AM UTC-7, David Pidcock wrote:
>
>
> I have some Java classes generated elsewhere (not by the lein proto 
> plugin) and I'm wanting to use them as the basis for the [protobuf "0.6.2"] 
>  code interactions (for interdependency with an existing java project) 
>
> One thing I noticed about the output in REPL is that only the first key is 
> presented to the screen from protobuf.core.PersistentProtocolBufferMap
>
> Even  (keys my-proto) only shows the first key
>
> At first I thought I'd screwed something up,   but when I try 
> (:some-key   my-proto)   
> I get the expected result. 
>
> The data referenced by :some-key in this instance is another map  -- 
> almost all of the data contained in the message is complex like this. 
>
> Is this a bug in protobuf.core.PersistentProtocolBufferMap?  Or am I 
> missing something?
>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: classloader and proxied classes issue

2013-04-11 Thread Jim - FooBar();
Ok I've narrowed it down a bit and it definitely is a classloader 
issue...observe this:


hotel_nlp.externals.uima=> c
#hotel_nlp.externals.uima.proxy$org.uimafit.component.JCasAnnotator_ImplBase$0@16059e71>


hotel_nlp.externals.uima=> (class c)
hotel_nlp.externals.uima.proxy$org.uimafit.component.JCasAnnotator_ImplBase$0

hotel_nlp.externals.uima=> (. (ClassLoader/getSystemClassLoader) 
loadClass 
"hotel_nlp.externals.uima.proxy$org.uimafit.component.JCasAnnotator_ImplBase$0") 
;;FAIL
ClassNotFoundException 
hotel_nlp.externals.uima.proxy$org.uimafit.component.JCasAnnotator_ImplBase$0 


java.net.URLClassLoader$1.run (URLClassLoader.java:366)

hotel_nlp.externals.uima=> (Class/forName 
"hotel_nlp.externals.uima.proxy$org.uimafit.component.JCasAnnotator_ImplBase$0" 
false (ClassLoader/getSystemClassLoader))
ClassNotFoundException 
hotel_nlp.externals.uima.proxy$org.uimafit.component.JCasAnnotator_ImplBase$0 
;;FAIL java.net.URLClassLoader$1.run (URLClassLoader.java:366)


hotel_nlp.externals.uima=> (Class/forName 
"hotel_nlp.externals.uima.proxy$org.uimafit.component.JCasAnnotator_ImplBase$0") 
;;SUCCESS
hotel_nlp.externals.uima.proxy$org.uimafit.component.JCasAnnotator_ImplBase$0 



which classloader was used in the last case which succeeded?presumably 
Clojure's dynamic classloader...
this is the first time this is happening to me...Ihaven't got a clue 
what to do...I don't see an obvious way of setting uima's classloader to 
use clojure's dynamic classloader and even if I could who knows what 
kind of problems that would bring...


Jim


On 11/04/13 16:36, Jim - FooBar(); wrote:
I found this on SO which seems to be related but the answer proposes 
deftype which is not an option for me as I need to extend a particular 
class with proxy... I'm completely stuck...


Jim


On 11/04/13 14:10, Jim - FooBar(); wrote:

Hi all,

I'm writing a tiny wrapper around apache UIMA but I'm facing some 
classloading issues. Before I start explaining I should point out 
that UIMA makes heavy use of the .class member of classes. It is 
practically everywhere (a small java code snippet follows for 
demonstration of what I mean):


AnalysisEngine goldTagger =
   AnalysisEngineFactory.createPrimitive(*GoldTagger.class*, 
typeSystem);


Ok let's start...I tried to create a minimal example with proxying 
java.awt.Point but the only tool that I have to check whether a class 
is present on the classpath is this code:


 (try (Class/forName "somePackage.someClass")
 (catch ClassNotFoundException cnf "NOT FOUND!"))

which in my made up minimal example returns the class object just 
fine (as does for my proper example following which makes things 
confusing). That is why I'm not posting the short example...OK here 
we go:


;first of all we need a component of our own that is alien to uima
(def regex-tokenizer artefacts/reg-tok) ;a regex-based tokenizer

;then I need to make it uima-compatible - this means extending a 
class and overriding 'process(JCas jc)'

(def uima-friendly
   (uima-compatible regex-tokenizer squeeze-jcas)) ;everything up to 
here works just fine.


;the definitions for 'uima-compatible' &  'squeeze-jcas' follow for 
the sake of completeness (feel free to skip them)

 (defn uima-compatible [component jcas-input-extractor]
 (proxy [org.uimafit.component.JCasAnnotator_ImplBase][]
   (process [^JCas jc]
   (let [xs (jcas-input-extractor jc)]
  (component xs) ;;assuming component is a fn for now

(defn squeeze-jcas [^JCas jcas & classes]
 (for [c classes
   x (JCasUtil/select jcas c)]
x))

;the final step is to produce the actual analysis engine(s) from the 
uima components (the proxied versions as they are the ones that are 
uima-friendly).
;this is where the classloading problems begin which is very 
frustrating as this is the very last step! Using the following fn:


(defn ufit-produce
"Produce UIMA components from your objects without writing any XML 
descriptors, via uima-fit."

 [& os]
   (map #(AnalysisEngineFactory/createPrimitive (class %) 
*type-system* (to-array [])) os))


I am doing (ufit-produce uima-friendly) and I get :

*ClassNotFoundException 
hotel_nlp.externals.uima.proxy$org.uimafit.component.JCasAnnotator_ImplBase$0 
**

**java.net.URLClassLoader$1.run (URLClassLoader.java:366) *

However the class is definitely there since I am able to do thie 
following no problem:


*(try (Class/forName 
"hotel_nlp.externals.uima.proxy$org.uimafit.component.JCasAnnotator_ImplBase$0") 
**

** (catch ClassNotFoundException cnf "NOT FOUND!"))**
**
** 
=>hotel_nlp.externals.uima.proxy$org.uimafit.component.JCasAnnotator_ImplBase$0*

 What on earthis happening? How am I able to get the class Object 
back but the ClassLoader couldn't? This is very weird isn't it?


any insights would be great! :)

Jim









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

Re: [ANN] Instaparse 1.0.0

2013-04-11 Thread Mark Engelberg
On Thu, Apr 11, 2013 at 7:08 AM, Stathis Sideris  wrote:

> Thanks, this looks fantastic! Is there any way to include comments in the
> syntax at all?


Last night I started a v1.1 branch to start work on these feature
requests.  The first feature I added was, in fact, support for EBNF comment
syntax:
(* this is a comment *)

Supports nested comments too, in case you want to wrap a comment around a
comment.

Add [instaparse "1.1.0-SNAPSHOT"] to your dependencies and give it a try.

As I add features, I'll add them to the v1.1 change log:
https://github.com/Engelberg/instaparse/blob/v1.1/CHANGES.md
and also update the README on the v1.1 branch:
https://github.com/Engelberg/instaparse/blob/v1.1/README.md

--Mark

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




Difficulty working with complex protobuf objects [protobuf "0.6.2"]

2013-04-11 Thread David Pidcock

I have some Java classes generated elsewhere (not by the lein proto plugin) 
and I'm wanting to use them as the basis for the [protobuf "0.6.2"]  code 
interactions (for interdependency with an existing java project) 

One thing I noticed about the output in REPL is that only the first key is 
presented to the screen from protobuf.core.PersistentProtocolBufferMap

Even  (keys my-proto) only shows the first key

At first I thought I'd screwed something up,   but when I try 
(:some-key   my-proto)   
I get the expected result. 

The data referenced by :some-key in this instance is another map  -- almost 
all of the data contained in the message is complex like this. 

Is this a bug in protobuf.core.PersistentProtocolBufferMap?  Or am I 
missing something?


-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: classloader and proxied classes issue

2013-04-11 Thread Jim - FooBar();
I found this on SO which seems to be related but the answer proposes 
deftype which is not an option for me as I need to extend a particular 
class with proxy... I'm completely stuck...


Jim


On 11/04/13 14:10, Jim - FooBar(); wrote:

Hi all,

I'm writing a tiny wrapper around apache UIMA but I'm facing some 
classloading issues. Before I start explaining I should point out that 
UIMA makes heavy use of the .class member of classes. It is 
practically everywhere (a small java code snippet follows for 
demonstration of what I mean):


AnalysisEngine goldTagger =
   AnalysisEngineFactory.createPrimitive(*GoldTagger.class*, 
typeSystem);


Ok let's start...I tried to create a minimal example with proxying 
java.awt.Point but the only tool that I have to check whether a class 
is present on the classpath is this code:


 (try (Class/forName "somePackage.someClass")
 (catch ClassNotFoundException cnf "NOT FOUND!"))

which in my made up minimal example returns the class object just fine 
(as does for my proper example following which makes things 
confusing). That is why I'm not posting the short example...OK here we go:


;first of all we need a component of our own that is alien to uima
(def regex-tokenizer artefacts/reg-tok) ;a regex-based tokenizer

;then I need to make it uima-compatible - this means extending a class 
and overriding 'process(JCas jc)'

(def uima-friendly
   (uima-compatible regex-tokenizer squeeze-jcas)) ;everything up to 
here works just fine.


;the definitions for 'uima-compatible' &  'squeeze-jcas' follow for 
the sake of completeness (feel free to skip them)

 (defn uima-compatible [component jcas-input-extractor]
 (proxy [org.uimafit.component.JCasAnnotator_ImplBase][]
   (process [^JCas jc]
   (let [xs (jcas-input-extractor jc)]
  (component xs) ;;assuming component is a fn for now

(defn squeeze-jcas [^JCas jcas & classes]
 (for [c classes
   x (JCasUtil/select jcas c)]
x))

;the final step is to produce the actual analysis engine(s) from the 
uima components (the proxied versions as they are the ones that are 
uima-friendly).
;this is where the classloading problems begin which is very 
frustrating as this is the very last step! Using the following fn:


(defn ufit-produce
"Produce UIMA components from your objects without writing any XML 
descriptors, via uima-fit."

 [& os]
   (map #(AnalysisEngineFactory/createPrimitive (class %) 
*type-system* (to-array [])) os))


I am doing (ufit-produce uima-friendly) and I get :

*ClassNotFoundException 
hotel_nlp.externals.uima.proxy$org.uimafit.component.JCasAnnotator_ImplBase$0 
**

**java.net.URLClassLoader$1.run (URLClassLoader.java:366) *

However the class is definitely there since I am able to do thie 
following no problem:


*(try (Class/forName 
"hotel_nlp.externals.uima.proxy$org.uimafit.component.JCasAnnotator_ImplBase$0") 
**

** (catch ClassNotFoundException cnf "NOT FOUND!"))**
**
** 
=>hotel_nlp.externals.uima.proxy$org.uimafit.component.JCasAnnotator_ImplBase$0*

 What on earthis happening? How am I able to get the class Object back 
but the ClassLoader couldn't? This is very weird isn't it?


any insights would be great! :)

Jim







--
--
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Parallelizing tasks

2013-04-11 Thread Bruno Kim Medeiros Cesar
On Thursday, April 11, 2013 10:03:51 AM UTC-3, Gary Verhaegen wrote:
>
> The way the f function is written, there is no way to run it in 
> parallel, since it needs the previous answer. The best you can hope 
> for is to use two cores, one for a and one for b. 
>

That was my goal at first, but your comment made me think that there _is_ a 
way to compute the sequence in parallel: Substituting the expression in 
itself I can compute x_{n+2} from x_n; this way I can compute the even and 
odd terms in parallel for each sequence. This can be extended to compute 
x_{n+4} from x_n, allowing to compute 4 terms in parallel for each 
sequence, thus occupying 8 cores. The calculation complexity will rise for 
each term, though, so some performance analysis is needed to find the best 
approach.
 

> What you can do if you want to make it parallel is use the closed 
> form, and create a lazy list of that closed form for each iteration. 
> Something along the lines of (doall (pmap #(- (f a %) (f b %)) 
> (range))), where (f a n) yields the value for the nth iteration with a 
> starting value of a, using the closed form. If you know in advance how 
> many steps you want, you could have even more parallelism with a 
> reducer-based map on a vector of n's. 
>
> Unfortunately, I personally do not know of an arbitrary-precision 
> implementation of sin, asin and sqrt (though I suppose they would not 
> be *that* hard to implement). 
>

It's impossible to implement such functions using rational arithmetic, it 
would be necessary some serious symbolic packages à la Mathematica.
 

> On 11 April 2013 09:27, Michael Gardner > 
> wrote: 
> > On Apr 10, 2013, at 21:46 , Ulises > 
> wrote: 
> > 
> >> Have you tried replacing all your calls to map for pmap yet? 
> > 
> > That will not work. He'll need to rearrange his algorithm to something 
> like this before pmap will help: 
> > 
> > (defn iterated-difference [f a b] 
> > "Yields a lazy seq of the differences between (iterate f a) and 
> (iterate f b)." 
> > (cons (doto (double (- b a)) println) 
> > (lazy-seq (apply iterated-difference f (pmap f [a b]) 
> > 
> > Might need to wrap this in a (doall …) or such to see progressive output 
> from the println. 
>

Both suggestions seems to kind-of have worked, but for the most part just 
one core is used. The problem is that the calculation for a is much faster 
than the calculation for b, and the iteration hangs on that. Also, the time 
complexity seems to be exponential!

(defn test-f [n x] (double (last (take n (iterate f x)
(doall (for [n (range 10 18)] [n (time (test-f n a)]))
;"Elapsed time: 1.550121 msecs"
;"Elapsed time: 1.081994 msecs"
;"Elapsed time: 3.278447 msecs"
;"Elapsed time: 11.228025 msecs"
;"Elapsed time: 22.27068 msecs"
;"Elapsed time: 90.175714 msecs"
;"Elapsed time: 305.631558 msecs"
;"Elapsed time: 1196.748514 msecs"
;(...)

(doall (for [n (range 10 18)] [n (time (test-f n b))]))
;"Elapsed time: 197.777474 msecs"
;"Elapsed time: 769.693374 msecs"
;"Elapsed time: 3038.191752 msecs"
;"Elapsed time: 12228.269874 msecs"
;"Elapsed time: 49325.26163 msecs"
;"Elapsed time: 197819.804965 msecs"
;^C (life is too short)

This is just to be expected as the denominator doubles every step, although 
the exponent seems close to 4... I guess I'll need plenty of time to reach 
100 steps.

Thanks for your suggestions, if I ever get some results I'll post it here.

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [GSOC 2013] Android UI as Clojure Data

2013-04-11 Thread Daniel Solano Gómez
Hello,

On Wed Apr 10 11:42 2013, Junseok Lee wrote:
> Hello! My name is Junseok Lee, and I'm studying CS at UC Berkeley. I was 
> lead to Clojure through my interest in the Lisp family of languages, 
> initiated by my studies of Scheme in my coursework. I've been lurking on 
> this group for a while and thought it was about time to introduce myself.
> 
> I'm hoping to find an effective way to express Android UI layouts with 
> Clojure during this year's Google Summer of Code. I'm very well versed in 
> Java and the Android API, and am currently studying the core.match library. 
> My first thought is to implement something similar to Hiccup's HTML 
> generation. Am I on the right track or did I get the idea completely wrong?
> 
> Any suggestions are welcome. Thanks in advance.

Thanks for your interest in participating in this year's GSoC.  There
have already been some good suggestions from other people, such as
looking into Alexander's work from last year and Dave Ray's Seesaw.

As you know, one of the quirks of Android' UI toolkit is that you need
to (or at least should) design your user interfaces so that it can scale
gracefully to a large number of different forms, e.g. different screen
orientations, different display sizes and densities, different
languages, different Android versions, etc.  The Android SDK gives you
tools to this via declaratively via a series of parallel XML files.
This works well enough, but I believe it stands a chance for
improvement.

In my experience, some of the biggest pain points with this approach are:

- While there is some mechanisms for XML layout reuse within the SDK, it
  seems like as the project and the number of supported configurations
  grow, it becomes harder to manage the XML.

- Often times, within a layout, you'll have a lot of elements that have
  similar attributes all grouped together (width and height come to
  mind).  Android gives you styles as a way of applying certain
  attributes to a variety elements, but it somewhat clunky if all you
  are interested in changing is one or two things.  It would be nice to
  have some sort of cascading style mechanism withing the layout itself.

- Once an XML layout is instantiated, it ceases to be data.  There is no
  way to easily query or manipulate it at runtime.  This means there is
  no way to tweak your UI at runtime and spit out XML.  It also means
  any tweaks to your XML layout require a full redeploy of your app.

As a result, I have been giving some thought on possible approaches to
solve these problems, and it has occured to me that creating some sort
of mapping of Clojure data to Android UI elements might make sense.
Alexander did some work along these lines last year, but I would be
interested in seeing the work taken further.

I do not have any specific things I'd like to see done per se; however,
some of the questions to ask when considering a solution include:

- Can it be used as a library with Android projects using other
  languages, i.e. Java or Scala?

- How well can does the solution integrate into Android SDK?

- Is it possible to have a 'production mode' that imparts no additional
  overhead compared to Android's native approach?

- How well can it be used to create tools to make it easier for
  designers to create layouts for Android?

I hope this gives you something to think about.  Feel free to post ideas
on the list to get feedback from a variety of developers.

Sincerely,

Daniel


signature.asc
Description: Digital signature


Re: [ANN] Instaparse 1.0.0

2013-04-11 Thread Stathis Sideris
Sorry for the lack of clarity -- I meant comments about the grammar within 
the resource file that describes it. The (str) approach would be good for 
embedded grammars in Clojure code, but I'm working with a fairly bulky 
grammar which would be better to keep in its own file.

Stathis

On Thursday, 11 April 2013 15:16:29 UTC+1, Steven Degutis wrote:
>
> I'm not the OP, but if you mean comments within the grammar, sure as long 
> as "comment" is well defined, and if you mean comments *about* the grammar 
> within the parser code, how about creating the grammar using (str) with one 
> string per line, and putting your comments after each line's string?
>
> -Steven
>
>
> On Thu, Apr 11, 2013 at 9:08 AM, Stathis Sideris 
> 
> > wrote:
>
>> Thanks, this looks fantastic! Is there any way to include comments in the 
>> syntax at all?
>>
>> Thanks,
>>
>> Stathis
>>
>>
>> On Tuesday, 9 April 2013 06:18:39 UTC+1, puzzler wrote:
>>>
>>> Instaparse is an easy-to-use, feature-rich parser generator for 
>>> Clojure.  The two stand-out features:
>>>
>>> 1. Converts standard EBNF notation for context-free grammars into an 
>>> executable parser.  Makes the task of building parsers as lightweight and 
>>> simple as working with regular expressions.
>>>
>>> 2. Works with *any* context-free grammar.  This means you don't have to 
>>> learn the esoteric subtleties of LR, LL, LALR or any other specialized 
>>> subset.  Left-recursion, right-recursion, ambiguous grammars -- instaparse 
>>> handles it all.
>>>
>>> Example:
>>>
>>> (def as-and-bs
>>>   (parser
>>> "S = AB*
>>>  AB = A B
>>>  A = 'a'+
>>>  B = 'b'+"))
>>>
>>> => (as-and-bs "abbbbb")
>>> [:S
>>>  [:AB [:A "a" "a" "a" "a" "a"] [:B "b" "b" "b"]]
>>>  [:AB [:A "a" "a" "a" "a"] [:B "b" "b"]]]
>>>
>>> https://github.com/Engelberg/**instaparsefor
>>>  full feature list and extensive tutorial.
>>>
>>  -- 
>> -- 
>> 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 unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [ANN] Instaparse 1.0.0

2013-04-11 Thread Steven Degutis
I'm not the OP, but if you mean comments within the grammar, sure as long
as "comment" is well defined, and if you mean comments *about* the grammar
within the parser code, how about creating the grammar using (str) with one
string per line, and putting your comments after each line's string?

-Steven


On Thu, Apr 11, 2013 at 9:08 AM, Stathis Sideris  wrote:

> Thanks, this looks fantastic! Is there any way to include comments in the
> syntax at all?
>
> Thanks,
>
> Stathis
>
>
> On Tuesday, 9 April 2013 06:18:39 UTC+1, puzzler wrote:
>>
>> Instaparse is an easy-to-use, feature-rich parser generator for Clojure.
>> The two stand-out features:
>>
>> 1. Converts standard EBNF notation for context-free grammars into an
>> executable parser.  Makes the task of building parsers as lightweight and
>> simple as working with regular expressions.
>>
>> 2. Works with *any* context-free grammar.  This means you don't have to
>> learn the esoteric subtleties of LR, LL, LALR or any other specialized
>> subset.  Left-recursion, right-recursion, ambiguous grammars -- instaparse
>> handles it all.
>>
>> Example:
>>
>> (def as-and-bs
>>   (parser
>> "S = AB*
>>  AB = A B
>>  A = 'a'+
>>  B = 'b'+"))
>>
>> => (as-and-bs "abbbbb")
>> [:S
>>  [:AB [:A "a" "a" "a" "a" "a"] [:B "b" "b" "b"]]
>>  [:AB [:A "a" "a" "a" "a"] [:B "b" "b"]]]
>>
>> https://github.com/Engelberg/**instaparsefor
>>  full feature list and extensive tutorial.
>>
>  --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [ANN] Instaparse 1.0.0

2013-04-11 Thread Stathis Sideris
Thanks, this looks fantastic! Is there any way to include comments in the 
syntax at all?

Thanks,

Stathis


On Tuesday, 9 April 2013 06:18:39 UTC+1, puzzler wrote:
>
> Instaparse is an easy-to-use, feature-rich parser generator for Clojure.  
> The two stand-out features:
>
> 1. Converts standard EBNF notation for context-free grammars into an 
> executable parser.  Makes the task of building parsers as lightweight and 
> simple as working with regular expressions.
>
> 2. Works with *any* context-free grammar.  This means you don't have to 
> learn the esoteric subtleties of LR, LL, LALR or any other specialized 
> subset.  Left-recursion, right-recursion, ambiguous grammars -- instaparse 
> handles it all.
>
> Example:
>
> (def as-and-bs
>   (parser
> "S = AB*
>  AB = A B
>  A = 'a'+
>  B = 'b'+"))
>
> => (as-and-bs "abbbbb")
> [:S
>  [:AB [:A "a" "a" "a" "a" "a"] [:B "b" "b" "b"]]
>  [:AB [:A "a" "a" "a" "a"] [:B "b" "b"]]]
>
> https://github.com/Engelberg/instaparse for full feature list and 
> extensive tutorial.
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




classloader and proxied classes issue

2013-04-11 Thread Jim - FooBar();

Hi all,

I'm writing a tiny wrapper around apache UIMA but I'm facing some 
classloading issues. Before I start explaining I should point out that 
UIMA makes heavy use of the .class member of classes. It is practically 
everywhere (a small java code snippet follows for demonstration of what 
I mean):


AnalysisEngine goldTagger =
   AnalysisEngineFactory.createPrimitive(*GoldTagger.class*, 
typeSystem);


Ok let's start...I tried to create a minimal example with proxying 
java.awt.Point but the only tool that I have to check whether a class is 
present on the classpath is this code:


 (try (Class/forName "somePackage.someClass")
 (catch ClassNotFoundException cnf "NOT FOUND!"))

which in my made up minimal example returns the class object just fine 
(as does for my proper example following which makes things confusing). 
That is why I'm not posting the short example...OK here we go:


;first of all we need a component of our own that is alien to uima
(def regex-tokenizer artefacts/reg-tok) ;a regex-based tokenizer

;then I need to make it uima-compatible - this means extending a class 
and overriding 'process(JCas jc)'

(def uima-friendly
   (uima-compatible regex-tokenizer squeeze-jcas)) ;everything up to 
here works just fine.


;the definitions for 'uima-compatible' &  'squeeze-jcas' follow for the 
sake of completeness (feel free to skip them)

 (defn uima-compatible [component jcas-input-extractor]
 (proxy [org.uimafit.component.JCasAnnotator_ImplBase][]
   (process [^JCas jc]
   (let [xs (jcas-input-extractor jc)]
  (component xs) ;;assuming component is a fn for now

(defn squeeze-jcas [^JCas jcas & classes]
 (for [c classes
   x (JCasUtil/select jcas c)]
x))

;the final step is to produce the actual analysis engine(s) from the 
uima components (the proxied versions as they are the ones that are 
uima-friendly).
;this is where the classloading problems begin which is very frustrating 
as this is the very last step! Using the following fn:


(defn ufit-produce
"Produce UIMA components from your objects without writing any XML 
descriptors, via uima-fit."

 [& os]
   (map #(AnalysisEngineFactory/createPrimitive (class %) *type-system* 
(to-array [])) os))


I am doing (ufit-produce uima-friendly) and I get :

*ClassNotFoundException 
hotel_nlp.externals.uima.proxy$org.uimafit.component.JCasAnnotator_ImplBase$0 
**

**java.net.URLClassLoader$1.run (URLClassLoader.java:366) *

However the class is definitely there since I am able to do thie 
following no problem:


*(try (Class/forName 
"hotel_nlp.externals.uima.proxy$org.uimafit.component.JCasAnnotator_ImplBase$0") 
**

** (catch ClassNotFoundException cnf "NOT FOUND!"))**
**
** 
=>hotel_nlp.externals.uima.proxy$org.uimafit.component.JCasAnnotator_ImplBase$0*

 What on earthis happening? How am I able to get the class Object back 
but the ClassLoader couldn't? This is very weird isn't it?


any insights would be great! :)

Jim





--
--
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Parallelizing tasks

2013-04-11 Thread Gary Verhaegen
The way the f function is written, there is no way to run it in
parallel, since it needs the previous answer. The best you can hope
for is to use two cores, one for a and one for b.

What you can do if you want to make it parallel is use the closed
form, and create a lazy list of that closed form for each iteration.
Something along the lines of (doall (pmap #(- (f a %) (f b %))
(range))), where (f a n) yields the value for the nth iteration with a
starting value of a, using the closed form. If you know in advance how
many steps you want, you could have even more parallelism with a
reducer-based map on a vector of n's.

Unfortunately, I personally do not know of an arbitrary-precision
implementation of sin, asin and sqrt (though I suppose they would not
be *that* hard to implement).

On 11 April 2013 09:27, Michael Gardner  wrote:
> On Apr 10, 2013, at 21:46 , Ulises  wrote:
>
>> Have you tried replacing all your calls to map for pmap yet?
>
> That will not work. He'll need to rearrange his algorithm to something like 
> this before pmap will help:
>
> (defn iterated-difference [f a b]
> "Yields a lazy seq of the differences between (iterate f a) and (iterate 
> f b)."
> (cons (doto (double (- b a)) println)
> (lazy-seq (apply iterated-difference f (pmap f [a b])
>
> Might need to wrap this in a (doall …) or such to see progressive output from 
> the println.
>
> --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Macros in ClojureScript

2013-04-11 Thread Kevin De Valck
I'm currently building a project in clojurescript where I need to create 
some macros. And I don't manage to get it to work.
What I'm currently doing is comparable with what you did in core.logic for 
clojurescript: 
https://github.com/clojure/core.logic/tree/master/src/main/clojure/cljs/core/logic

I have create a file src-cljs/jsrefact/macros/macros.clj containing a macro 
defined in clojure.
Aftwards from my project: src-cljs/jsrefact/core.cljs i try to use the 
macrosby putting in de namespace:
(:use-macros [jsrefact.macros.macros :only
[equals]])

For the compilation I use cljsbuild, and this doesn't give any errors.
But when I try to load the namespace of core.cljs in the REPL it gives this 
error:

java.io.FileNotFoundException: Could not locate 
jsrefact/macros/macros__init.class or jsrefact/macros/macros.clj on 
classpath: 
at clojure.lang.RT.load(RT.java:432)
at clojure.lang.RT.load(RT.java:400)
at clojure.core$load$fn__4890.invoke(core.clj:5415)
at clojure.core$load.doInvoke(core.clj:5414)
at clojure.lang.RestFn.invoke(RestFn.java:408)
...
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.Var.applyTo(Var.java:532)
at clojure.main.main(main.java:37)
java.io.FileNotFoundException: Could not locate 
jsrefact/macros/macros__init.class or jsrefact/macros/macros.clj on 
classpath: 
nil

I suppose that this error says that the macro file is not compiled but how 
can I solve this?


On Wednesday, September 14, 2011 2:57:16 AM UTC+2, David Nolen wrote:
>
> You can reference macros defined in *clojure* files that are on your 
> classpath like this:
>
> (ns my.namespace
>   (:require-macros [my.macros :as my])
>
> The ClojureScript compiler will use these macros to expand your 
> ClojureScript source.
>
> Works great.
>
> David
>
> On Tue, Sep 13, 2011 at 6:31 PM, Timothy Baldridge 
> 
> > wrote:
>
>> While working with ClojureScript I came across a interesting question.
>> When compiling cljs files, how does Clojure handle macros? Normally
>> macros are run at compile-time, but in this case the compile-time
>> platform is completely different than the run time platform. My guess
>> is that the compiler assumes that clojure.core.first (for instance)
>> functions exactly the same for both the JVM and the JS versions of
>> Clojure, but I could be wrong there. The only other possibility I can
>> see is if ClojureScript has some internal JS VM it uses only for macro
>> expanding.
>>
>> So what is the situation here?
>>
>> Thanks for your time,
>>
>> Timothy
>>
>> --
>> “One of the main causes of the fall of the Roman Empire was
>> that–lacking zero–they had no way to indicate successful termination
>> of their C programs.”
>> (Robert Firth)
>>
>> --
>> 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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: defrecord and namespace-qualified symbols

2013-04-11 Thread Simon Katz
Yes, I agree.

Thanks for helping me to clarify my thoughts on this.

On Thursday, 11 April 2013 02:40:23 UTC+1, Cedric Greevey wrote:
>
> Let me clarify. If the library's designed to interoperate specifically 
> with a particular record type, it should be designed with knowledge of the 
> base keys. Even then, its own keys should be ns-qualified. And it can't 
> assume the set of base keys won't grow in a future version of the record 
> type. But it might conceivably use base keys to do things that are specific 
> to that record type, e.g.:
>
> (defn fancy-third-party-transform [point]
>   (Point. (funky-fn-x (:x point) (:y point)) (funky-fn-y (:x point) (:y 
> point
>
> If the library's designed to interoperate with generic maps of outside 
> origin, it can't assume anything about how those maps might be used with 
> regard to keys outside of its own namespace. Non-caller-supplied keys 
> should be qualified.
>
>
>
> On Wed, Apr 10, 2013 at 4:24 PM, Simon Katz 
> > wrote:
>
>> On Wednesday, 10 April 2013 21:08:22 UTC+1, Cedric Greevey wrote:
>>
>>> If a third-party library is storing things in your defrecord, it 
>>> behooves its author to know what that record's predefined keys are.
>>>
>>
>> Um, I don't think I agree. The library might be doing something very 
>> generic and have no reason to know anything about the defrecord.
>>  
>>
>>> In fact, if a third-party library is putting (its own, rather than 
>>> caller-supplied) keys into caller-supplied maps, it behooves it to use 
>>> qualified keys. :)
>>>
>>
>> Yes.  I can imagine libraries that don't do this, though, and it might 
>> not be obvious that's the case without inspecting a library very carefully.
>>
>> -- 
>> -- 
>> 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 unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [GSOC 2013] Android UI as Clojure Data

2013-04-11 Thread BJG145
PS The Clojure-Android group is pretty much dead in the water, though 
Thomas Kalbe recently posted up a useful link to something he's been 
working on.

https://groups.google.com/forum/#!topic/clojure-android/fzcX_ColRwE

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [GSOC 2013] Android UI as Clojure Data

2013-04-11 Thread BJG145
>I'm hoping to find an effective way to express Android UI layouts with 
Clojure

Are you thinking in terms of working with the standard XML layout files or 
replacing them with something else...?

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [GSOC 2013] Android UI as Clojure Data

2013-04-11 Thread Junseok Lee
Thank you both for the helpful instruction. I'll be back once I've done a 
bit more research on those projects.

On Thursday, April 11, 2013 12:34:00 AM UTC-7, Osbert Feng wrote:
>
> Be sure to look at neko and lein-droid, both most recently being worked on 
> by alexander-yakushev, I believe as a previous GSOC project:
>
> http://clojure-android.blogspot.com/
> https://gist.github.com/alexander-yakushev/2907442
>
> https://github.com/alexander-yakushev/lein-droid/blob/master/sample/src/clojure/test/leindroid/sample/main.clj
>
>
>
> On Wed, Apr 10, 2013 at 7:19 PM, Dave Sann 
> > wrote:
>
>> Caveat - I haven't do any android dev and don't know details of their UI 
>> apis
>>
>> But not letting that get in the way of an opinion,  I also suggest that 
>> you look at what Dave Ray has done with Seesaw for swing. There my well be 
>> useful ideas in there for you.
>>
>> https://github.com/daveray/seesaw/
>>
>> infoq preso 
>> http://www.infoq.com/presentations/Building-User-Interfaces-with-Seesaw
>>
>> Dave
>>
>>
>> On Thursday, 11 April 2013 04:42:25 UTC+10, Junseok Lee wrote:
>>>
>>> Hello! My name is Junseok Lee, and I'm studying CS at UC Berkeley. I was 
>>> lead to Clojure through my interest in the Lisp family of languages, 
>>> initiated by my studies of Scheme in my coursework. I've been lurking on 
>>> this group for a while and thought it was about time to introduce myself.
>>>
>>> I'm hoping to find an effective way to express Android UI layouts with 
>>> Clojure during this year's Google Summer of Code. I'm very well versed in 
>>> Java and the Android API, and am currently studying the core.match library. 
>>> My first thought is to implement something similar to Hiccup's HTML 
>>> generation. Am I on the right track or did I get the idea completely wrong?
>>>
>>> Any suggestions are welcome. Thanks in advance.
>>>
>>  -- 
>> -- 
>> 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 unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [GSOC 2013] Android UI as Clojure Data

2013-04-11 Thread Osbert Feng
Be sure to look at neko and lein-droid, both most recently being worked on
by alexander-yakushev, I believe as a previous GSOC project:

http://clojure-android.blogspot.com/
https://gist.github.com/alexander-yakushev/2907442
https://github.com/alexander-yakushev/lein-droid/blob/master/sample/src/clojure/test/leindroid/sample/main.clj



On Wed, Apr 10, 2013 at 7:19 PM, Dave Sann  wrote:

> Caveat - I haven't do any android dev and don't know details of their UI
> apis
>
> But not letting that get in the way of an opinion,  I also suggest that
> you look at what Dave Ray has done with Seesaw for swing. There my well be
> useful ideas in there for you.
>
> https://github.com/daveray/seesaw/
>
> infoq preso
> http://www.infoq.com/presentations/Building-User-Interfaces-with-Seesaw
>
> Dave
>
>
> On Thursday, 11 April 2013 04:42:25 UTC+10, Junseok Lee wrote:
>>
>> Hello! My name is Junseok Lee, and I'm studying CS at UC Berkeley. I was
>> lead to Clojure through my interest in the Lisp family of languages,
>> initiated by my studies of Scheme in my coursework. I've been lurking on
>> this group for a while and thought it was about time to introduce myself.
>>
>> I'm hoping to find an effective way to express Android UI layouts with
>> Clojure during this year's Google Summer of Code. I'm very well versed in
>> Java and the Android API, and am currently studying the core.match library.
>> My first thought is to implement something similar to Hiccup's HTML
>> generation. Am I on the right track or did I get the idea completely wrong?
>>
>> Any suggestions are welcome. Thanks in advance.
>>
>  --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Parallelizing tasks

2013-04-11 Thread Michael Gardner
On Apr 10, 2013, at 21:46 , Ulises  wrote:

> Have you tried replacing all your calls to map for pmap yet?

That will not work. He'll need to rearrange his algorithm to something like 
this before pmap will help:

(defn iterated-difference [f a b]
"Yields a lazy seq of the differences between (iterate f a) and (iterate f 
b)."
(cons (doto (double (- b a)) println)
(lazy-seq (apply iterated-difference f (pmap f [a b])

Might need to wrap this in a (doall …) or such to see progressive output from 
the println.

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.