Re: Need help to find a bug in a genetic algorithm

2012-04-12 Thread Stefan Kamphausen
Hi,

On Wednesday, April 11, 2012 8:27:26 PM UTC+2, Goldritter wrote:


 Another thing about the posted code here.
 When the alogrithm is stopped, the start-stop-agent became the state 
 stopped. Because this agent has not the state running anymore, there 
 is no send for any other agent anymore. But these agents are available 
 and running correct? Does these unused agents use up any System 
 ressources?


what exactly do you mean?  The agents are still within scope and thus 
reachable and won't be garbage collected.  They will consume some memory.  
However, since no update function is sent to the agents anymore, they don't 
consume any CPU cycles.

All update functions sent to all agents (using `send') will be run on a 
dedicated thread-pool.  No agent has its own thread.  Maybe this is your 
misunderstanding?
 

Kind regards,
Stefan

-- 
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: Need help to find a bug in a genetic algorithm

2012-04-12 Thread Marcus Lindner
Ahh ok.

I had read following text on  http://clojure.org/agents
Note that use of Agents starts a pool of non-daemon background threads
that will prevent shutdown of the JVM. Use
shutdown-agentshttp://clojure.github.com/clojure/clojure.core-api.html#clojure.core/send-off
to
terminate these threads and allow shutdown.

That is the reason I though the agents consume some system ressources, even
when they do nothing, and  I realy had the assumption somehow that every
agents has it's own Thread. :(


2012/4/12 Stefan Kamphausen ska2...@googlemail.com

 Hi,


 On Wednesday, April 11, 2012 8:27:26 PM UTC+2, Goldritter wrote:


 Another thing about the posted code here.
 When the alogrithm is stopped, the start-stop-agent became the state
 stopped. Because this agent has not the state running anymore, there
 is no send for any other agent anymore. But these agents are available
 and running correct? Does these unused agents use up any System
 ressources?


 what exactly do you mean?  The agents are still within scope and thus
 reachable and won't be garbage collected.  They will consume some memory.
 However, since no update function is sent to the agents anymore, they don't
 consume any CPU cycles.

 All update functions sent to all agents (using `send') will be run on a
 dedicated thread-pool.  No agent has its own thread.  Maybe this is your
 misunderstanding?


 Kind regards,
 Stefan

 --
 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: [ANN] Quil 1.0.0

2012-04-12 Thread Sam Aaron
We have a mailing list (which dates back to the clj-processing days):

https://groups.google.com/forum/?fromgroups#!forum/clj-processing

I also hang out in #quil on free node.

I'm always happy to help out in any way I can.

Sam

---
http://sam.aaron.name

On 11 April 2012 18:04, Changa Damany Imara cdim...@gmail.com wrote:
 Where's the best place to ask questions or get help using quill? I have a
 question about drawing stuff to the screen that I don't think is really a
 bug, just lack of knowledge on my part.

 On Saturday, April 7, 2012 10:17:06 AM UTC-7, Sam Aaron wrote:

 On 7 April 2012 16:20, Changa Damany Imara wrote:

  Very excited to see this. Thanks so much!

 No need to thank me - thank Roland Sadowski for writing clj-processing
 in the first place. I just did a spot of spring cleaning :-)

 Sam

 ---
 http://sam.aaron.name

 --
 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: Comprehensive ClojureScript Optimizations - Please Try!

2012-04-12 Thread David Nolen
On Thu, Apr 12, 2012 at 1:13 AM, Brandon Bloom snprbo...@gmail.com wrote:


 In my little test project (which depends on Vars for some clever DOM
 manipulation callbacks), I needed a way to get the :dynamic flag when
 attaching a REPL to an already-compiled front end. What I did was prn the
 namespaces atom to the output directory with *print-dup* true  reload it
 server side from my repl initialization script. That prn/read stuff isn't
 in my branch, just my local project.


Why not just analyze the source path? Also re-analyze changed files?




 Related - dynamic binding. You will now get a warning if you try to use a
 var that has not been declared ^:dynamic. Dynamic vars are never direct
 invoked.


 Have you given any more consideration to bound-fn,
 {push,pop,get}-thread-bindings, Var with IWatchable, etc?

 Now that this compiler state is required for optimizations, my Vars
 changes aren't as big and scary in my mind. I'd be happy to bring the
 branch up to date, if you're happy to consider it for inclusion :-)


Feel free to create a patch and put it into JIRA. I don't think there's any
rush on this particular patch.

David

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

Supporting platform specific code

2012-04-12 Thread Timothy Baldridge
I've been thinking lately how to seamlessly merge clojure-py and
clojure-jvm code in the same packages. This is something I know has
been discussed in the past, but I'm just looking for
ideas/brainstorming on how we can solve this problem.

Let's begin by explaining the problem. Let's assume that my project
needs a platform specific way to convert a int to a string:

On clojure-jvm:

(defn to-string [i] (.toString Integer i))

On clojure-py:

(defn to-string [i] (py/str i))

On Clojurescript:

(defn to-string [i] (.toString i))


We could do this inline (inside a common .clj file):

(for-platform jvm
  (defn to-string [i] (.toString Integer i))
  python
  (defn to-string [i] (py/str i))
  js
  (defn to-string [i] (.toString i)))

But this gets ugly real fast.

My idea, would be to provide some sort of hook to the compiler, that
would be cross-platform. The compiler, when looking for a namespace,
would find all files in a given folder that match the required
namespace:

