Why can't I use/require namespaces not associated with files?

2011-11-18 Thread Tassilo Horn
Hi all,

why does the existance of a namespace not suffice to use or require it?
Currently, with clojure 1.3, it has to be associated with a class or
clojure file.

Here's a simple example REPL session:

--8---cut here---start-8---
user (ns test)
nil
test (defn foo [x] (+ 2 x))
#'test/foo
test (in-ns 'user)
#Namespace user
user (test/foo 2)
4
user (find-ns 'test)  ;; finding works
#Namespace test
user (use 'test)  ;; using doesn't work
Could not locate test__init.class or test.clj on classpath: 
  [Thrown class java.io.FileNotFoundException]
; Evaluation aborted
user (require '[test :as t])  ;; neither does requiring
Could not locate test__init.class or test.clj on classpath: 
  [Thrown class java.io.FileNotFoundException]
; Evaluation aborted
user (refer 'test);; referring does work
nil
user (foo 2)
4
--8---cut here---end---8---

So while I can't use or require it, I can refer it.  However, what I
really want to do is to require it with some short alias.
Unfortunately, refer doesn't support an :as option.

Why I think I need that: I'm playing around with core.logic, and there I
generate relations (defrel, which in the end defines a Var with def)
from some spec I get at runtime.  In order not to clutter *ns*, I do
that in some new namespace by generating some do-form with ns and tons
of defrels, and then evaling that.

After the relations are there, I want to populate them with facts.
Since there can be many fact bases for the relations, I use another
namespace.  In that, I want to easily access the relations using some
prefix, as (require 'foo :as 'f) would allow.  I can't really refer that
namespace, because it's highly likely that some relation names clash
with clojure.core defs.

For the time being, I've changed my code a bit to prefix all relations
with a +, but artificial prefixing is just not right if you have
namespaces...

Bye,
Tassilo
-- 
(What the world needs (I think) is not
  (a Lisp (with fewer parentheses))
  but (an English (with more.)))
Brian Hayes, http://tinyurl.com/3y9l2kf

-- 
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: Review my code - delay-map

2011-11-18 Thread Chris Perkins
Meikel,

That's very helpful. You and I took essentially the same approach - wrap a 
real map and delegate most operations to it. You used deftype, which I 
was afraid to try because there seemed to be too many interfaces and too 
many methods to implement, so I used proxy and APersistentMap to get some 
of it for free. I see from your code that there aren't nearly as many as I 
had feared.

Your code has helped me to answer most of the questions I had.

Thanks,

- Chris

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

Literate Programming example

2011-11-18 Thread daly
Many of you asked me to show an example of a literate
program and demonstrate the use of the tangle function.

I usually use Latex for literate work but I've done
this example using HTML and pre id=foo tags.

I've written a self-referential literate program that
explains the details of the tangle function in literate
form. You can find the web page at

http://daly.literatesoftware.com/lithtml/litprog.html

and the source for the tangle function (which is in the
web page but)

http://daly.literatesoftware.com/lithtml/tangle.c

I appreciate the time and attention you all gave me at
the Clojure Conj. Hopefully someone will catch the ah-ha
and write a literate program for next year's Conj.

Tim Daly
d...@literatesoftware.com


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


Re: Review my code - delay-map

2011-11-18 Thread Meikel Brandmeyer (kotarak)
Hi,

glad it helped. There are still intresting questions. For example 
transients. It'd sure be interesting to have this also.

Meikel

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

Re: Why can't I use/require namespaces not associated with files?

2011-11-18 Thread Stephen Gilardi



why does the existance of a namespace not suffice to use or require it?
Currently, with clojure 1.3, it has to be associated with a class or
clojure file.



The primary purpose of both use and require is to load code from a file in 
classpath.



So while I can't use or require it, I can refer it. However, what I
really want to do is to require it with some short alias.
Unfortunately, refer doesn't support an :as option.


For the purpose you describe, alias should work. (:as uses alias to do its job)

user (doc alias)
-
clojure.core/alias
([alias namespace-sym])
 Add an alias in the current namespace to another
 namespace. Arguments are two symbols: the alias to be used, and
 the symbolic name of the target namespace. Use :as in the ns macro in 
preference
 to calling this directly.

--Steve


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

Re: Literate Programming example

2011-11-18 Thread Chas Emerick

On Nov 18, 2011, at 7:17 AM, daly wrote:

 http://daly.literatesoftware.com/lithtml/litprog.html

FYI, this is 404 at the moment.

- Chas

-- 
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: Literate Programming example

2011-11-18 Thread daly
sigh. Try 

http://daly.axiom-developer.org/lithtml/litprog.html


On Fri, 2011-11-18 at 07:46 -0500, Chas Emerick wrote:
 On Nov 18, 2011, at 7:17 AM, daly wrote:
 
  http://daly.literatesoftware.com/lithtml/litprog.html
 
 FYI, this is 404 at the moment.
 
 - Chas
 


-- 
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: Why can't I use/require namespaces not associated with files?

2011-11-18 Thread Tassilo Horn
Stephen Gilardi squee...@mac.com writes:

Hi!

 Currently, with clojure 1.3, it has to be associated with a class or
 clojure file.

 The primary purpose of both use and require is to load code from a
 file in classpath.

Sure.  But when you say primary you imply there's also a secondary
purpose.

 So while I can't use or require it, I can refer it. However, what I
 really want to do is to require it with some short alias.
 Unfortunately, refer doesn't support an :as option.

 For the purpose you describe, alias should work. (:as uses alias to do
 its job)

Hey, that looks like what I'm looking for. :-)

Thanks a lot,
Tassilo
-- 
(What the world needs (I think) is not
  (a Lisp (with fewer parentheses))
  but (an English (with more.)))
Brian Hayes, http://tinyurl.com/3y9l2kf

-- 
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: Literate Programming example

2011-11-18 Thread daly
I believe I fixed it.
Please try it again and let me know.

Tim

On Fri, 2011-11-18 at 07:46 -0500, Chas Emerick wrote:
 On Nov 18, 2011, at 7:17 AM, daly wrote:
 
  http://daly.literatesoftware.com/lithtml/litprog.html
 
 FYI, this is 404 at the moment.
 
 - Chas
 


-- 
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: Literate Programming example

2011-11-18 Thread László Török
it works for me.
Las

2011/11/18 daly d...@axiom-developer.org

 I believe I fixed it.
 Please try it again and let me know.

 Tim

 On Fri, 2011-11-18 at 07:46 -0500, Chas Emerick wrote:
  On Nov 18, 2011, at 7:17 AM, daly wrote:
 
   http://daly.literatesoftware.com/lithtml/litprog.html
 
  FYI, this is 404 at the moment.
 
  - Chas
 


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




-- 
László Török

Skype: laczoka2000
Twitter: @laczoka

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

All Contributor Agreements from the Clojure/conj have been added

2011-11-18 Thread Christopher Redinger
Over 50 new CAs have been signed. If you have signed one, you should see 
your name on this list: http://clojure.org/contributing.

Thanks everybody!

-- 
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: ClojureScript: Should 'advanced optimizations' lead to faster execution? (or just faster loading)

2011-11-18 Thread Stuart Sierra
On Nov 17, 5:18 pm, Paul Richards paul.richa...@gmail.com wrote:
 Aside from loading times (due to different file sizes) and memory
 usage (again due to different file sizes, minified field names, etc),
 do we expect the optimized version to execute faster?

Theoretically, yes, because GClosure Advanced Mode does some
optimizations like inlining. In practice, probably not much, because a
good JavaScript interpreter will do the same optimizations at runtime.

-S

-- 
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: Change var in other namespace

2011-11-18 Thread vitalyper
Thanks, Sean. Exactly what I was looking for.
IMO, clojure.tools.logging could of made this easier: log
implementation from classpath by default with override by client when
needed.

On Nov 17, 11:32 pm, Sean Corfield seancorfi...@gmail.com wrote:
 Note: if you just want something that will execute at startup and
 force _all_ logging to use log4j, instead of wrapping code in (binding
 ..) then you probably want something like this:

 (ns your.namespace
   (:require [clojure.tools.logging :as log])
   (:require [clojure.tools.logging.impl :as impl]))

 (alter-var-root (var log/*logger-factory*) (constantly (impl/log4j-factory)))

 This is what we ended with in our code to ensure log4j was selected at
 startup...

 Sean







 On Thu, Nov 17, 2011 at 7:04 PM, Mark Rathwell mark.rathw...@gmail.com 
 wrote:
  You rebind dynamic vars with binding, so your use would look something
  like this:

  (binding [*logger-factory* (log-impl/log4j-factory)]
   (do-stuff-with-the-logger-factory-rebound))

  On Thu, Nov 17, 2011 at 5:17 PM, vitalyper vitaly...@yahoo.com wrote:
  clojure.tools.logging defines *logger-factory* and initializes it with
  first logger implementation on the class path

  (def ^{:doc
   An instance satisfying the impl/LoggerFactory protocol. Used
  internally to
    obtain an impl/Logger. Defaults to the value returned from impl/
  find-factory.
   :dynamic true}
   *logger-factory*
   (impl/find-factory))

  In my own namespace I want to redefine *logger-factory* to log4j one.
  Tried different variations (def, set!, etc) in 1.3.0 with no avail.
  (ns my.foo
   (:gen-class)
   (:use
     [clojure.tools.logging :only (*logger-factory* info debug)])
   (:require
             [clojure.string :as s1]
             [clojure.tools.logging.impl :as log-impl])
  )

  (defn init-logging
   Force log4j factory for core tools logging
   []
   (def *logger-factory* (log-impl/log4j-factory)))
  ; CompilerException java.lang.IllegalStateException: *logger-factory*
  already refers to: #'clojure.tools.logging/*logger-factory* in
  namespace: infrared.common

-- 
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: Literate Programming example

2011-11-18 Thread bernardH


On Nov 18, 1:17 pm, daly d...@axiom-developer.org wrote:
 Many of you asked me to show an example of a literate
 program and demonstrate the use of the tangle function.

Thanks to your perseverance, I am looking into practicing literate
programming.

However, I decided to settle for emacs org-mode environment with the
literate elisp for the relevant code (abel'part of org-mode)
being here : http://eschulte.github.com/org-babel/org-babel.org.html
I found an example of clojure project (research on genetic
programming) written in literate programming using babel org-mode for
emacs
is hosted here :
http://gitweb.adaptive.cs.unm.edu/asm.git/tree

I do hope that others find those resources as useful as I found them.

Best Regards,

Bernard

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


Use of eval

2011-11-18 Thread vitalyper
Came across this code in clojure.tools.logging

(defn cl-factory
  Returns a Commons Logging-based implementation of the LoggerFactory
protocol, or
  nil if not available.
  []
  (try
(Class/forName org.apache.commons.logging.Log)
(eval
  `(do
 (extend org.apache.commons.logging.Log
   Logger
   {:enabled?
(fn [logger# level#]
  (condp = level#
:trace (.isTraceEnabled logger#)
:debug (.isDebugEnabled logger#)
:info  (.isInfoEnabled  logger#)
:warn  (.isWarnEnabled  logger#)
:error (.isErrorEnabled logger#)
:fatal (.isFatalEnabled logger#)
(throw (IllegalArgumentException. (str level#)
:write!
(fn [logger# level# e# msg#]
  (if e#
(condp = level#
  :trace (.trace logger# msg# e#)
  :debug (.debug logger# msg# e#)
  :info  (.info  logger# msg# e#)
  :warn  (.warn  logger# msg# e#)
  :error (.error logger# msg# e#)
  :fatal (.fatal logger# msg# e#)
  (throw (IllegalArgumentException. (str level#
(condp = level#
  :trace (.trace logger# msg#)
  :debug (.debug logger# msg#)
  :info  (.info  logger# msg#)
  :warn  (.warn  logger# msg#)
  :error (.error logger# msg#)
  :fatal (.fatal logger# msg#)
  (throw (IllegalArgumentException. (str
level#))})
 (reify LoggerFactory
   (name [_#]
 org.apache.commons.logging)
   (get-logger [_# logger-ns#]
 (org.apache.commons.logging.LogFactory/getLog (str logger-
ns#))
(catch Exception e nil)))

I do understand what it does with extend and reify but I am not clear
why eval is needed 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


Blog: SQL in Clojure

2011-11-18 Thread Herwig Hochleitner
Hello,

I wanted to summarize my thoughts on the current state of SQL in
clojure, with respect to the new library, Korma, to get a discussion
going.
It turned out to be too long for the ML, so I blogged it:
http://thinkrevoactevo.blogspot.com/2011/11/sql-in-clojure.html

enjoy
-- 
__
Herwig Hochleitner

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


Re: Use of eval

2011-11-18 Thread Gary Trakhman
My speculation is that the eval is required in the case that commons-logger 
is not in the classpath.  The code wouldn't compile without it.

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

Re: Use of eval

2011-11-18 Thread vitalyper
I don't think you are right - it does compiles without it.
After more thinking my guess is that eval is used to combine extend
and reify in the same function. Let's see if somebody else could shed
a light on this.

On Nov 18, 12:45 pm, Gary Trakhman gary.trakh...@gmail.com wrote:
 My speculation is that the eval is required in the case that commons-logger
 is not in the classpath.  The code wouldn't compile without it.

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


Re: Debugging Java heap space memory error with lazy sequences.

2011-11-18 Thread Julian Kelsey
Thanks!

To confirm my understanding: in my original version I defined (using def) a
reference to a lazy sequence. I then evaluated it, using nth to pick a
value from the sequence. Because I have a reference to the beginning of the
sequence all the lazily generated items are retained. I.e. the lazy
sequence is lazy only for the first time it works through the sequence
instance, if there is a live reference to the sequence then those now
generated elements remain, (to avoid the overhead of regenerating them?).

By providing a function to return a new instance of the sequence each time,
as in the solution Meikel has provided, I avoid retaining any references to
the front of the sequence, and the garbage collector can do it's work.

I always learn much better by making mistakes like these.


Cheers,
Julian.

On Thu, Nov 17, 2011 at 9:49 PM, Meikel Brandmeyer m...@kotka.de wrote:

 Hi,

 this is a “hold unto head” problem.

 Am 17.11.2011 um 15:06 schrieb Julian Kelsey:

(def seq-3s-n-5s
  (filter
(fn [n] (or (= 0 (mod n 5)) (= 0 (mod n 3)) ) )
(iterate inc 1)))

 Here you keep a reference to the head of the generated by iterate. Make it
 a function:

 (defn seq-3s-n-5s
  []
  (filter #(or (zero? (mod % 5)) (zero? (mod % 3))) (iterate inc 1)))

 Then call it like this:

 (nth (sums (seq-3s-n-5s 0) (Math/pow 10 6))

 That should fix your problem.

 Sincerely
 Meikel

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

-- 
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: Latest Bagwell paper for a new implementation of Clojure vectors ?

2011-11-18 Thread logan
Are there currently any plans to eventually replace PersistentVector? 
Looking at the code, the upper limit for the number of elements that can be 
stored in PersistentVector is 32^6, which is quite a lot but still might 
become a real limitation in the near future. 

-- 
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: Literate Programming example

2011-11-18 Thread daly
On Fri, 2011-11-18 at 07:07 -0800, bernardH wrote:
 
 On Nov 18, 1:17 pm, daly d...@axiom-developer.org wrote:
  Many of you asked me to show an example of a literate
  program and demonstrate the use of the tangle function.
 
 Thanks to your perseverance, I am looking into practicing literate
 programming.
 
 However, I decided to settle for emacs org-mode environment with the
 literate elisp for the relevant code (abel'part of org-mode)
 being here : http://eschulte.github.com/org-babel/org-babel.org.html
 I found an example of clojure project (research on genetic
 programming) written in literate programming using babel org-mode for
 emacs
 is hosted here :
 http://gitweb.adaptive.cs.unm.edu/asm.git/tree
 
 I do hope that others find those resources as useful as I found them.

I have nothing against org-mode. Indeed, I've been an emacs user
since I could spell it.

I believe the above examples are not literate programmings. They miss
the point completely. They are using emacs org-mode for DOCUMENTATION.

Literate programming is NOT documentation. It is a way to communicate
from one person to another by starting from ideas and reducing them to
practice.

I may have missed the point but the above programs are just fancier
ways of 1970 style coding using a new format tool.

Compare the example I gave at
http://axiom-developer.org/axiom-website/litprog.html
with the above programs. See if you can spot a qualitative difference.
My literate program tries to motivate the need for tangle, to explain
why it works in a development context, and then gets down to details
of implementation. It is a story.

Where does this happen in the org-mode example? Perhaps I missed
something but the author does not seem to be concentrating on 
communicating their ideas to me. Where did I go wrong? What 
emacs keystrokes get me a copy of the full document to read? 

Literate programming is about communication, not documentation.
The org-mode tool is perfectly fine but be very, very careful
not to miss this fundamental point.

People should be able to just pick up clojure-core and read it
like a novel, from ideas to implementation, and be able to 
understand it enough to change it. If your code can pass this
independence test then your code is literate.

Tim


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


repl dodges ns :use :only ?

2011-11-18 Thread Andrew
I'm surprised that I can do the following. Am I wrong about namespaces?

   1. M-x clojure-jack-in
   2. at the repl, execute (ns my-proj.core)
   3. compile my core.clj (see ns snippet below)
   4. back in the repl, use a function from a library that wasn't included 
   in the :only clause from my core.clj file: 

(ns my-proj.core
  (:use [clj-webdriver.core :as cw :only (attribute
  exists?
  find-it
  flash)]))

I thought the :only clause here limits my use of the library to these four 
functions... But at the repl, I'm able to use cw/start ... 

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

Re: repl dodges ns :use :only ?

2011-11-18 Thread Chas Emerick
The :as clause establishes an alias for the entire clj-webdriver.core 
namespace.  The value of :only lists the vars from that namespace that are 
referred into my-proj.core, which you can use without qualification e.g. 
`(attribute …)` will work, but `(start …)` won't.  Both `(cw/attribute …)` and 
`(cw/start …)` will work because of the alias.

- Chas

On Nov 18, 2011, at 4:36 PM, Andrew wrote:

 I'm surprised that I can do the following. Am I wrong about namespaces?
 M-x clojure-jack-in
 at the repl, execute (ns my-proj.core)
 compile my core.clj (see ns snippet below)
 back in the repl, use a function from a library that wasn't included in the 
 :only clause from my core.clj file:
 (ns my-proj.core
   (:use [clj-webdriver.core :as cw :only (attribute
   exists?
   find-it
   flash)]))
 
 I thought the :only clause here limits my use of the library to these four 
 functions... But at the repl, I'm able to use cw/start ... 
 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

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

Re: Use of eval

2011-11-18 Thread Gary Trakhman
I get this when i try it in a blank project, removing the eval and the 
quote:


Unknown location:
  error: java.lang.ClassNotFoundException: org.apache.commons.logging.Log

core.clj:16:8:
  error: java.lang.ClassNotFoundException: org.apache.commons.logging.Log 
(core.clj:16)

Compilation failed.

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

Re: repl dodges ns :use :only ?

2011-11-18 Thread Andrew
Oh, thanks. Is there a way to import some functions and not others such 
that the others cannot be used at all? 

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

Re: repl dodges ns :use :only ?

2011-11-18 Thread Sam Ritchie
Sure, just remove the :as argument:

(ns example.ns
   (:use [clojure.string :only (join)])

On Friday, November 18, 2011, Andrew ache...@gmail.com wrote:
 Oh, thanks. Is there a way to import some functions and not others such
that the others cannot be used at all?

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

-- 
Sam Ritchie, Twitter Inc
703.662.1337
@sritchie09

(Too brief? Here's why! http://emailcharter.org)

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

Re: Probabilistic programming in clojure

2011-11-18 Thread Nils Bertschinger
On Nov 18, 8:05 am, Konrad Hinsen googlegro...@khinsen.fastmail.net
wrote:
 --On 17 novembre 2011 15:09:11 -0800 Nils Bertschinger

 nils.bertschin...@googlemail.com wrote:
  The two approaches are somewhat complementary to each other. Your
  monad does exact inference on discrete distributions by running
  through all possibilities. Mine is sampling based and does approximate
  inference using MCMC.

 I tried that approach as well:

 https://github.com/richhickey/clojure-contrib/blob/master/src/main/cl...

 but I never used it much because for my own applications, exact inference
 was very doable. I'll check out yours for comparison!

Just checked your implementation, the stream approach is indeed quite
nice to thread random numbers through programs. It seems that I handle
downstream conditioning somewhat different. The stream can basically
be filtered to implement rejection sampling, whereas I thread a
database state through the program to record all random choices (as
well as their probability) that have been taken. That way conditioning
does not have to be based on rejection, but is simply accounted for by
including the probability of the conditioned value. Then I can propose
a change to this database store, re-run the program and implement
Metropolis Hastings sampling on top of this, i.e. test whether the
change increased the probability of the random decisions taken
throughout the program and either accept or reject it accordingly.
Your stream approach can probably be nicely extended to particle
filters. I'll think about that ...

Nils

 Konrad.

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


Re: Change var in other namespace

2011-11-18 Thread Sean Corfield
On Fri, Nov 18, 2011 at 6:35 AM, vitalyper vitaly...@yahoo.com wrote:
 IMO, clojure.tools.logging could of made this easier: log
 implementation from classpath by default with override by client when
 needed.

I agree but when I brought the issue up, there didn't seem to be much
support for making it easier... Perhaps a ticket in JIRA might garner
some votes?
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
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: Literate Programming example

2011-11-18 Thread Daniel Jomphe
On Friday, November 18, 2011 7:17:08 AM UTC-5, TimDaly wrote:

 Many of you asked me to show an example of a literate
 program and demonstrate the use of the tangle function.

 I usually use Latex for literate work but I've done
 this example using HTML and pre id=foo tags.

 I've written a self-referential literate program that
 explains the details of the tangle function in literate
 form. You can find the web page at

 http://daly.literatesoftware.com/lithtml/litprog.html

I have read your literate program, and must recognize that I know how 
tangle works even though I didn't want to really read the source code. I 
read your prose all the way through. I still haven't read the source code; 
I didn't feel the need to read it. Were I to maintain your program, I'd 
have more than enough confidence to start hacking the code right now.

I think this speaks very positively about literate programming. What 
remains to be seen is how much (or not) I'm going to practice it in the 
future.

What do you think of marginalia? It's a bit the reverse of tangle; it 
assembles all those 70's files together into this book you might want to 
read. Is it sound or not? Have your thoughts changed from what you wrote in 
[1]?

[1] http://goo.gl/cXWzF

-- 
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: Literate Programming example

2011-11-18 Thread TimDaly
On Fri, 2011-11-18 at 20:02 -0800, Daniel Jomphe wrote:
 On Friday, November 18, 2011 7:17:08 AM UTC-5, TimDaly wrote:
 Many of you asked me to show an example of a literate
 program and demonstrate the use of the tangle function.

 I usually use Latex for literate work but I've done
 this example using HTML and pre id=foo tags.

 I've written a self-referential literate program that
 explains the details of the tangle function in literate
 form. You can find the web page at

 http://daly.literatesoftware.com/lithtml/litprog.html

 I have read your literate program, and must recognize that I know how
 tangle works even though I didn't want to really read the source code.
 I read your prose all the way through. I still haven't read the source
 code;

In fact, that's the whole point. You don't read the equations in a
calculus textbook either. You read the words. The equations are icons.
If you understood the text and spoke mathematics you could probably
write the equations.

In programming we can reach the same level of literacy. Reading just
the words in the literate version it should be possible to recreate
the program in your favorite language. Note that you would be creating
a different program with different design decisions but the same
functionality.

 I didn't feel the need to read it. Were I to maintain your program,
 I'd have more than enough confidence to start hacking the code right
 now.

One thing worth trying would be to code the same program in Clojure.

The tangle program is conceptually very simple but there are a lot
of low level design decisions that I would make differently. For
example, there are loops in the C program which would go away.

Would you map read or would you slurp? Mapping a read function allows
transforming  lt; to  at read time. This does not matter in the C
program because the buffer is mutable but it would matter in Clojure.

Would you use the Clojure pattern language to find the pre tags?
Would you be able to parse out the string from the id? C encourages
character-level hacking but Clojure would be much more powerful.



 I think this speaks very positively about literate programming. What
 remains to be seen is how much (or not) I'm going to practice it in
 the future.

If you do try to rewrite it in Clojure please post the program. I
would be very interested to see how Clojure's concise syntax and
semantics get reflected in your design decisions.

The tangle program in Clojure might turn out to be a single
s-expression of only a few lines. The code density would be a
huge win but a literate version would still have to have the
vitals of the story. Remember that the key test for a literate
program is the independence test. Someone can read it without
talking to you, understand how it works, and be able to change it.



 What do you think of marginalia? It's a bit the reverse of tangle; it
 assembles all those 70's files together into this book you might want
 to read. Is it sound or not? Have your thoughts changed from what you
 wrote in [1]?


 [1] http://goo.gl/cXWzF

Literate programming is a mindset, not a tool. You can write a
literate program in anything, including marginalia.

That said, I have yet to see a Clojure program that lays out a story
so I can sit and read it. For a real challenge, if you try to write
tangle in Clojure, try writing the story in marginalia. I'm sure
Fogus would welcome the feedback.


The readability aspect is a real feature. Heck, you could even give
your programs to a company so they could read them BEFORE the job
interview. I would strongly favor hiring someone who could
communicate, who cared about code quality, and who could improve
the company's maintenance headache in the long term. A Literate
Clojure programmer would be a real gotta-hire person. Companies
use many programming languages but all programmers really do need
good communication skills.


In the long view, it would be sweet if the Clojure reader knew how
to read a literate program. Just call (literate-load file chunk)
and you get the same effect as if you had tangled the program to
a file.

With literate-load available you would be able to write all of
your Clojure code in a literate style, making Clojure much
easier to understand, maintain, and modify.



Tim Daly


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