[Job Spam] Looking for a clojure devs

2015-06-04 Thread Murtaza Husain
Hi,

A friend's startup is looking for couple of clojure devs. Its a startup and 
the stack they are using is reagent / clojure / datomic. 

They are looking for experienced developers with / without clojure 
experience, however with enthusiasm to learn and excel at the clojure 
stack. If interested please email me your resume on murtaz...@gmail.com, 
and I will forward it across. 

They currently have a remote team working in different time zones, and 
these positions will also be remote and can be based in any time zone. 

Thanks,
Murtaza

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


Re: How to include ... in project.clj

2015-06-04 Thread skuro
Have a look at the sample-project.clj 
, 
as you can read:

;; Repositories named "snapshots" and "releases" automatically 
;; have their :snapshots and :releases disabled as appropriate.

hence, you should do this way:

  :dependencies [...  [edu.cmu.sphinx/sphinx4-core "1.0-SNAPSHOT"]]
  :repositories [["snapshots" {:url 
"https://oss.sonatype.org/content/repositories/snapshots"}]]


c.

Il giorno mercoledì 3 giugno 2015 18:12:44 UTC+2, Jacob Goodson ha scritto:
>
> How would I get this to work?
>
> 
> ...
> 
> 
> snapshots-repo
> https://oss.sonatype.org/content/repositories/snapshots 
> 
> false
> true
> 
> 
> ...
>
> Then add sphinx4-core to the project dependencies:
>
> 
>   edu.cmu.sphinx
>   sphinx4-core
>   1.0-SNAPSHOT
>
>

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


Datomic query question

2015-06-04 Thread Wilker
Hi, good morning.

I have this query here:

[:find ?track (count ?lessons)
 :where
 [?t :track/name ?track]
 [?lessons :lesson/track ?t]
]

A lesson has a track (so a track can be on multiple lessons), and with this
query I can return the track names and the number of lessons where this
track is being used, all good here.

But I would like to use this count information to filter, and return only
tracks that are present in more than one lesson, I tried:

[:find ?track (count ?lessons)
 :where
 [?t :track/name ?track]
 [?lessons :lesson/track ?t]
 [(> (count ?lessons) 1)]
]

Also tried:

[:find ?track ?lc
 :where
 [?t :track/name ?track]
 [?lessons :lesson/track ?t]
 [(count ?lessons) ?lc]
 [(> ?lc 1)]
]

But I feel like I'm going on the wrong direction... How can I make this
query works?

Thanks.

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


Re: [Job Spam] Looking for a clojure devs

2015-06-04 Thread Shahrdad Shadab
Hi Morteza

 I have been doing Clojure past two years. Please find my Resume attached.

Best Regards
Shahrdad

On Thu, Jun 4, 2015 at 3:45 AM, Murtaza Husain <
murtaza.hus...@sevenolives.com> wrote:

> Hi,
>
> A friend's startup is looking for couple of clojure devs. Its a startup
> and the stack they are using is reagent / clojure / datomic.
>
> They are looking for experienced developers with / without clojure
> experience, however with enthusiasm to learn and excel at the clojure
> stack. If interested please email me your resume on murtaz...@gmail.com,
> and I will forward it across.
>
> They currently have a remote team working in different time zones, and
> these positions will also be remote and can be based in any time zone.
>
> Thanks,
> Murtaza
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Software Architect & Computer Scientist

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


Resume.doc
Description: MS-Word document


Re: How to include ... in project.clj

2015-06-04 Thread Jacob Goodson
Thanks, one last question(hopefully)... I have gotten it to pull down the 
sphinx4-core but for some reason it will not pull down the data.

:dependencies [[org.clojure/clojure "1.6.0"]
   [edu.cmu.sphinx/sphinx4-data "1.0-SNAPSHOT"]
   [edu.cmu.sphinx/sphinx4-core "1.0-SNAPSHOT"]]

:repositories [["snapshots-repo" {:url 
"https://oss.sonatype.org/content/repositories/snapshots"}]])


This is the way it looks on the website:


  edu.cmu.sphinx
  sphinx4-data
  1.0-SNAPSHOT

Finally, here is the url itself:

http://cmusphinx.sourceforge.net/wiki/tutorialsphinx4

Thanks!