/test/to_string.clj
/test/to_string.cljpy
/test/to_string.cljs
/test/to_string.cljclr

These function hooks would then pick the best entry based on the
extension, defaulting to .clj if no better option exists. Since these
functions could be composable it would be possible to also dispatch on
platform versions:

/test/to_string.cljpy26   ; Python 2.6 code
/test/to_string.clj7; JVM 7 code

It seems to me that this would be a very clean way to allow clojure
programs to be cross-platform. The side-effect is that it would force
non-standard code out into separate namespaces where they can be
easily maintained. If someone wanted to port the project to a new
platform, he would need only to find existing platform overrides, and
create new entries.


Thoughts?

Timothy Baldridge

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


Logic puzzle: send more money performance

2012-04-12 Thread Nicolas Buduroi
Hi, I translated[1]the solution to the send more money logic puzzle from
the cKanren paper in core.logic and I was wondering about its expected
performance. I wasn't patient enough to run it without giving it some
clues, giving it the S E N D digits make it run in around 36s on my
machine, but then giving it just three digits make it goes on for minutes.

So I'm curious about how much time would be needed to run this solution
without any clues. Is its performance expected or I've made some kind of
mistake? Also does anyone know of ways to optimize this code?

[1]: https://gist.github.com/2364695

-- 
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: Logic puzzle: send more money performance

2012-04-12 Thread David Nolen
You'll want to wait for core.logic to get the cKanren extensions before
trying that. Even an optimized core.logic version takes about 14-16s.

David

On Thu, Apr 12, 2012 at 12:58 PM, Nicolas Buduroi nbudu...@gmail.comwrote:

 Hi, I translated[1]the solution to the send more money logic puzzle from
 the cKanren paper in core.logic and I was wondering about its expected
 performance. I wasn't patient enough to run it without giving it some
 clues, giving it the S E N D digits make it run in around 36s on my
 machine, but then giving it just three digits make it goes on for minutes.

 So I'm curious about how much time would be needed to run this solution
 without any clues. Is its performance expected or I've made some kind of
 mistake? Also does anyone know of ways to optimize this code?

 [1]: https://gist.github.com/2364695

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

[ANN] Leiningen 2.0.0-preview3

2012-04-12 Thread Phil Hagelberg

Hello folks.

I'm happy to announce the release of the third preview of Leiningen 2.0.0.

Highlights include the ability to show a full dependency tree a la mvn
dependency:tree, a host of repl improvements, better offline support,
and the ability to load lein new templates on-demand.

* Add HTTP nREPL support for repl task via :connect option. (Chas Emerick,
  Phil Hagelberg)
* Improve repl startup time, output consistency, Windows support. (Lee Hinman,
  Colin Jones)
* Stop using numeric exit codes for task failures.
* Dynamically resolve unknown templates in new task.
* Automatically activate offline profile when needed.
* Honor $http_proxy environment variable. (Juergen Hoetzel)
* Allow arbitrary :filespecs to be included in jars.
* Let custom :prep-tasks be specified in project.clj.
* Include :java-source-paths and dev/test deps in pom. (Nelson Morris)
* Add offline profile.
* Prevent project JVMs from outlasting Leiningen's process. (Colin Jones)
* Update lein.bat to work with version 2. (Andrew Kondratovich)
* Show a dependency tree in deps task. (Chas Emerick, Nelson Morris)
* Support connecting to nrepl server in repl task. (Chas Emerick, Colin Jones)
* Pretty-print pom.xml. (Nelson Morris)
* Display task aliases in help task. (Michael S. Klishin)
* Only compile stale java source files. (Stephen C. Gilardi)
* Respect :java-cmd in project.clj. (Michael S. Klishin)
* Show progress when downloading search indices. (Justin Kramer)

If you have an earlier preview version, you can pull this in via lein
upgrade. If you only have Leiningen 1.x installed, you will have to
download preview3 by hand:

https://raw.github.com/technomancy/leiningen/preview/bin/lein

Note that this does not conflict in any way with Leiningen 1.x; you can
keep the two of them installed side-by-side. It's common to save the
above script as lein2 to differentiate between the two of them if you
have projects that don't yet work with Leiningen 2.

So far we've found the preview2 release to be quite stable, so now would
be a great time to try upgrading if you've been holding off:

https://github.com/technomancy/leiningen/wiki/Upgrading

If you're interested in contributing, I've categorized the existing
TODOs into low-hanging fruit, intermediate, and complex; pick something
and hop on the #leiningen channel in freenode:

https://github.com/technomancy/leiningen/blob/master/todo.org

thanks!

-Phil

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


Re: Supporting platform specific code

2012-04-12 Thread Vinzent
First thing which comes to mind is to use metadata for this purpose. 
Something like

(defn ^{:platform :jvm} to-string [x] ...)

This doesn't force the user to create a separate file for each platform 
(although it's still possible to do so) and feels very naturally for 
clojure.

Another option is to use reader macros, like in Common Lisp:

#+ :jvm (defn to-string ...)

-- 
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: Supporting platform specific code

2012-04-12 Thread Jim - FooBar();

+1 for meta-data...it fits the glove perfectly ;-)


On 12/04/12 18:52, Vinzent wrote:
First thing which comes to mind is to use metadata for this purpose. 
Something like


(defn ^{:platform :jvm} to-string [x] ...)

This doesn't force the user to create a separate file for each 
platform (although it's still possible to do so) and feels very 
naturally for clojure.


Another option is to use reader macros, like in Common Lisp:

#+ :jvm (defn to-string ...)
--
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: Supporting platform specific code

2012-04-12 Thread Evan Mezeske


 First thing which comes to mind is to use metadata for this purpose. 
 Something like

 (defn ^{:platform :jvm} to-string [x] ...)


You might be interested in https://github.com/lynaghk/cljx , which already 
does this sort of thing. 

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

Accessing defrecord from another namespace

2012-04-12 Thread Adam Markham
I have two namespaces as follows:

(ns app.one.a
  (:require [ns.app.two.b])
  (:import [ns.app.two.b Book]))

(def b (Book. A Book Adam))


(ns app.two.b)

(defrecord Book [title author])


However whenever I try to import the defrecord I get a
ClassNotFoundException thrown. I tried AOT compiling the namespace
containing the defrecord with (:gen-class) but it made no difference.

Is there anything that i'm doing wrong?

Thanks,

Adam

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

2012-04-12 Thread Vinzent
Well, changing the behaviour of 'if' is not the only way to fix the problem 
(and it's impossible because of backward compatibility anyway). In my mind, 
more realistic solution would be:

  1. Clearly state in the section on interop that clojure, unlike java, 
doesn't treat 'false' and (Boolean. false) as equal objects.
2. Clearly state in the doc of '=' that it should not be used for testing 
equality of booleans, since it could lead to confusing results.
3. Emphasis that 'true?' and 'false?' should be used instead of (= x false).

Then typical expierence of the newcomer can be changed from

= (def x (Boolean. false))
#'x
= (if x :t :f)
:t  ; WTF?!
= (= (Boolean. false) false)
true ; WHAT...???
** going to ask a question on the google group

to

= (def x (Boolean. false))
#'x
= (if x :t :f)
:t  ; WTF?!
= (= (Boolean. false) false)
WARNING: false? should be used instead, see also: http://...
= (false? x)
false ; hmmm...
= (if (boolean x) :t :f)
:f   ; ok, it's not very convenient, but they probably have a reason 
for that. I  can live with it.
** continues to write his program

-- 
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: Supporting platform specific code

2012-04-12 Thread Timothy Baldridge
 First thing which comes to mind is to use metadata for this purpose.
 Something like

 (defn ^{:platform :jvm} to-string [x] ...)



What we need is even more defined then that, however, Consider this
snippet from core.match:

(ns clojure.core.match
  (:refer-clojure :exclude [compile])
  (:require [clojure.set :as set])
  (:import [java.io Writer]))

how do we use metadata to restrict/include java.io.Writer vs CLR's
System.IO.TextWriter? If we go with the meta-data route, then we're
forced to put ^{:platform :jvm} 40 times in a single file instead of
just putting the code in a different file and not needing to clutter
the code with extra meta-data. Not to mention that defmacro, deftype,
defprotocol, etc. would all need to check for this metadata before
executing.


cljx is a lein plugin...I'm trying to figure out how to do this on the
compiler level. It seems that it would be good to have a way to to
this in clojure-clr, clojure-scheme, etc.

Timothy

-- 
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: Supporting platform specific code

2012-04-12 Thread Tassilo Horn
Vinzent ru.vinz...@gmail.com writes:

 First thing which comes to mind is to use metadata for this purpose.
 Something like

 (defn ^{:platform :jvm} to-string [x] ...)

I don't think that's too practical.  The reader sees the metadata only
after it already started to read the form it should then ignore, if the
platform doesn't match.

 Another option is to use reader macros, like in Common Lisp:

 #+ :jvm (defn to-string ...)

Yet another option is to use plain macros, and arbitrary test
expressions instead of just keywords.  For example, I have some jvm
clojure code where I use the ForkJoin classes if available and fall back
to executor services if not.  One could consider a clojure.platform
namespace with standard, frequently used predicates.

Something along the lines of:

(cond-compile
  (platform-jvm? =1.7.0) ...
  (platform-jvm?) ...
  (platform-clr?) ...
  :else (throw (Exception.
 (format Sorry, frobnification not supported on %s *platform*

Bye,
Tassilo  

-- 
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: translating underscore.js to clojurescript

2012-04-12 Thread David Nolen
For the curious:

https://github.com/Reactive-Extensions/RxJS

David

On Wed, Apr 11, 2012 at 9:22 PM, Jason Hickner jhick...@gmail.com wrote:

 Thanks, I'll check it out.

 - Jason


 On Wednesday, April 11, 2012 4:42:35 PM UTC-7, David Nolen wrote:

 It might be worth investigating a more functional solution. RxJS looks
 like a promising project to steal ideas from.

 David

 On Wed, Apr 11, 2012 at 6:11 PM, Jason Hickner jhick...@gmail.comwrote:

 Hello,

 I'm working on porting underscore.js to clojurescript (at least the
 parts that aren't made redundant by clojurescript already). Mostly it's
 pretty straightforward, but for some of the trickier functions I'm having
 trouble finding an idiomatic translation.

 Here's the throttle and bounce functions for example (alongside the
 original js):

 https://gist.github.com/**2363070 https://gist.github.com/2363070

 I don't like how I've had to use so many atoms in throttle, but you
 can't set! a local var. Is there a better way to go about this? Maybe I
 should just have one map in an atom, for instance.

 - Jason
 http://www.varywell.com/

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

2012-04-12 Thread Tassilo Horn
Vinzent ru.vinz...@gmail.com writes:

 1. Clearly state in the section on interop that clojure, unlike java,
 doesn't treat 'false' and (Boolean. false) as equal objects.

Of course, it does!  But `if` doesn't check equality, it checks if the
test expression's result is *identical* to nil or false.

 2. Clearly state in the doc of '=' that it should not be used for
 testing equality of booleans, since it could lead to confusing
 results.

Not at all.  But java.lang.Boolean-equality to true or false is
different to clojure's truthiness semantics, which state that everything
except nil and false is logical true.  Clearly, nil and false are not
equal, neither are 17 and Foobar, but the former two are both falsy
and the latter two truthy.

 3. Emphasis that 'true?' and 'false?' should be used instead of (= x
 false).

Depends on what you want to do.  false? and true? obey the clojure
semantics, while (= x false) with x being a Boolean object gives you the
java semantics.

So what's actually needed is a big red sign telling the clojure rule of
truthiness.  Everything except nil and false [1] is logical true.

[1] false is the primitive thingy, which is identical to Boolean/FALSE,
(Boolean/valueOf false), or auto-unboxed false Boolean objects, but
not to (Boolean. false).

Bye,
Tassilo

-- 
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: Supporting platform specific code

2012-04-12 Thread Vinzent


 What we need is even more defined then that, however, Consider this
 snippet from core.match:

 (ns clojure.core.match
   (:refer-clojure :exclude [compile])
   (:require [clojure.set :as set])
   (:import [java.io Writer]))

 how do we use metadata to restrict/include java.io.Writer vs CLR's
 System.IO.TextWriter?

If I understand what I've seen on cljx page correctly, it's possible to put 
platform metadata on ns forms (and maybe even on any expression?)
 

 If we go with the meta-data route, then we're
 forced to put ^{:platform :jvm} 40 times in a single file instead of
 just putting the code in a different file and not needing to clutter
 the code with extra meta-data.

On the other hand, you'd have to create a file even if you want just one 
platform-specific function. Also, it's probably possible to combine the 
strengths of the two somehow, e.g. (with-platform :jvm ...).

-- 
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: Supporting platform specific code

2012-04-12 Thread Vinzent


 I don't think that's too practical.  The reader sees the metadata only
 after it already started to read the form it should then ignore, if the
 platform doesn't match.

 As I understand it happens before compilation (lein plugin extracts the 
appropriate forms and then compiles it), so it shouldn't be a problem, no? 
Am I wrong?



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

2012-04-12 Thread Vinzent
I understand the points you've described, but as I written earlier the 
thing which is really confuses me is that for 2 equal objects, one 
considered truthy and the other considered falsey. In terms of clojure, if 
2 objects are equal they represents the same value, right? As I've 
mentioned earlier, '(1 2 3) and [1 2 3] is two different objects, but it's 
a single value - collection of numbers 1, 2 and 3, in this order. This is 
true for all built-in clojure types of data - equal things are the same 
thing. 'false' is a clojure built-in, so I'd expect that its behaviour is 
similar. 'false' is equal to (Boolean. false); it implies that they 
represents the same value. Thus, the same value can be considered as both 
truthy and falsey by clojure, which is like blowing my mind.

Of course it's possible to say that one of ='s arguments is a java class, 
so you can't rely on it, but it just doesn't feel right for me. It creates 
a sense that I cannot trust my code on the most basic level, as topic 
starter sayed.

Hope I've made my point clear now.

-- 
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: Accessing defrecord from another namespace

2012-04-12 Thread Vinzent
It should be

(ns app.one.a 
  (:require [app.two.b]) 
  (:import [app.two.b Book])) 

i.e. 'app.two.b' instead of 'ns.app.two.b'

пятница, 13 апреля 2012 г., 0:03:49 UTC+6 пользователь Adam Markham написал:

 I have two namespaces as follows: 

 (ns app.one.a 
   (:require [ns.app.two.b]) 
   (:import [ns.app.two.b Book])) 

 (def b (Book. A Book Adam)) 


 (ns app.two.b) 

 (defrecord Book [title author]) 


 However whenever I try to import the defrecord I get a 
 ClassNotFoundException thrown. I tried AOT compiling the namespace 
 containing the defrecord with (:gen-class) but it made no difference. 

 Is there anything that i'm doing wrong? 

 Thanks, 

 Adam

-- 
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: Supporting platform specific code

2012-04-12 Thread Tassilo Horn
Vinzent ru.vinz...@gmail.com writes:

 I don't think that's too practical.  The reader sees the metadata
 only after it already started to read the form it should then ignore,
 if the platform doesn't match.

 As I understand it happens before compilation (lein plugin extracts
 the appropriate forms and then compiles it),

Such a feature shouldn't depend on a specific tool, it should be part of
the language.

 so it shouldn't be a problem, no?  Am I wrong?

It's doable, but not very elegant and unlispy.  Reader macros or plain
macros are a better match here.

Bye,
Tassilo

-- 
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: Supporting platform specific code

2012-04-12 Thread Vinzent


 Such a feature shouldn't depend on a specific tool, it should be part of
 the language.

Yeah, you're right - I haven't thought about the fact that leiningen isn't 
available on the platforms other than jvm and js.

Given that reader macros are already used for this purpose extensively in 
the other language, is there a reason to reinvent the wheel? What kind of 
problems such approach creates?
(this question is not addressed specifically to you) 

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

2012-04-12 Thread Tassilo Horn
Vinzent ru.vinz...@gmail.com writes:

 As I've mentioned earlier, '(1 2 3) and [1 2 3] is two different
 objects, but it's a single value - collection of numbers 1, 2 and 3,
 in this order.  This is true for all built-in clojure types of data -
 equal things are the same thing.

No, equal doesn't mean they are the same thing.  For sequentials like
lists and vectors equality is defined as same length and equal objects
in the same order.  Nevertheless, that doesn't mean that you can
exchange all vectors in your code by equal lists.  For example, you
cannot call `subvec' on a list.

 'false' is a clojure built-in,

false and true are JVM built-ins.

 so I'd expect that its behaviour is similar. 'false' is equal to
 (Boolean. false); it implies that they represents the same
 value. Thus, the same value can be considered as both truthy and
 falsey by clojure, which is like blowing my mind.

You could argue the same way that since (1 2 3) and [1 2 3] are equal,
they represent the same value, and thus you should be able to call
`subvec' on both of them.

 Of course it's possible to say that one of ='s arguments is a java
 class, so you can't rely on it, but it just doesn't feel right for me.

Since you are complaining about =, do you mean that = should be
special-cased to do an identity-check instead of an equality check for
java.lang.Booleans?  E.g., are you demanding that (= false
(Boolean. false)) should be false?  That would be horrible.

Bye,
Tassilo

-- 
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: Supporting platform specific code

2012-04-12 Thread Tassilo Horn
Vinzent ru.vinz...@gmail.com writes:

 Such a feature shouldn't depend on a specific tool, it should be part
 of the language.

 Yeah, you're right - I haven't thought about the fact that leiningen
 isn't available on the platforms other than jvm and js.

And even if it was, why shouldn't I be allowed to build my clojure
projects with ant (like clojure itself) or maven?

Bye,
Tassilo

-- 
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: == is not always transitive

2012-04-12 Thread Patrick Houk
Yes, that is one reason why I tend to use BigDecimal instead of float
or double.  The thing that seems wrong to me is (not (== 1 1.0M)),
since these are both exact representations of the value one and the
doc for == says that it tests for equivalent value (type-
independent).

On Apr 11, 10:00 pm, Cedric Greevey cgree...@gmail.com wrote:
 IME, it's almost never useful to perform equality tests on floating
 point values. Generally you want to know if they're near enough to one
 another without necessarily being exactly equal. For that something
 like (defn f= [f1 f2 threshold] ( (Math/abs (- f1 f2)) threshold)) is
 probably the sort of thing you want.

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


[ANN]: new library for contract programming

2012-04-12 Thread Vinzent
Hello,

I'd like to announce 
clojure-contractshttps://github.com/dnaumov/clojure-contracts - 
a library for contract programming with emphasis on  good error messages. 
In short, it allows you to specify pre- and postconditions for an existing 
function, and then uses this information to improve the error 
messages significantly. Simple example from the readme:

user (defn foo [x] (+ x 5))
 
user (foo nil) ;=
 No message.
 [Thrown class java.lang.NullPointerException]
 
user (provide-contract foo (c/= number? number?))
 
user (foo nil) ;=
 Precondition failed for var #'user/foo 
 Expecting: number? 
 Given: nil

For the more detailed description of clojure-contracts and contract 
programming in general, please read the 
tutorialhttp://ubuntuone.com/4V1fhhEJnb14RGMloKIbIS
.

Note that this is a development version; it's not intended for the real use 
yet (although, the API is unlikely to change), but rather I need your 
feedback on it.

Source code: https://github.com/dnaumov/clojure-contracts
Documentation: tutorial http://ubuntuone.com/4V1fhhEJnb14RGMloKIbIS
Issue tracker: https://github.com/dnaumov/clojure-contracts/issues

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

2012-04-12 Thread Vinzent


 false and true are JVM built-ins.

Yes, but clojure uses this booleans as a basic type, in the same way as it 
does for lists and symbols.
 

 You could argue the same way that since (1 2 3) and [1 2 3] are equal,

 they represent the same value, and thus you should be able to call
 `subvec' on both of them.

Well, if we draw an analogy with subvec, then the behaviour we're 
discussing would rather be the same as if (subvec [1 2 3] 1) would return 
[2 3] and (subvec '(1 2 3) 1) would return haha, gotcha! :)

Since you are complaining about =, do you mean that = should be

 special-cased to do an identity-check instead of an equality check for
 java.lang.Booleans?  E.g., are you demanding that (= false
 (Boolean. false)) should be false?  That would be horrible.


It's not that I'm complaining about =, it's more about documentation and 
such kind of stuff. On the other hand, if we ignore the fact that = uses 
.equals under the hood, it'd be reasonable to return false in this case 
(because clojure doesn't really treat the two as equal things).

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

Re: Supporting platform specific code

2012-04-12 Thread Vinzent


 And even if it was, why shouldn't I be allowed to build my clojure
 projects with ant (like clojure itself) or maven?

Well, theoretically you could be able to do so, but yes, the problem is 
more fundamental and probably should be solved on a language level rather 
than one a tooling's one (of course, this doesn't affect the fact that 
https://github.com/lynaghk/cljx is cool :))

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

Re: [ANN] Leiningen 2.0.0-preview3

2012-04-12 Thread Michael Klishin
Phil Hagelberg:

 I'm happy to announce the release of the third preview of Leiningen 2.0.0.

lein2-preview3 is already live on travis-ci.org. More about using lein2 in our 
Clojure guide [1], see [2]
if you are only getting started.

1. http://about.travis-ci.org/docs/user/languages/clojure/
2. http://about.travis-ci.org/docs/user/getting-started/

MK

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

2012-04-12 Thread Andy Fingerhut
I know that having such things in the doc strings would probably be your
ideal, but note that clojuredocs.org is editable by anyone, and one could
in a few minutes create an account there and document what they consider
corner cases.

I don't know where you'd most like to find these kinds of notes.  I've just
added some examples on clojuredocs.org for if that explain these things,
and added links from cond, if-let, if-not, when, and a couple
others to see the example for if explaining Clojure's logical true and
false.  Check it out and see if it is what you would hope to find.

http://clojuredocs.org/clojure_core/clojure.core/if

The cheatsheet at http://clojure.org/cheatsheet (and the tooltip variants
available at http://jafingerhut.github.com) link to the clojuredocs pages,
so they have visibility to people who use the cheatsheet, or
clojuredocs.orgdirectly.

Andy

On Thu, Apr 12, 2012 at 2:27 PM, Vinzent ru.vinz...@gmail.com wrote:

 false and true are JVM built-ins.

 Yes, but clojure uses this booleans as a basic type, in the same way as it
 does for lists and symbols.


 You could argue the same way that since (1 2 3) and [1 2 3] are equal,

 they represent the same value, and thus you should be able to call
 `subvec' on both of them.

 Well, if we draw an analogy with subvec, then the behaviour we're
 discussing would rather be the same as if (subvec [1 2 3] 1) would return
 [2 3] and (subvec '(1 2 3) 1) would return haha, gotcha! :)

 Since you are complaining about =, do you mean that = should be

 special-cased to do an identity-check instead of an equality check for
 java.lang.Booleans?  E.g., are you demanding that (= false
 (Boolean. false)) should be false?  That would be horrible.


 It's not that I'm complaining about =, it's more about documentation and
 such kind of stuff. On the other hand, if we ignore the fact that = uses
 .equals under the hood, it'd be reasonable to return false in this case
 (because clojure doesn't really treat the two as equal things).


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

Loading a huge graph

2012-04-12 Thread László Török
Hi,

I'm trying figure out how to load a huge file that contains some 800k pair
of integers (two integers per line) which represent edges of a directed
graph.

So if the ith line has x and y, it means that there is an edge between x
and y vertex in the graph.

The goal is to load it in an array of arrays representation, where the kth
array contains all the nodes, where there is a directed edge from the kth
node to those nodes.

I've attempted multiple variants of with-open reader and line-seq etc. but
almost always ended up with OutMemoryException or sg VERY slow.

My latest attempt that also does not work on the large input:

(defn load-graph [input-f]
  (with-open [rdr (io/reader input-f)]
(- (line-seq rdr)
(map (fn [row]
   (let [[v1str v2str] (str/split row #\s)]
   [ (Integer/parseInt v1str) (Integer/parseInt v2str) ]))
  )
(reduce (fn [G [v1 v2]]
  (if-let [vs (get G v1)]
(update-in G [v1] #(conj % v2))
(assoc G v1 [v2])))  { }  

I'm getting a bit frustrated as there are Python, Go implementations that
load the graph in less the 5 seconds.

What am I doing wrong?

Thanks

-- 
László Török

-- 
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: Loading a huge graph

2012-04-12 Thread David Nolen
How much memory do Python  Go consume when you do this? Are you giving the
JVM enough memory?

On Thu, Apr 12, 2012 at 6:17 PM, László Török ltoro...@gmail.com wrote:

 Hi,

 I'm trying figure out how to load a huge file that contains some 800k pair
 of integers (two integers per line) which represent edges of a directed
 graph.

 So if the ith line has x and y, it means that there is an edge between x
 and y vertex in the graph.

 The goal is to load it in an array of arrays representation, where the kth
 array contains all the nodes, where there is a directed edge from the kth
 node to those nodes.

 I've attempted multiple variants of with-open reader and line-seq etc. but
 almost always ended up with OutMemoryException or sg VERY slow.

 My latest attempt that also does not work on the large input:

 (defn load-graph [input-f]
   (with-open [rdr (io/reader input-f)]
 (- (line-seq rdr)
 (map (fn [row]
(let [[v1str v2str] (str/split row #\s)]
[ (Integer/parseInt v1str) (Integer/parseInt v2str) ]))
   )
 (reduce (fn [G [v1 v2]]
   (if-let [vs (get G v1)]
 (update-in G [v1] #(conj % v2))
 (assoc G v1 [v2])))  { }  

 I'm getting a bit frustrated as there are Python, Go implementations that
 load the graph in less the 5 seconds.

 What am I doing wrong?

 Thanks

 --
 László Török

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

2012-04-12 Thread mnicky

The cheatsheet at http://clojure.org/cheatsheet (and the tooltip variants 
available at http://jafingerhut.github.com) link to the clojuredocs pages, 
so they have visibility to people who use the cheatsheet, or 
clojuredocs.orgdirectly.

Or anyone else who uses this awesome feature of leinigen 2: (clojuredocs if)

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

2012-04-12 Thread mnicky



 The cheatsheet at http://clojure.org/cheatsheet (and the tooltip variants 
 available at http://jafingerhut.github.com) link to the clojuredocs 
 pages, so they have visibility to people who use the cheatsheet, or 
 clojuredocs.org directly.


or anyone else who uses this awesome feature of leinigen: (clojuredocs if)

-- 
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: Supporting platform specific code

2012-04-12 Thread Herwig Hochleitner
As I remember, Rich Hickey solicited input on this matter in his Conj
'11 Keynote.
Maybe these and other proposals would fit into
http://dev.clojure.org/display/design/Cross-Dialect+Enhancements

kind regards

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

2012-04-12 Thread Armando Blancas


  'false' is a clojure built-in,

 false and true are JVM built-ins.

LOL. Don't let him get away with anything!

-- 
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: Loading a huge graph

2012-04-12 Thread Alex Robbins
Yeah, sounds like it could definitely be a memory issue. This is one
part where the JVM works a lot differently than I expected coming from
a python background.

Everybody may already know this, but the JVM only takes 64mb for the
heap by default. You'll get an out of memory error if your program
uses more than that. In contrast, python just takes all the memory it
needs. As your program gets closer to the JVM memory limit it'll spend
more and more time doing garbage collection, with less and less real
work getting done. You can pass an -Xmx flag to give java access to
more memory, which many (most?) programs do.


On Thu, Apr 12, 2012 at 5:22 PM, David Nolen dnolen.li...@gmail.com wrote:
 How much memory do Python  Go consume when you do this? Are you giving the
 JVM enough memory?


 On Thu, Apr 12, 2012 at 6:17 PM, László Török ltoro...@gmail.com wrote:

 Hi,

 I'm trying figure out how to load a huge file that contains some 800k pair
 of integers (two integers per line) which represent edges of a directed
 graph.

 So if the ith line has x and y, it means that there is an edge between x
 and y vertex in the graph.

 The goal is to load it in an array of arrays representation, where the kth
 array contains all the nodes, where there is a directed edge from the kth
 node to those nodes.

 I've attempted multiple variants of with-open reader and line-seq etc. but
 almost always ended up with OutMemoryException or sg VERY slow.

 My latest attempt that also does not work on the large input:

 (defn load-graph [input-f]
   (with-open [rdr (io/reader input-f)]
     (- (line-seq rdr)
         (map (fn [row]
                (let [[v1str v2str] (str/split row #\s)]
                    [ (Integer/parseInt v1str) (Integer/parseInt v2str) ]))
   )
         (reduce (fn [G [v1 v2]]
                   (if-let [vs (get G v1)]
                     (update-in G [v1] #(conj % v2))
                     (assoc G v1 [v2])))  { }  

 I'm getting a bit frustrated as there are Python, Go implementations that
 load the graph in less the 5 seconds.

 What am I doing wrong?

 Thanks

 --
 László Török

 --
 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: Supporting platform specific code

2012-04-12 Thread Dave Sann
-1 for metadata
+1 for file extensions or paths.

I don't think metadata or in-file conditional compilation is the right tool 
for this.

My reasons are as follows

1. I don't think it is a good idea to mix multi-platform definitions in one 
file. it gets complicated and confusing very quickly. You cant see the wood 
for the trees.
2. What about adding a new platform - do you edit the existing files or add 
a new one.
3. Different platform specifics could be maintained by different teams with 
only the port code required. Most people will not care about every platform.
4. Separating them means that you can very easily see what is platform 
specific and port. You can also easily produce separate source 
distributions if you so wish. 
5. If you add metadata - then the complier must read the file in order to 
decide whether it needs to look process the contents or not. This will 
increase build times substantially as you add platforms.

I don't know about platform versions - that could get very complicated.

If following the extension route, you would also require an extension for 
generic clojure code vs jvm platform code in addition to the others.

I like the idea of separate, parallel source paths:
e.g.

src/clj/blah.clj;; pure clojure
src/jvm/blah.clj  ;; for the jvm
src/py/blah.clj;; etc
src/clr/blah.clj
src/cljs/blah.clj

maybe - but not sure
src/jvm/1.7/blah.clj ;; for the jvm (1.7)


My tuppence worth.

Dave

On Friday, 13 April 2012 02:56:59 UTC+10, tbc++ wrote:

 I've been thinking lately how to seamlessly merge clojure-py and
 clojure-jvm code in the same packages. This is something I know has
 been discussed in the past, but I'm just looking for
 ideas/brainstorming on how we can solve this problem.

 Let's begin by explaining the problem. Let's assume that my project
 needs a platform specific way to convert a int to a string:

 On clojure-jvm:

 (defn to-string [i] (.toString Integer i))

 On clojure-py:

 (defn to-string [i] (py/str i))

 On Clojurescript:

 (defn to-string [i] (.toString i))


 We could do this inline (inside a common .clj file):

 (for-platform jvm
   (defn to-string [i] (.toString Integer i))
   python
   (defn to-string [i] (py/str i))
   js
   (defn to-string [i] (.toString i)))

 But this gets ugly real fast.

 My idea, would be to provide some sort of hook to the compiler, that
 would be cross-platform. The compiler, when looking for a namespace,
 would find all files in a given folder that match the required
 namespace:

 /test/to_string.clj
 /test/to_string.cljpy
 /test/to_string.cljs
 /test/to_string.cljclr

 These function hooks would then pick the best entry based on the
 extension, defaulting to .clj if no better option exists. Since these
 functions could be composable it would be possible to also dispatch on
 platform versions:

 /test/to_string.cljpy26   ; Python 2.6 code
 /test/to_string.clj7; JVM 7 code

 It seems to me that this would be a very clean way to allow clojure
 programs to be cross-platform. The side-effect is that it would force
 non-standard code out into separate namespaces where they can be
 easily maintained. If someone wanted to port the project to a new
 platform, he would need only to find existing platform overrides, and
 create new entries.


 Thoughts?

 Timothy Baldridge



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

Re: [ANN] Leiningen 2.0.0-preview3

2012-04-12 Thread Jacek Laskowski
On Thu, Apr 12, 2012 at 11:39 PM, Michael Klishin
michael.s.klis...@gmail.com wrote:

 1. http://about.travis-ci.org/docs/user/languages/clojure/

I believe it begs for the following change:

s/Standalone Leiningen 2.0.0 [preview 2]./Standalone Leiningen 2.0.0
[preview 3]./

in CI environment for Clojure Projects.

Jacek

-- 
Jacek Laskowski
Functional languages (Clojure), Java EE, and IBM WebSphere -
http://blog.japila.pl
Never discourage anyone who continually makes progress, no matter how
slow. Plato

-- 
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: Supporting platform specific code

2012-04-12 Thread Aaron Cohen
On Thu, Apr 12, 2012 at 11:31 PM, Dave Sann daves...@gmail.com wrote:

 -1 for metadata
 +1 for file extensions or paths.

 I don't think metadata or in-file conditional compilation is the right
 tool for this.

 My reasons are as follows

 1. I don't think it is a good idea to mix multi-platform definitions in
 one file. it gets complicated and confusing very quickly. You cant see the
 wood for the trees.
 2. What about adding a new platform - do you edit the existing files or
 add a new one.
 3. Different platform specifics could be maintained by different teams
 with only the port code required. Most people will not care about every
 platform.
 4. Separating them means that you can very easily see what is platform
 specific and port. You can also easily produce separate source
 distributions if you so wish.
 5. If you add metadata - then the complier must read the file in order to
 decide whether it needs to look process the contents or not. This will
 increase build times substantially as you add platforms.

 I don't know about platform versions - that could get very complicated.

 If following the extension route, you would also require an extension for
 generic clojure code vs jvm platform code in addition to the others.

 I like the idea of separate, parallel source paths:
 e.g.

 src/clj/blah.clj;; pure clojure
 src/jvm/blah.clj  ;; for the jvm
 src/py/blah.clj;; etc
 src/clr/blah.clj
 src/cljs/blah.clj


I think all your concerns can be addressed by carefully using the metadata
solution?

ie, In file lib.clj (the generic api):

(ns lib)

(declare fns-to-be-implemented-in-platform-code)

(defn general-api-fn)

^{:platform :jvm} (load jvm/lib)
^{:platform :python} (load python/lib)

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

where do you put the docstring in a deftype declaration?

2012-04-12 Thread Frank Siebenlist
Confusingly yours, FrankS.

-- 
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: where do you put the docstring in a deftype declaration?

2012-04-12 Thread Alan Malloy
A deftype creates a java class, not a clojure var. Classes have no
slots to store a docstring. Just put a comment somewhere.

On Apr 12, 9:52 pm, Frank Siebenlist frank.siebenl...@gmail.com
wrote:
 Confusingly yours, FrankS.

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


ANN: Strange Loop 2012

2012-04-12 Thread Alex Miller
---
Strange Loop 2012
 St. Louis, MO - Sept 24-25, 2012
   Preconference - Sept 23, 2012
 http://thestrangeloop.com
---

Strange Loop is a multi-technology conference exploring the ways in 
which software developers are creating systems that work at new scale,
provide new means of interaction, or create new ways of building systems.

Strange Loop typically covers topics like distributed systems, 
concurrency, mobile, web, and programming languages but it is open to a 
wide variety of ideas. Strange Loop is primarily focused on commercial 
users but also includes talks from the academic world, especially if they
are in areas that are impacting practice. 

For ideas of typical talks, see the list of 2011 talks at 
http://thestrangeloop.com/archive/2011. 

Registration is open now:
* Registration - http://regonline.com/strangeloop2012

PRESENTATIONS
---
The conference takes place on Mon Sept 24 - Tues Sept 25, 2012.  There is 
also an optional preconference day on Sun Sept 23 for paid workshops and 
the Emerging Languages Camp.

* Workshops - http://thestrangeloop.com/preconf
* Emerging Languages Camp - http://thestrangeloop.com/preconf
* Conference - http://thestrangeloop.com/sessions

The conference Call for Presentations is open now for both 50 and 20 
minute talks. Strange Loop speakers (both 20 and 50 minute) receive free 
admission to Strange Loop, free hotel, and (for 50 minute speakers only) 
free US air fare (international speakers receive a stipend instead).  

* Call for presentations closes - May 11th, 2012
* Speaker notification - by May 18th, 2012
* CFP - https://thestrangeloop.com/sessions-page/call-for-presentations

- Alex Miller

-- 
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: Supporting platform specific code

2012-04-12 Thread Tassilo Horn
Aaron Cohen aa...@assonance.org writes:

 I think all your concerns can be addressed by carefully using the
 metadata solution?

 ^{:platform :jvm} (load jvm/lib)
 ^{:platform :python} (load python/lib)

But why would that be better than a reader macro

  #+:jvm(load jvm/lib)
  #+:python (load python/lib)

or a usual macro?  IMO, metadata is good for metainformation that
someone (a human, the compiler) wants to access later, not for
consumption by the lisp reader.  Or would the non-matching forms still
be read but not compiled afterwards?  In that case, you get problems
with

  ^{:platform :jvm} 1
  ^{:platform :python} 0

because metadata cannot be attached to numbers.

Bye,
Tassilo

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