On Thursday, June 4, 2015 at 7:31:12 AM UTC-4, skuro wrote:
>
> Have a look at the sample-project.clj 
> ,
>  
> as you can read:
>
> ;; Repositories named "snapshots" and "releases" automatically 
> ;; have their :snapshots and :releases disabled as appropriate.
>
> hence, you should do this way:
>
>   :dependencies [...  [edu.cmu.sphinx/sphinx4-core "1.0-SNAPSHOT"]]
>   :repositories [["snapshots" {:url "
> https://oss.sonatype.org/content/repositories/snapshots"}]]
>
>
> c.
>
> Il giorno mercoledì 3 giugno 2015 18:12:44 UTC+2, Jacob Goodson ha scritto:
>>
>> How would I get this to work?
>>
>> 
>> ...
>> 
>> 
>> snapshots-repo
>> https://oss.sonatype.org/content/repositories/snapshots 
>> 
>> false
>> true
>> 
>> 
>> ...
>>
>> Then add sphinx4-core to the project dependencies:
>>
>> 
>>   edu.cmu.sphinx
>>   sphinx4-core
>>   1.0-SNAPSHOT
>>
>>

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


Re: Datomic query question

2015-06-04 Thread Francis Avila
(This question is more appropriate to the datomic 
group: https://groups.google.com/forum/#!forum/datomic)

Datomic/datalog queries always perform aggregation as a last step so the 
results of aggregation are unavailable to the :where clause. In other 
words, what you want is impossible with a single datalog query.

However, this isn't SQL: the datalog query is run in the peer and all the 
data used for aggregation is transmitted to the peer anyway. Just filter 
over the results yourself with normal Clojure code. There's no advantage to 
expressing everything in a single query like there is in SQL.

(let [db [[:t1 :track/name "foo"]
  [:l1 :lesson/track :t1]
  [:t2 :track/name "bar"]
  [:l2 :lesson/track :t2]
  [:t3 :track/name "baz"]
  [:l3 :lesson/track :t3]
  [:l4 :lesson/track :t3]]]
  (->> (d/q '[:find ?track (count ?lessons)
  :where
  [?t :track/name ?track]
  [?lessons :lesson/track ?t]]
 db)
(filter (fn [[_ cnt]] (> cnt 1)
;=> (["baz" 2])


You can also use two queries: one to get the count per track, another to 
get the track names (but a simple filter is less verbose):

(let [db [[:t1 :track/name "foo"]
  [:l1 :lesson/track :t1]
  [:t2 :track/name "bar"]
  [:l2 :lesson/track :t2]
  [:t3 :track/name "baz"]
  [:l3 :lesson/track :t3]
  [:l4 :lesson/track :t3]]]
  (->>
(d/q '[:find ?t (count ?lessons)
   :where [?lessons :lesson/track ?t]]
  db)
(d/q '[:find ?track ?num-lessons
   :in $ [[?t ?num-lessons]]
   :where
   [(> ?num-lessons 1)]
   [?t :track/name ?track]]
 db)))
;=> #{["baz" 2]}



As a side note, be aware that if your track names are not unique you may 
get unexpected results from your current query:

(let [db [[:t1 :track/name "foo"]
  [:l1 :lesson/track :t1]
  [:t2 :track/name "bar"]
  [:l2 :lesson/track :t2]
  [:t3 :track/name "foo"]
  [:l3 :lesson/track :t3]
  [:l4 :lesson/track :t3]]]
  (d/q '[:find ?track (count ?lessons)
 :where
 [?t :track/name ?track]
 [?lessons :lesson/track ?t]]
db))
;=> [["bar" 1] ["foo" 3]]


This is because the aggregation is done over an unaggregated result *set*  
(i.e. all unique values) and  ?track is the same for multiple ?t. The 
solution is to either include ?t in the :find, or use :with. See the 
Datomic docs more more details: http://docs.datomic.com/query.html#sec-5-17


On Thursday, June 4, 2015 at 6:35:08 AM UTC-5, Wilker wrote:

> Hi, good morning.
>
> I have this query here:
>
> [:find ?track (count ?lessons)
>  :where
>  [?t :track/name ?track]
>  [?lessons :lesson/track ?t]
> ]
>
> A lesson has a track (so a track can be on multiple lessons), and with 
> this query I can return the track names and the number of lessons where 
> this track is being used, all good here.
>
> But I would like to use this count information to filter, and return only 
> tracks that are present in more than one lesson, I tried:
>
> [:find ?track (count ?lessons)
>  :where
>  [?t :track/name ?track]
>  [?lessons :lesson/track ?t]
>  [(> (count ?lessons) 1)]
> ]
>
> Also tried:
>
> [:find ?track ?lc
>  :where
>  [?t :track/name ?track]
>  [?lessons :lesson/track ?t]
>  [(count ?lessons) ?lc]
>  [(> ?lc 1)]
> ]
>
> But I feel like I'm going on the wrong direction... How can I make this 
> query works?
>
> Thanks.
>

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


multi-arity functions with macros

2015-06-04 Thread Phillip Lord

I have a number of fairly nasty functions with a form that looks like
this:

(defn default-ontology
  ([f]
 (dispatch f))
  ([f a]
 (dispatch f a))
  ([f a b]
 (dispatch f a b))
  ([f a b c]
 (dispatch f a b c))
  ([f a b c d]
 (dispatch f a b c d))
  ([f a b c d e]
 (dispatch f a b c d e))
  ([f a b c d e fa]
 (dispatch f a b c d e fa))
  ([f a b c d e fa g]
 (dispatch f a b c d e fa g))
  ([f a b c d e fa g h]
 (dispatch f a b c d e fa g h))
  ([f a b c d e fa g h i]
 (dispatch f a b c d e fa g h i))
  ([f a b c d e fa g h i j]
 (dispatch f a b c d e fa g h i j)))

The reason for all of this is that I need to avoid the use of variadic
function calls for performance reasons -- this function gets called a
lot in my code base, and without this unwinding, I box and unbox
consistantly.

Now, I dislike the code repetition here, and indeed have found already
found one bug in my code where I missed a variable out, something like

([f a b c d]
 (dispatch f a b d))

which is hard to pick up on.

I can't make the whole thing a macro because I need to pass this as a
first class function. And I can't macro each of the variadic elements
since the I'd need to return two elements at once.

The best I have done up with so far is:

(defn ^:private form-with-arity[n]
  ;; left as an exercise for the reader
)

(defmacro ^:private m-default-ontology
  `(defn default-ontology
  ~@(map form-with-arity (range 1 10

(m-default-ontology)

Or am I missing something more obvious?

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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Datomic query question

2015-06-04 Thread Wilker
Thank you very much Francis, that was very helpful :)

On Thu, Jun 4, 2015 at 1:21 PM Francis Avila  wrote:

> (This question is more appropriate to the datomic group:
> https://groups.google.com/forum/#!forum/datomic)
>
> Datomic/datalog queries always perform aggregation as a last step so the
> results of aggregation are unavailable to the :where clause. In other
> words, what you want is impossible with a single datalog query.
>
> However, this isn't SQL: the datalog query is run in the peer and all the
> data used for aggregation is transmitted to the peer anyway. Just filter
> over the results yourself with normal Clojure code. There's no advantage to
> expressing everything in a single query like there is in SQL.
>
> (let [db [[:t1 :track/name "foo"]
>   [:l1 :lesson/track :t1]
>   [:t2 :track/name "bar"]
>   [:l2 :lesson/track :t2]
>   [:t3 :track/name "baz"]
>   [:l3 :lesson/track :t3]
>   [:l4 :lesson/track :t3]]]
>   (->> (d/q '[:find ?track (count ?lessons)
>
>   :where
>   [?t :track/name ?track]
>   [?lessons :lesson/track ?t]]
>  db)
> (filter (fn [[_ cnt]] (> cnt 1)
> ;=> (["baz" 2])
>
>
> You can also use two queries: one to get the count per track, another to
> get the track names (but a simple filter is less verbose):
>
> (let [db [[:t1 :track/name "foo"]
>   [:l1 :lesson/track :t1]
>   [:t2 :track/name "bar"]
>   [:l2 :lesson/track :t2]
>   [:t3 :track/name "baz"]
>   [:l3 :lesson/track :t3]
>   [:l4 :lesson/track :t3]]]
>   (->>
> (d/q '[:find ?t (count ?lessons)
>:where [?lessons :lesson/track ?t]]
>   db)
> (d/q '[:find ?track ?num-lessons
>:in $ [[?t ?num-lessons]]
>:where
>[(> ?num-lessons 1)]
>[?t :track/name ?track]]
>  db)))
> ;=> #{["baz" 2]}
>
>
>
> As a side note, be aware that if your track names are not unique you may
> get unexpected results from your current query:
>
> (let [db [[:t1 :track/name "foo"]
>   [:l1 :lesson/track :t1]
>   [:t2 :track/name "bar"]
>   [:l2 :lesson/track :t2]
>   [:t3 :track/name "foo"]
>   [:l3 :lesson/track :t3]
>   [:l4 :lesson/track :t3]]]
>   (d/q '[:find ?track (count ?lessons)
>
>  :where
>  [?t :track/name ?track]
>  [?lessons :lesson/track ?t]]
> db))
> ;=> [["bar" 1] ["foo" 3]]
>
>
> This is because the aggregation is done over an unaggregated result *set*
> (i.e. all unique values) and  ?track is the same for multiple ?t. The
> solution is to either include ?t in the :find, or use :with. See the
> Datomic docs more more details:
> http://docs.datomic.com/query.html#sec-5-17
>
>
> On Thursday, June 4, 2015 at 6:35:08 AM UTC-5, Wilker wrote:
>
>> Hi, good morning.
>>
>> I have this query here:
>>
>> [:find ?track (count ?lessons)
>>  :where
>>  [?t :track/name ?track]
>>  [?lessons :lesson/track ?t]
>> ]
>>
>> A lesson has a track (so a track can be on multiple lessons), and with
>> this query I can return the track names and the number of lessons where
>> this track is being used, all good here.
>>
>> But I would like to use this count information to filter, and return only
>> tracks that are present in more than one lesson, I tried:
>>
>> [:find ?track (count ?lessons)
>>  :where
>>  [?t :track/name ?track]
>>  [?lessons :lesson/track ?t]
>>  [(> (count ?lessons) 1)]
>> ]
>>
>> Also tried:
>>
>> [:find ?track ?lc
>>  :where
>>  [?t :track/name ?track]
>>  [?lessons :lesson/track ?t]
>>  [(count ?lessons) ?lc]
>>  [(> ?lc 1)]
>> ]
>>
>> But I feel like I'm going on the wrong direction... How can I make this
>> query works?
>>
>> Thanks.
>>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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

Re: [ANN] Clojure 1.7.0-RC1 now available

2015-06-04 Thread Andy Fingerhut
I've filed http://dev.clojure.org/jira/browse/CLJ-1745

In checking Mike Rodriguez's test case for reproducing the issue, I could
reproduce the behavior change in a lein repl, but the behavior appears to
be the same with a plain Clojure REPL.  See the ticket for what I found,
and feel free to edit in case anyone else gets additional results that
differ from those.

Andy

On Wed, Jun 3, 2015 at 7:20 PM, Alex Miller  wrote:

> s/Ivan/Mike Rodriguez/ sorry :)
>
>
> On Wednesday, June 3, 2015 at 8:19:40 PM UTC-6, Alex Miller wrote:
>>
>> Thanks Ivan and Andy, I'd appreciate a ticket in jira if only to consider
>> this again before release.
>>
>> Thank goodness Stu H screened that one so I can blame him. ;)
>>
>>
>> On Wednesday, June 3, 2015 at 4:00:35 PM UTC-6, Andy Fingerhut wrote:
>>>
>>> Just to provide slightly more info, that change was made because of this
>>> ticket: http://dev.clojure.org/jira/browse/CLJ-1169
>>>
>>> Andy
>>>
>>> On Wed, Jun 3, 2015 at 6:34 AM, Mike Rodriguez  wrote:
>>>
 Sorry for the delay in getting back with a response to this.  I think
 it is fairly clear in the Clojure Compiler that there is an exception that
 will wrap errors that occur during macroexpansion now.

 Around here
 https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L6627-L6649,
 the Compiler.macroexpand1() now has a try-catch for Throwable around the
 evaluation of the macro invocation.
 This was not the case in Clojure version 1.6.  See around
 https://github.com/clojure/clojure/blob/clojure-1.6.0/src/jvm/clojure/lang/Compiler.java#L6548-L6560
 for a reference point.

 I'm fairly sure that is what has caused this change in behavior that
 broke our expectations that the exception types our code through during
 macroexpansion would propagate all the way back to the caller.  Again, I
 think this was a bad expectation to have, but it is a little tricky.

 It is a little trickier for us to have any strong assertions on the
 type of exception that may come from a macro now.
 Compiler$CompilerException seems too dependent on the implementation.  So
 we've opted to just assert there would be a is-thrown? RuntimeException in
 these sorts of tests.  If we want to test something like an ExceptionInfo's
 data map, we now just have to write a helper to walk the stack trace until
 we find it - which would likely be a single "step" up the trace.

 A simple reproducing case:
 *clojure-version* ;= {:major 1, :minor 7, :incremental 0, :qualifier
 "RC1"}

 (defmacro demo [] (throw (ex-info "fail" {})))

 (demo) ;= CompilerException clojure.lang.ExceptionInfo: fail {},
 compiling:(form-init4053282905768384039.clj:1:1)

 vs.
 *clojure-version* ;= {:major 1, :minor 6, :incremental 0, :qualifier
 nil}

 (demo) ;= ExceptionInfo fail  clojure.core/ex-info (core.clj:4403)



 On Saturday, May 23, 2015 at 8:52:47 AM UTC-5, Alex Miller wrote:
>
> I'm not aware of any wholesale changes with respect to compiler
> exceptions. Can you give an example?

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

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

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

[ANN] Dominator 0.3.0

2015-06-04 Thread David Sargeant
* Fixed an issue with :style attribute.
* Added animation-frames signal for syncing with requestAnimationFrame.
* Live examples!

https://github.com/dubiousdavid/dominator#sample-programs

Check out my Mario example: 
http://dubiousdavid.github.io/dominator/examples/mario/
Mario code: 
https://github.com/dubiousdavid/dominator/blob/master/examples/mario/src/mario/core.cljs

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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] Clojure 1.7.0-RC1 now available

2015-06-04 Thread Sean Corfield
We took RC1 to production yesterday afternoon (after being on beta1 since 
mid-April). So far so good.

I think the only 1.7 new feature we’re using so far is transducers (we wrote a 
transducer that takes a result set of user-to-user messages and returns a 
paginated, nested result set organized by conversion thread — a big 
simplification over how we’d done it before).

Sean

On May 21, 2015, at 9:30 AM, Alex Miller  wrote:
> Clojure 1.7.0-RC1 is now available.
> 
> Try it via
> - Download: https://repo1.maven.org/maven2/org/clojure/clojure/1.7.0-RC1/ 
> 
> - Leiningen: [org.clojure/clojure "1.7.0-RC1"]
> 
> The only change since 1.7.0-beta3 is CLJ-1706, which makes reader conditional 
> splicing an error at the top level (previously it would silently drop all but 
> the first spliced element).
> 
> For a full list of changes since 1.6.0, see:
> https://github.com/clojure/clojure/blob/master/changes.md 
> 
> 
> Please give it a try and let us know if things are working (or not). The more 
> and quicker feedback we get, the sooner we can release 1.7.0 final!


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


Re: multi-arity functions with macros

2015-06-04 Thread Fluid Dynamics
On Thursday, June 4, 2015 at 12:55:23 PM UTC-4, Phillip Lord wrote:
>
>
> I have a number of fairly nasty functions with a form that looks like 
> this: 
>
> (defn default-ontology 
>   ([f] 
>  (dispatch f)) 
>   ([f a] 
>  (dispatch f a)) 
>   ([f a b] 
>  (dispatch f a b)) 
>   ([f a b c] 
>  (dispatch f a b c)) 
>   ([f a b c d] 
>  (dispatch f a b c d)) 
>   ([f a b c d e] 
>  (dispatch f a b c d e)) 
>   ([f a b c d e fa] 
>  (dispatch f a b c d e fa)) 
>   ([f a b c d e fa g] 
>  (dispatch f a b c d e fa g)) 
>   ([f a b c d e fa g h] 
>  (dispatch f a b c d e fa g h)) 
>   ([f a b c d e fa g h i] 
>  (dispatch f a b c d e fa g h i)) 
>   ([f a b c d e fa g h i j] 
>  (dispatch f a b c d e fa g h i j))) 
>
> The reason for all of this is that I need to avoid the use of variadic 
> function calls for performance reasons -- this function gets called a 
> lot in my code base, and without this unwinding, I box and unbox 
> consistantly. 
>
> Now, I dislike the code repetition here, and indeed have found already 
> found one bug in my code where I missed a variable out, something like 
>
> ([f a b c d] 
>  (dispatch f a b d)) 
>
> which is hard to pick up on. 
>
> I can't make the whole thing a macro because I need to pass this as a 
> first class function. And I can't macro each of the variadic elements 
> since the I'd need to return two elements at once. 
>
> The best I have done up with so far is: 
>
> (defn ^:private form-with-arity[n] 
>   ;; left as an exercise for the reader 
> ) 
>
> (defmacro ^:private m-default-ontology 
>   `(defn default-ontology 
>   ~@(map form-with-arity (range 1 10 
>
> (m-default-ontology) 
>
> Or am I missing something more obvious? 
>
> Phil 
>

Well, the example case could be replaced with (def default-ontology 
dispatch). :)

Beyond that, you might want to consider generating such repetitive and 
predictably-structured functions with a custom def-something style macro, 
but it looks like you already are.

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


Re: multi-arity functions with macros

2015-06-04 Thread Francis Avila
This is exactly the approach to take: a macro which expands to a defn with 
all your arities filled out.

Here's a simple approach which might be enough for your problem: it will 
splice in argument names whenever some marker symbol is encountered, and 
repeat for the range of arities you want.


(defn splice [marker replacement form]
  (cond
(seq? form) (reduce #(if (= marker %2)
  (into %1 (reverse replacement))
  (conj %1 (splice marker replacement %2)))
  () (reverse form))

(or (vector? form) (set? form))
(reduce #(if (= marker %2)
  (into %1 replacement)
  (conj %1 (splice marker replacement %2)))
  (empty form) form)

(map? form)
(reduce-kv #(assoc %1 (splice marker replacement %2)
  (splice marker replacement %3)) {} form)

(= marker form)
(throw (ex-info "Cannot splice into a top-level form!" {}))

:else form))

(defmacro defvariadic
;; Full support for defn options (attr-map, docstring, pre/post conditions)
;; an exercise for the reader.
  [name marker max-arity params & body]
  (assert (and (symbol? name) (nil? (namespace name
  (assert (and (symbol? marker)))
  (assert (and (integer? max-arity) (<= 0 max-arity 24)))
  (assert (vector? params))
  (let [arg-syms (mapv gensym (subs "abcdefghijklmnopqrstuvwxyz" 0 
max-arity))
params+bodies
 (map (fn [arity]
(let [var-params (subvec arg-syms 0 arity)]
  (list* (splice marker var-params params)
(splice marker var-params body
   (range max-arity))]
`(defn ~name ~@params+bodies)))


This produces output like the following:

(clojure.pprint/pprint (macroexpand-1
  '(defvariadic default-ontology-dispatch <> 5
[f <>]
(dispatch f <>


(clojure.core/defn
 default-ontology-dispatch
 ([f] (dispatch f))
 ([f a23733] (dispatch f a23733))
 ([f a23733 b23734] (dispatch f a23733 b23734))
 ([f a23733 b23734 c23735] (dispatch f a23733 b23734 c23735))
 ([f a23733 b23734 c23735 d23736]
  (dispatch f a23733 b23734 c23735 d23736)))






On Thursday, June 4, 2015 at 11:55:23 AM UTC-5, Phillip Lord wrote:
>
>
> I have a number of fairly nasty functions with a form that looks like 
> this: 
>
> (defn default-ontology 
>   ([f] 
>  (dispatch f)) 
>   ([f a] 
>  (dispatch f a)) 
>   ([f a b] 
>  (dispatch f a b)) 
>   ([f a b c] 
>  (dispatch f a b c)) 
>   ([f a b c d] 
>  (dispatch f a b c d)) 
>   ([f a b c d e] 
>  (dispatch f a b c d e)) 
>   ([f a b c d e fa] 
>  (dispatch f a b c d e fa)) 
>   ([f a b c d e fa g] 
>  (dispatch f a b c d e fa g)) 
>   ([f a b c d e fa g h] 
>  (dispatch f a b c d e fa g h)) 
>   ([f a b c d e fa g h i] 
>  (dispatch f a b c d e fa g h i)) 
>   ([f a b c d e fa g h i j] 
>  (dispatch f a b c d e fa g h i j))) 
>
> The reason for all of this is that I need to avoid the use of variadic 
> function calls for performance reasons -- this function gets called a 
> lot in my code base, and without this unwinding, I box and unbox 
> consistantly. 
>
> Now, I dislike the code repetition here, and indeed have found already 
> found one bug in my code where I missed a variable out, something like 
>
> ([f a b c d] 
>  (dispatch f a b d)) 
>
> which is hard to pick up on. 
>
> I can't make the whole thing a macro because I need to pass this as a 
> first class function. And I can't macro each of the variadic elements 
> since the I'd need to return two elements at once. 
>
> The best I have done up with so far is: 
>
> (defn ^:private form-with-arity[n] 
>   ;; left as an exercise for the reader 
> ) 
>
> (defmacro ^:private m-default-ontology 
>   `(defn default-ontology 
>   ~@(map form-with-arity (range 1 10 
>
> (m-default-ontology) 
>
> Or am I missing something more obvious? 
>
> 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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: When should defrecord be slower than deftype?

2015-06-04 Thread Steven Yi
I gave overriding of equals/hashCode a try with records just as a path
to test against the deftype performance. I guess with records, they're
meant to be treated like immutable value types, so identity based
hashCodes would sort of go against the spirit of that.

On Wed, Jun 3, 2015 at 11:16 PM, Mars0i  wrote:
>
>
> On Tuesday, June 2, 2015 at 11:16:49 PM UTC-5, Steven Yi wrote:
>>
>> As a side note, as an experiment I just tried overriding Object.equals
>> and Object.hashCode with a defrecord, and I got a compiler error:
>>
>> CompilerException java.lang.ClassFormatError: Duplicate method
>> name&signature in class file user/R1,
>>
>> compiling:(/private/var/folders/0k/xj_drd990xxf4q99n2bdknrcgn/T/form-init3397614882621384237.clj:1:1)
>>
>> I'm assuming that defrecord is adding its hashCode and equals
>> implementations without checking if it's being overridden, but haven't
>> verified. (That was with 1.7.0-beta3 at least).
>
>
> I just understood why you tried this experiment, I think.  I tried it in
> 1.6.0 and 1.7.0-RC1 and got the same result.  For my purposes, it would be
> ideal if I could override hashCode so that it was based on identity.  I'd
> get speed with Java hashmaps along with the other conveniences of records.
> Oh well.  Perhaps overriding hash behavior seems too bug-prone to be
> allowed.
>
> The docstring for defrecord mentions explicitly that it defines hashCode and
> equals.  It seems as if there's a tiny inconsistency in the documentation
> given that it says that "You can also define overrides for methods of
> Object", though it doesn't say that you can do this for all of Object's
> methods; perhaps strictly speaking it's not inconsistent.
>
> --
> 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 a topic in the
> Google Groups "Clojure" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojure/EdjnSxRkOPk/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

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


Re: [ANN] Clojure 1.7.0-RC1 now available

2015-06-04 Thread Luc Prefontaine
Hi,

Have been using 1.7 since beta1 in dev and test in a new dev.
Still 3 months away from production beta.

So far no issues. Zero, nada, nil, ...

Reader conditionals are quite amazing, we started unifying backend and front 
end code.
Wow... No more split brain syndrome and a huge simplification of front end/back 
end code.
That's a huge relief on my nervous system :)

For the first time in many years I enjoy working on a web front end... finally.

Thank you all,

Luc P.

On Thu, 21 May 2015 11:30:47 -0500
Alex Miller  wrote:

> Clojure 1.7.0-RC1 is now available.
> 
> Try it via
> - Download:
> https://repo1.maven.org/maven2/org/clojure/clojure/1.7.0-RC1/
> - Leiningen: [org.clojure/clojure "1.7.0-RC1"]
> 
> The only change since 1.7.0-beta3 is CLJ-1706, which makes reader
> conditional splicing an error at the top level (previously it would
> silently drop all but the first spliced element).
> 
> For a full list of changes since 1.6.0, see:
> https://github.com/clojure/clojure/blob/master/changes.md
> 
> Please give it a try and let us know if things are working (or not).
> The more and quicker feedback we get, the sooner we can release 1.7.0
> final!
> 
> - Alex
> 



-- 
Luc Préfontaine

SoftAddicts inc.
Québec, Canada
Mobil: +1 (514) 993-0320
Fax: +1 (514) 800-2017

Rabat, Maroc
Mobil: +1 212 6 98 00 64 47


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


Re: [ANN] Clojure 1.7.0-RC1 now available

2015-06-04 Thread Sean Corfield
On Jun 4, 2015, at 2:51 PM, Luc Prefontaine  wrote:
> Still 3 months away from production beta.

I get twitchy if we go more than two weeks between production builds — but then 
it’s the web :)

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] Clojure 1.7.0-RC1 now available

2015-06-04 Thread Mike Rodriguez
Thanks Andy for the extra info and for logging the follow-up Jira! 
It looks like the exception changes are expected and are a potential 
improvement with line numbers etc. 
My the main goal was just to provide constructive feedback on here of the 
issues I faced investigating the upgrade of a fairly large code base  from 
Clojure 1.6 to 1.7. 

I appreciate all the feedback from everyone. 

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


Re: [ANN] Clojure 1.7.0-RC1 now available

2015-06-04 Thread Luc Prefontaine
We have a planned upgrade at a customer site before xmas of our oldest product. 
Internal work on upgrading it to 1.7 starts in august.

If I look at the Clojure upgrade track since 2009, I can't say that I am 
nervous about this.

Not at all :)

We are presently building a new product and integrating 1.7 made sense. We 
already reused some common internal components w/o any glitches.

25 years ago I was used to smooth upgrades working on VMS.

I did not see that happening many times since then.

And we run critical services 24/7 on  premises, not in a fully controlled 
off-site environment. Our up times are insane.

Yahoo !
Luc

> On Jun 4, 2015, at 2:51 PM, Luc Prefontaine  
> wrote:
> > Still 3 months away from production beta.
> 
> I get twitchy if we go more than two weeks between production builds — but 
> then it’s the web :)
> 
> Sean Corfield -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
> 
> "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
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
> 
--
Luc Prefontaine sent by ibisMail!

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


I created a new macro "if-let-all"

2015-06-04 Thread crocket


The macro below is called if-let-all.

(defmacro if-let-all
  "if-let-all evaluates every local binding sequentially and evaluates 
true-case only if every local binding is a truthy value.
true-case has access to all local bindings, but false-case doesn't have access 
to local bindings."
  [bindings true-case false-case]
  (let [pairs (partition 2 bindings)
names (mapv first pairs)
exprs (map second pairs)
exprs-in-if-let (fn self [[name1 & more-names] [expr1 & more-exprs]]
 `(if-let [~name1 ~expr1]
~(if more-names
   (self more-names more-exprs)
   names)))
things (exprs-in-if-let names exprs)]
`(if-let [~names ~things]
   ~true-case
   ~false-case)))

You can use it as (if-let-all [a 2 b 3] (+ a b) "oh no!!"). false-case doesn't 
have access to local bindings.

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


namespace scope

2015-06-04 Thread Todd Stout
What are the scope rules of a namespace? For example, can a single file 
define multiple namespaces? Can multiple files contribute to the same 
namespace?

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


Re: I created a new macro "if-let-all"

2015-06-04 Thread crocket
Ouch, I didn't write. Gary Fredericks wrote it. I simply modified his 
if-let-all macro a little bit.

On Friday, June 5, 2015 at 2:44:22 PM UTC+9, crocket wrote:
>
> The macro below is called if-let-all.
>
> (defmacro if-let-all
>   "if-let-all evaluates every local binding sequentially and evaluates 
> true-case only if every local binding is a truthy value.
> true-case has access to all local bindings, but false-case doesn't have 
> access to local bindings."
>   [bindings true-case false-case]
>   (let [pairs (partition 2 bindings)
> names (mapv first pairs)
> exprs (map second pairs)
> exprs-in-if-let (fn self [[name1 & more-names] [expr1 & more-exprs]]
>  `(if-let [~name1 ~expr1]
> ~(if more-names
>(self more-names more-exprs)
>names)))
> things (exprs-in-if-let names exprs)]
> `(if-let [~names ~things]
>~true-case
>~false-case)))
>
> You can use it as (if-let-all [a 2 b 3] (+ a b) "oh no!!"). false-case 
> doesn't have access to local bindings.
>
>

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


Re: namespace scope

2015-06-04 Thread Andy Fingerhut
A single file can define multiple namespaces, and a single namespace's
definition can be spread across multiple files.  However, I have not seen
either of those things done very often in Clojure projects.  By far the
most common approach is to have one file per namespace, and each namespace
defined completely within one file.  More details below.

It is a reasonably common mistake to have a file define a namespace, but
the file name and namespace do not correspond to each other, and this
confuses many tools, including require and use in Clojure, without clear
error messages.  For this reason, Eastwood [3] checks for this issue in
Leiningen projects as one of the first things it does, before doing any
other lint checks.


Can a single file define multiple namespaces?

Yes, it can.

However, if you 'require' or 'use' a namespace foo.bar, Clojure will look
for a file foo/bar.clj (and starting in Clojure 1.7.0, also first
foo/bar.cljc) and read and load that file if one exists, anywhere on your
class path.  After that, it will throw an exception if the namespace
foo.bar does not exist, so that file, or something else loaded as a side
effect, should create the namespace foo.bar.

If loading file foo/bar.clj also creates a namespace baz.gah by having (ns
baz.gah ...) in it, and there is no file baz/gah.clj (nor baz/gah.cljc in
Clojure 1.7.0), then you cannot do a require or use on namespace baz.gah
without getting an error.

Since people usually like having the flexibility of doing require or use on
any namespace they wish, they usually put the (ns ...) forms defining them
into files with the corresponding names.


Can multiple files contribute to the same namespace?

Yes, they can.  Clojure does this itself in the file core.clj [1], and a
few other source files, where a 'main' file with a name that corresponds to
the namespace name has one or more (load "other_file.clj") calls in it, and
those other files have no (ns ...) form at all (for example the file
core_proxy.clj [2]).

[1]
https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L6488-L6495
[2]
https://github.com/clojure/clojure/blob/master/src/clj/clojure/core_proxy.clj
[3] https://github.com/jonase/eastwood

Andy


On Thu, Jun 4, 2015 at 7:55 PM, Todd Stout  wrote:

> What are the scope rules of a namespace? For example, can a single file
> define multiple namespaces? Can multiple files contribute to the same
> namespace?
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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