Compojure-api, spec-tools, swagger,

2018-05-14 Thread Dave Tenny
I'm using compojure-api 2.0.0-alpha19, spec-tools 0.6.1, and trying to 
generate swagger pages with :spec coercion in compojure-api.

I know this is a work in progress but I'm not an expert in any of these 
tools and thought I'd ask here before I write pesky and likely incorrect 
issues in the Metosin repos.  I've done a fair bit of prismatic-schema 
enabled compojure-api and so was trying to translate some of that into a 
spec-ized implementation.  However i've either made a ton of mistakes 
(quite likely), or there's a lot of bugs, I'm not sure.

The following code fragments and annotated image show some of the problems 
I'm seeing.  Advice welcome. 

Basic specs, later aliased via 'db-jobs':

(s/def ::job-id nat-int?)
(s/def ::job-type #{:this-job :that-job :the-other-job})

Specs built on the above, later aliased via 'specs' in compojure-api 
declarations:
(s/def ::job-id  
  (st/spec ::db-jobs/job-id
   {:description "Specifies a Job ID, must be accompanied by a Firm 
ID for any valid use."}))


(s/def ::job-type 
  (st/spec ::db-jobs/job-type
   {:description "Specifies the type of job to be dispatched to a 
suitable worker service node."}))


(s/def ::firm-id
  (st/spec nat-int? 
   {:description "Specifies a Firm ID in the service database, or 
zero if there there is no specific firm."}))

Compojure-api code using the above three specs:

...
  (:require
   [clojure.spec.alpha :as s]
   [compojure.api.core :as api-core]
   [compojure.api.sweet :as sweet]
   [compojure.route :as route]
   [my.specs :as specs]
   [spec-tools.core :as st]

...
(sweet/defroutes routes
  (sweet/POST "/job/:firm-id" []
{:summary  "Enqueue a job"
 :description  "Enqueue a job."
 :path-params [firm-id :- ::specs/firm-id]
 :body-params [job-type :- ::specs/job-type]
 :responses   {201 {:description "Job enqueued." :schema ::specs/job-id}
   400 {:description "Invalid job type." 
:schema (st/spec string? {:description "Value of 
the unsupported job-type argument."})
}}}
{:status 201 :body (impl/create-job! firm-id job-type)}))

...
  (sweet/api
   {:coercion :spec
:swagger {:data {;;:basePath "/"
 :info {:title "Job Scheduler"
:description "Jobs"
:version 1
:contact {:name  "Pizza Eaters Inc." ...}}}
  :ui "/docs/swagger"
  :spec "/docs/swagger.json"
  :options {:ui {:docExpansion "list"

The resulting swagger page (fragment) follows, annotated for discussion:




   1. For the Response Class presentation, it would be nice to get the 
   description shown with the ::job-id type.
   2. The 'job-type' parameter name is not shown.
   3. The description of the 'job-type' parameter is not shown.
   4. The 201 response code data is missing from Response messages.
   5. (not highlighted)   :firm-id works as expected, whether it's because 
   it's a :path-param or because it lacks the same degree of indirection in 
   its spec definition I don't know.


Also note that
:path-params [firm-id :- (sweet/describe ::specs/firm-id "Firm identifier, 
or zero if there is no firm.")]
Does not produce a description in swagger, however the spec.tools code in 
the initial compojure-api code I presented works.  Bug or feature? (Seems 
like sweet/describe might be deprecated as we move to clojure.spec if we're 
using spec-tools).


Anyway, tips appreciated, and patience for obvious "user" mistakes.

-- 
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: Clojure.spec: need function equivalents of library macros?

2017-05-09 Thread Dave Tenny
My issues aren't about qualified or unqualified keys (and the APIs
generally need to accept unqualified keys - I do use qualified keys in
various contexts, just not this post where the topic is macros vs.
non-macro forms).

s/merge is a good point about composition.  However often all I really want
to do is take some list of, say, keywords, acceptable in a map or
collection that is a parameter, and 'disj' one keyword from it for another
spec because that particular keyword isn't valid or supported for an
interface in question.

At the end of the day, I feel I'm often forced to cut and paste too many
similar but different lists into various specs (fdef in particular).  The
ability to construct specs without macros might be useful.

On Tue, May 9, 2017 at 6:05 AM, Alex Miller <a...@puredanger.com> wrote:

> Is there any reason why you're using unqualified keys? If you're using
> qualified keys, then a simple (s/keys) spec will validate all registered
> keys in the map so you can cover all of your optional attribute cases that
> way.
>
> Another possibility worth mentioning is using s/merge to combine
> well-known (smaller) map specs into larger combinations.
>
>
> On Monday, May 8, 2017 at 10:38:34 AM UTC-5, Dave Tenny wrote:
>>
>> Let's say I have a namespace that provides access to the database,
>> say our table has these fields (as clojure specs)
>>
>> (s/def ::job-id nat-int?) ; 1 2 3 ...
>> (s/def ::job-name string?) ; frobozz-executor
>> (s/def ::job-status keyword?) ; :queued, :in-progress, :completed
>>
>>
>> And that I have the logic in place to convert to/from the types (e.g.
>> keywords).
>>
>> If I have a simple function to return records in from the jobs table it
>> might look like:
>>
>> (s/def ::job-record (s/keys :req-un [::job-id ::job-name ::job-status]))
>>
>> (s/fdef get-jobs
>>   :args (s/cat :db database-handle?)
>>   :ret (s/coll-of ::job-record))
>>
>> (defn get-jobs
>>   [db]
>>   ... returns vector of maps, one for each record, jdbc-style ...)
>>
>> (get-jobs) => [{:job-id 1 :job-name "frobozz-executor" :job-status
>> :queued} ...]
>>
>> Now here's where things get iffy in practice.  Suppose I have other
>> database interfaces that take similar but different maps or collections of
>> keywords.
>>
>> For example, a function like:
>>
>> (s/fdef get-selective-jobs
>>   :args (s/cat :db database-handle? :fields (s/keys :opt-un [::job-id
>> ::job-name ::job-status])))
>>
>> (defn get-selective-jobs
>>   [db fields]
>>   ... return only fields from the database that are specified in the
>> fields parameter ...)
>>
>>
>> Once you start getting some similar-but-different specs, it'd be nice
>> apply a bit of code building.
>>
>> e.g.
>>
>> (def job-field-keys [::job-id ::job-name ::job-status])
>>
>> (s/def ::job-record (s/keys* :req-un job-field-keys))
>> (s/fdef get-selective-args
>>   :args (s/cat* :db database-handle? :fields  (s/keys :opt-un
>> job-field-keys))
>>
>> Hopefully this is conducive to some thought/discussion of the subject,
>> and/or someone can just let me know how I should be doing this if there's
>> an easy way in the present spec implementation.
>>
>> Sidewise plea: inline specs for s/keys like you can do for s/cat.  s/keys
>> deliberate omision of inline specs does occasionally get in the way in
>> large namespaces.
>>
>>
>>
>> --
> 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/OBbq-jInyqI/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: Clojure.spec: need function equivalents of library macros?

2017-05-08 Thread Dave Tenny
Oops, some corrections to my original post.

On Monday, May 8, 2017 at 11:38:34 AM UTC-4, Dave Tenny wrote:
>
> Let's say I have a namespace that provides access to the database,
> say our table has these fields (as clojure specs)
>
> (s/def ::job-id nat-int?) ; 1 2 3 ...
> (s/def ::job-name string?) ; frobozz-executor
> (s/def ::job-status keyword?) ; :queued, :in-progress, :completed
>
>
> And that I have the logic in place to convert to/from the types (e.g. 
> keywords).
>
> If I have a simple function to return records in from the jobs table it 
> might look like:
>
> (s/def ::job-record (s/keys :req-un [::job-id ::job-name ::job-status]))
>
> (s/fdef get-jobs
>   :args (s/cat :db database-handle?)
>   :ret (s/coll-of ::job-record))
>
> (defn get-jobs
>   [db]
>   ... returns vector of maps, one for each record, jdbc-style ...)
>
> (get-jobs) => [{:job-id 1 :job-name "frobozz-executor" :job-status 
> :queued} ...]
>
> Now here's where things get iffy in practice.  Suppose I have other 
> database interfaces that take similar but different maps or collections of 
> keywords.
>
> For example, a function like this which lets you specify which fields you 
> want retrieved:
>
> (s/fdef get-selective-jobs
>   :args (s/cat :db database-handle? :fields (s/coll-of #{:job-id :job-name 
> :job-status}))
>
  :ret (s/coll-of (s/keys :opt-un [ ::job-id ::job-name ::job-status 
])))

^^ correction of :fields above, additiobn of :ret


> (defn get-selective-jobs
>   [db fields]
>   ... return only fields from the database that are specified in the 
> fields parameter ...)
>
>
> Once you start getting some similar-but-different specs, it'd be nice 
> apply a bit of code building.
>
> e.g.
>
> (def job-field-keys [::job-id ::job-name ::job-status])
>
> (s/def ::job-record (s/keys* :req-un job-field-keys))
> (s/fdef get-selective-args
>   :args (s/cat* :db database-handle? :fields  (s/coll-of (set 
> job-field-keys))
>
:ret (s/coll-of (s/keys* :opt-un job-field-keys)))

^^ correction to :args above, addition of :ret


> Hopefully this is conducive to some thought/discussion of the subject, 
> and/or someone can just let me know how I should be doing this if there's 
> an easy way in the present spec implementation.
>

The point being that it's be nice to have some easier ways of specifying 
similar but different sets of data in
s/keys, s/cat, s/coll-of, and possibly other macros.

 

>
> Sidewise plea: inline specs for s/keys like you can do for s/cat.  s/keys 
> deliberate omision of inline specs does occasionally get in the way in 
> large namespaces.
>   
>
>
>

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


Clojure.spec: need function equivalents of library macros?

2017-05-08 Thread Dave Tenny
Let's say I have a namespace that provides access to the database,
say our table has these fields (as clojure specs)

(s/def ::job-id nat-int?) ; 1 2 3 ...
(s/def ::job-name string?) ; frobozz-executor
(s/def ::job-status keyword?) ; :queued, :in-progress, :completed


And that I have the logic in place to convert to/from the types (e.g. 
keywords).

If I have a simple function to return records in from the jobs table it 
might look like:

(s/def ::job-record (s/keys :req-un [::job-id ::job-name ::job-status]))

(s/fdef get-jobs
  :args (s/cat :db database-handle?)
  :ret (s/coll-of ::job-record))

(defn get-jobs
  [db]
  ... returns vector of maps, one for each record, jdbc-style ...)

(get-jobs) => [{:job-id 1 :job-name "frobozz-executor" :job-status :queued} 
...]

Now here's where things get iffy in practice.  Suppose I have other 
database interfaces that take similar but different maps or collections of 
keywords.

For example, a function like:

(s/fdef get-selective-jobs
  :args (s/cat :db database-handle? :fields (s/keys :opt-un [::job-id 
::job-name ::job-status])))

(defn get-selective-jobs
  [db fields]
  ... return only fields from the database that are specified in the fields 
parameter ...)


Once you start getting some similar-but-different specs, it'd be nice apply 
a bit of code building.

e.g.

(def job-field-keys [::job-id ::job-name ::job-status])

(s/def ::job-record (s/keys* :req-un job-field-keys))
(s/fdef get-selective-args
  :args (s/cat* :db database-handle? :fields  (s/keys :opt-un 
job-field-keys))

Hopefully this is conducive to some thought/discussion of the subject, 
and/or someone can just let me know how I should be doing this if there's 
an easy way in the present spec implementation.

Sidewise plea: inline specs for s/keys like you can do for s/cat.  s/keys 
deliberate omision of inline specs does occasionally get in the way in 
large namespaces.
  


-- 
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: clojure.spec s/keys map key with alternative definitions in same namespace

2017-02-07 Thread Dave Tenny
>From my perspective, there are two specs.  I'm not trying to mash them
together, however I would like to use the appropriate spec with the same
keyword in maps, in different contexts.

It wouldn't be an issue if the contexts were in separate namespaces.  It's
only an issue because the two specs are in the same namespace, and I want
to use them in different places with the same map key.

(Or so it seems to me, still wrapping my head around spec).

On Tue, Feb 7, 2017 at 11:10 AM, Alex Miller <a...@puredanger.com> wrote:

> Spec names are intended to have enduring global semantics. So the notion
> of the same spec name having different semantics at different times seems
> to be at odds with that.
>
> In general, it's often helpful to think about all the possible values that
> an attribute will have - that's the true spec. In this case, it seems like
> what you have for ::coercible-job-type is the true spec - it can be either
> a string or other named value.
>
> And then think about the places where you need to add additional
> constraints to your ::job-record spec to narrow it. Like maybe here:
>
> (s/fdef ... :ret (s/and ::job-record #(-> % ::job-type string?)))
>
> You're on the brink of suggesting subtypes and covariant / contravariants,
> etc and that's a path spec is not going down.
>
>
> On Tuesday, February 7, 2017 at 9:40:24 AM UTC-6, Dave Tenny wrote:
>>
>> Let's say I have these definitions for a "job" record I'm managing,
>> perhaps in a database.
>>
>> (s/def ::job-status #{:in-progress :completed})
>> (s/def ::user-id (s/and integer? #(>= % 0)))
>> (s/def ::job-id integer?)
>>
>> (s/def ::coercible-job-type (s/and named? #(not (empty? (name %)
>> (s/def ::job-type (s/and string? #(not (empty? %
>>
>> So we have a job status which can be any of a limited set of keywords,
>> integer user and job ID's.
>>
>> Then there's job type and my issue.  Depending on the context I want
>> either to insist that job type will be purely a non-empty string, or that
>> it may also be a 'named?' object,
>> i.e. something for which the clojure.core/name function will work.
>>
>> If I'm just returning a pure job record, my definition would look like
>> this:
>>
>> (s/def ::job-record
>>   (s/keys :req-un [::job-id ::user-id ::job-type ::job-status]))
>>
>> So a map with all those keys and type definitions. And that's great.  I
>> define functions that return these
>> maps and so there's an (s/fdef ... :ret ::job-record).
>>
>> Now let's say I have an update! function that can take a map of optional
>> fields and update the record in the database with the fields that were
>> specified.
>>
>> (s/def ::field-options (s/keys :opt-un [::job-id ::user-id ::job-type
>> ::job-status]))
>> (s/fdef update! :args (s/cat ::field-map ::field-options) ...)
>> (defn update! [field-map] ... (:job-type field-map) ...)
>>
>> So far, so good. I have a parameter 'field-map' that can take optional
>> map keys, validate map arguments if the testing instrumentation is enabled,
>> etc.
>>
>> Here is my problem.  There appears to be no way for me to define, in this
>> namespace, map specs with a :job-type key, but that will have
>> :coercible-job-type semantics,
>> for my update! function. Or at least I don't see an easy way short of
>> writing a function to do everything that the existing machinery is doing
>> with respect to key and value validation,
>> which is a lot of work to handle this tiny thing, basically the ability
>> to have map keys and spec semantics bound to different names in s/keys
>> specs.
>>
>> For example, the following pseudo-spec might let me define a map key
>> :job-type whose semantics were specified by the ::coercible-job-type
>> definition.
>> Or inlining of definitions which the spec guide says was omitted on
>> purpose.
>>
>> (s/def ::field-map (s/keys :opt-un [... [::coercible-job-type :as ::job-
>> type]]))
>>
>> I want the map key to be ":job-type", but the clojure.spec semantics for
>> that field, *in selective module definitions*, to have ::coercible-job-type
>> behavior.
>>
>> So... am I missing something?
>>
>> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, 

clojure.spec s/keys map key with alternative definitions in same namespace

2017-02-07 Thread Dave Tenny
Let's say I have these definitions for a "job" record I'm managing, perhaps 
in a database.

(s/def ::job-status #{:in-progress :completed})
(s/def ::user-id (s/and integer? #(>= % 0)))
(s/def ::job-id integer?)

(s/def ::coercible-job-type (s/and named? #(not (empty? (name %)
(s/def ::job-type (s/and string? #(not (empty? %

So we have a job status which can be any of a limited set of keywords,
integer user and job ID's.  

Then there's job type and my issue.  Depending on the context I want either 
to insist that job type will be purely a non-empty string, or that it may 
also be a 'named?' object, 
i.e. something for which the clojure.core/name function will work.

If I'm just returning a pure job record, my definition would look like this:

(s/def ::job-record 
  (s/keys :req-un [::job-id ::user-id ::job-type ::job-status]))

So a map with all those keys and type definitions. And that's great.  I 
define functions that return these
maps and so there's an (s/fdef ... :ret ::job-record).

Now let's say I have an update! function that can take a map of optional 
fields and update the record in the database with the fields that were 
specified.

(s/def ::field-options (s/keys :opt-un [::job-id ::user-id ::job-type 
::job-status]))
(s/fdef update! :args (s/cat ::field-map ::field-options) ...)
(defn update! [field-map] ... (:job-type field-map) ...)

So far, so good. I have a parameter 'field-map' that can take optional map 
keys, validate map arguments if the testing instrumentation is enabled, etc.

Here is my problem.  There appears to be no way for me to define, in this 
namespace, map specs with a :job-type key, but that will have 
:coercible-job-type semantics,
for my update! function. Or at least I don't see an easy way short of 
writing a function to do everything that the existing machinery is doing 
with respect to key and value validation,
which is a lot of work to handle this tiny thing, basically the ability to 
have map keys and spec semantics bound to different names in s/keys specs.

For example, the following pseudo-spec might let me define a map key 
:job-type whose semantics were specified by the ::coercible-job-type 
definition.
Or inlining of definitions which the spec guide says was omitted on purpose.

(s/def ::field-map (s/keys :opt-un [... [::coercible-job-type :as ::job-type
]]))

I want the map key to be ":job-type", but the clojure.spec semantics for 
that field, *in selective module definitions*, to have ::coercible-job-type 
behavior.

So... am I missing something?

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


named? predicate?

2017-02-07 Thread Dave Tenny
I've occasionally wanted this and haven't found it.

(defn named?
  "True if object is compatible with the 'name' function.
  There must be a clojure built-in to do this but I haven't figured it out 
yet."
  [x]
  (or (string? x)
  (keyword? x)
  (symbol? x)))


Note that simply doing (instance? clojure.lang.Named x) won't work for 
strings, but the (name) function does.

Anyway, I'm thinking there's a built in way to do this without defining the 
above function.  Suggestions?

My use case is simply that I want to call the name function for objects 
that support it in a translation function.

-- 
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: Clojure.spec, maps, restrict valid keywords, easier way?

2017-02-04 Thread Dave Tenny
I have found eastwood to be useful for a number of things, however on 
keyword checking it failed terribly on our code base, though perhaps there 
have been updates since I last tried it.

Thanks for the suggestion though.

On Friday, February 3, 2017 at 7:26:01 PM UTC-5, Ben Brinckerhoff wrote:
>
> The eastwood linter can also be configured to look for possibly misspelled 
> keyword typos
>
> https://github.com/jonase/eastwood#keyword-typos
>
>>
>>>

-- 
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: Clojure.spec, maps, restrict valid keywords, easier way?

2017-02-02 Thread Dave Tenny
On Thursday, February 2, 2017 at 10:07:31 AM UTC-5, Alex Miller wrote:
>
> We don't encourage you to do this, but I don't have an easier solution 
> than this.
>

Yes, and from the general standpoint of map handling I understand that.

>From the standpoint of functions that take options and don't pass option 
maps through to other functions, I disagree with the clojure philosophy 
here.  So many bugs could be caught if we flagged unexpected map keys when 
they're used as options to functions.  Of course use and validation via 
clojure.spec helps too, but from a general bug catching standpoint I 
believe there's a huge value to flagging inputs to functions that aren't 
recognized by the functions. 

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


Clojure.spec, maps, restrict valid keywords, easier way?

2017-02-02 Thread Dave Tenny
I want to specify in clojure spec that only declared keywords are permitted 
in function calls.
This is to catch what are usually mis-spelled or mis-cased keywors passed 
via option maps in function calls.

In the fdefs below, the second fdef will catch an invalid call, e.g. 
(f 1 {:a 2 :B 3})
but the first fdef will not.

Is there an easier way to specify the more restrictive spec without having 
to add my own 'every' and enumeration of the keys?
(or build my own version of s/keys that does this automatically, which I'm 
guessing is the answer).

(require '[clojure.spec :as s])
(require '[clojure.spec.test :as stest])


(s/def ::x (fn [x] true))   ;for lack of any?


;; Will not catch invalid keywords
(s/fdef f
  :args (s/cat :x ::x
   :options (s/keys :opt-un [::a ::b]))
  :ret nil?)


;; Will catch invalid keywords, but is there an easier way?
(s/fdef f
  :args (s/cat :x ::x
   :options (s/and (s/keys :opt-un [::a ::b])
   #(every? #{:a :b} (keys %
  :ret nil?)


(defn f [x {:keys [a b]}])


(stest/instrument `f)





-- 
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: Documentation for namespace aliased keywords (particularly relevant for clojure.spec use)

2017-02-02 Thread Dave Tenny
I also have to wonder why keyword namespaces aren't processed like other 
symbol namespaces, that is, to interpret the namespace portion before a '/' 
with alias consideration.
No doubt there's a good answer, but it seems anachronistic that keywords 
need special syntax contortions to recognize namespace aliases when other 
symbols do not.
(Yes, clojure keywords may not be thought of as symbols, still, the rules 
for alias recognition are 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 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.


Documentation for namespace aliased keywords (particularly relevant for clojure.spec use)

2017-02-01 Thread Dave Tenny
Looking at the documentation for keywords 
under https://clojure.org/reference/reader#_literals
there is no mention for the syntax for namespace aliased keywords, and this 
is very important it you want to manage your keywords for clojure.spec.

I only know about it because google turned up some clojure.spec notes on 
it, but it seems it should be in the mainline clojure docs too.
I certainly didn't know about it until today.

Say we have this namespace:

(ns foo 
  (:require [clojure.spec :as s]))
(s/def ::specific-even-number #(= 1000 %))




And then in the user namespace:

(ns user)
(require '[clojure.spec :as s])
(require '[foo :as f])


(s/valid? :f/specific-even-number 1000) 
;; Exception Unable to resolve spec: :f/specific-even-number  clojure.spec/
reg-resolve! (spec.clj:70)

What is needed is the extra colon, as if we're saying use the current 
namespace, only that isn't what happens.
(s/valid? ::f/specific-even-number 1000)
;; true

Perhaps the clojure docs are correctly stating the use of this kind of 
keyword my interpretation is just flawed, but it certainly wasn't obvious 
to me, and nobody in my team knew that we could do this either.  The result 
was some namespace unfriendly code to avoid typing in long namespaces on 
clojure spec keywords.  Now that we know ::ns-alias/keyword we can do 
better on our clojure.spec use.

(The above tested in clojure 1.8.0).

While I'm here, I want to say that I am _deeply_ disappointed that 
clojure.spec def/fdef forms don't support documentation strings.  I upvoted 
the issue in the bug tracker, but there were only 27 votes including mine 
when I checked on this half-year-plus old issue.
http://dev.clojure.org/jira/browse/CLJ-1965


-- 
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: lein project cross-reference tools

2016-04-19 Thread Dave Tenny
I'll take a look at that clj-refactor.

Re: IntelliJ.

I vaguely (possibly incorrectly) recall there was someone who used the
eclipse capabilities for java source code analysis and cross referencing
and packaged it up as some kind of emacs extension. I wonder if anybody has
done that with IntelliJ.



On Tue, Apr 19, 2016 at 2:49 PM, Colin Yates <colin.ya...@gmail.com> wrote:

> Have you tried the 'find usages' functionality of
> https://github.com/clojure-emacs/clj-refactor.el? Also - you might
> want to download IntelliJ and give cursive a try - cursive is
> fantastic for this sort of stuff
>
> ... and yes, I too feel a bit of despair that my suggestions is 'try
> this other tool, if that doesn't work, try this entire editor, if that
> doesn't work then' :-)
>
> On 19 April 2016 at 19:45, Dave Tenny <dave.te...@gmail.com> wrote:
> > Still looking for basic slime-like who-calls in cider.  Is it there and
> I'm
> > just missing it?
> >
> > On Tue, Apr 19, 2016 at 9:57 AM, Dave Tenny <dave.te...@gmail.com>
> wrote:
> >>
> >> Tags aside, a transtive closure who-calls report for a definition would
> >> still be appreciated.
> >>
> >> On Tue, Apr 19, 2016 at 9:53 AM, Dave Tenny <dave.te...@gmail.com>
> wrote:
> >>>
> >>> Hmm, okay, trying etags, certainly plenty of google hits there as
> opposed
> >>> to googling "cross reference".  FYI, in terms of emacs compatibility, I
> >>> generally use CIDER if anybody has suggestoins for how to search
> without a
> >>> live repl or with a live repl but across projects or uberjars.
> >>>
> >>> On Tue, Apr 19, 2016 at 9:33 AM, Dave Tenny <dave.te...@gmail.com>
> wrote:
> >>>>
> >>>> Oh, if crossclj DOES do what I'm asking, please let me know, I found
> the
> >>>> pages I visited a bit confusing as to how I might analyze my (private)
> >>>> projects.
> >>>>
> >>>> On Tue, Apr 19, 2016 at 9:30 AM, Dave Tenny <dave.te...@gmail.com>
> >>>> wrote:
> >>>>>
> >>>>> I'm tired of doing 'find-grep' type operations (including that
> command
> >>>>> in emacs).
> >>>>>
> >>>>> Are there any decent tools for producing cross reference reports and
> >>>>> emacs who-calls data in some useful form?
> >>>>>
> >>>>> A search on the topic mostly points to 'crossclj', which doesn't seem
> >>>>> to be what I want (I don't need to see who uses what from, say,
> clojars).
> >>>>>
> >>>>> I have a big project which, in conjunction with 'lein modules' has
> many
> >>>>> subprojects.  I can't really load a REPL on all of them in emacs.
> I'm happy
> >>>>> with source code analysis and the assumption that I don't need to
> know who
> >>>>> is calling functions by obscured dynamic lisp means.
> >>>>>
> >>>>>
> >>>>> --
> >>>>> 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/ejNMVjyjp-Q/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 patie

Re: lein project cross-reference tools

2016-04-19 Thread Dave Tenny
Still looking for basic slime-like who-calls in cider.  Is it there and I'm
just missing it?

On Tue, Apr 19, 2016 at 9:57 AM, Dave Tenny <dave.te...@gmail.com> wrote:

> Tags aside, a transtive closure who-calls report for a definition would
> still be appreciated.
>
> On Tue, Apr 19, 2016 at 9:53 AM, Dave Tenny <dave.te...@gmail.com> wrote:
>
>> Hmm, okay, trying etags, certainly plenty of google hits there as opposed
>> to googling "cross reference".  FYI, in terms of emacs compatibility, I
>> generally use CIDER if anybody has suggestoins for how to search without a
>> live repl or with a live repl but across projects or uberjars.
>>
>> On Tue, Apr 19, 2016 at 9:33 AM, Dave Tenny <dave.te...@gmail.com> wrote:
>>
>>> Oh, if crossclj DOES do what I'm asking, please let me know, I found the
>>> pages I visited a bit confusing as to how I might analyze my (private)
>>> projects.
>>>
>>> On Tue, Apr 19, 2016 at 9:30 AM, Dave Tenny <dave.te...@gmail.com>
>>> wrote:
>>>
>>>> I'm tired of doing 'find-grep' type operations (including that command
>>>> in emacs).
>>>>
>>>> Are there any decent tools for producing cross reference reports and
>>>> emacs who-calls data in some useful form?
>>>>
>>>> A search on the topic mostly points to 'crossclj', which doesn't seem
>>>> to be what I want (I don't need to see who uses what from, say, clojars).
>>>>
>>>> I have a big project which, in conjunction with 'lein modules' has many
>>>> subprojects.  I can't really load a REPL on all of them in emacs.  I'm
>>>> happy with source code analysis and the assumption that I don't need to
>>>> know who is calling functions by obscured dynamic lisp means.
>>>>
>>>>
>>>> --
>>>> 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/ejNMVjyjp-Q/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: lein project cross-reference tools

2016-04-19 Thread Dave Tenny
Tags aside, a transtive closure who-calls report for a definition would
still be appreciated.

On Tue, Apr 19, 2016 at 9:53 AM, Dave Tenny <dave.te...@gmail.com> wrote:

> Hmm, okay, trying etags, certainly plenty of google hits there as opposed
> to googling "cross reference".  FYI, in terms of emacs compatibility, I
> generally use CIDER if anybody has suggestoins for how to search without a
> live repl or with a live repl but across projects or uberjars.
>
> On Tue, Apr 19, 2016 at 9:33 AM, Dave Tenny <dave.te...@gmail.com> wrote:
>
>> Oh, if crossclj DOES do what I'm asking, please let me know, I found the
>> pages I visited a bit confusing as to how I might analyze my (private)
>> projects.
>>
>> On Tue, Apr 19, 2016 at 9:30 AM, Dave Tenny <dave.te...@gmail.com> wrote:
>>
>>> I'm tired of doing 'find-grep' type operations (including that command
>>> in emacs).
>>>
>>> Are there any decent tools for producing cross reference reports and
>>> emacs who-calls data in some useful form?
>>>
>>> A search on the topic mostly points to 'crossclj', which doesn't seem to
>>> be what I want (I don't need to see who uses what from, say, clojars).
>>>
>>> I have a big project which, in conjunction with 'lein modules' has many
>>> subprojects.  I can't really load a REPL on all of them in emacs.  I'm
>>> happy with source code analysis and the assumption that I don't need to
>>> know who is calling functions by obscured dynamic lisp means.
>>>
>>>
>>> --
>>> 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/ejNMVjyjp-Q/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: lein project cross-reference tools

2016-04-19 Thread Dave Tenny
Hmm, okay, trying etags, certainly plenty of google hits there as opposed
to googling "cross reference".  FYI, in terms of emacs compatibility, I
generally use CIDER if anybody has suggestoins for how to search without a
live repl or with a live repl but across projects or uberjars.

On Tue, Apr 19, 2016 at 9:33 AM, Dave Tenny <dave.te...@gmail.com> wrote:

> Oh, if crossclj DOES do what I'm asking, please let me know, I found the
> pages I visited a bit confusing as to how I might analyze my (private)
> projects.
>
> On Tue, Apr 19, 2016 at 9:30 AM, Dave Tenny <dave.te...@gmail.com> wrote:
>
>> I'm tired of doing 'find-grep' type operations (including that command in
>> emacs).
>>
>> Are there any decent tools for producing cross reference reports and
>> emacs who-calls data in some useful form?
>>
>> A search on the topic mostly points to 'crossclj', which doesn't seem to
>> be what I want (I don't need to see who uses what from, say, clojars).
>>
>> I have a big project which, in conjunction with 'lein modules' has many
>> subprojects.  I can't really load a REPL on all of them in emacs.  I'm
>> happy with source code analysis and the assumption that I don't need to
>> know who is calling functions by obscured dynamic lisp means.
>>
>>
>> --
>> 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/ejNMVjyjp-Q/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: lein project cross-reference tools

2016-04-19 Thread Dave Tenny
Oh, if crossclj DOES do what I'm asking, please let me know, I found the
pages I visited a bit confusing as to how I might analyze my (private)
projects.

On Tue, Apr 19, 2016 at 9:30 AM, Dave Tenny <dave.te...@gmail.com> wrote:

> I'm tired of doing 'find-grep' type operations (including that command in
> emacs).
>
> Are there any decent tools for producing cross reference reports and emacs
> who-calls data in some useful form?
>
> A search on the topic mostly points to 'crossclj', which doesn't seem to
> be what I want (I don't need to see who uses what from, say, clojars).
>
> I have a big project which, in conjunction with 'lein modules' has many
> subprojects.  I can't really load a REPL on all of them in emacs.  I'm
> happy with source code analysis and the assumption that I don't need to
> know who is calling functions by obscured dynamic lisp means.
>
>
> --
> 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/ejNMVjyjp-Q/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.


lein project cross-reference tools

2016-04-19 Thread Dave Tenny
I'm tired of doing 'find-grep' type operations (including that command in 
emacs).

Are there any decent tools for producing cross reference reports and emacs 
who-calls data in some useful form?  

A search on the topic mostly points to 'crossclj', which doesn't seem to be 
what I want (I don't need to see who uses what from, say, clojars).

I have a big project which, in conjunction with 'lein modules' has many 
subprojects.  I can't really load a REPL on all of them in emacs.  I'm 
happy with source code analysis and the assumption that I don't need to 
know who is calling functions by obscured dynamic lisp means.


-- 
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] Pipes 0.1.1 - chain processes, shell commands and threads via pipes

2015-11-13 Thread Dave Tenny
Just a bit of history from which you might derive some inspiration for your 
pipe metaphors in Clojure,
the scheme shell.

Main site: 
http://scsh.net/

Docs on various constructs, including process I/O operators:
http://scsh.net/docu/html/man-Z-H-1.html#node_toc_start



On Friday, November 13, 2015 at 9:13:56 AM UTC-5, Marcin Bilski wrote:
>
> Home: https://github.com/bilus/pipes
>
> If you ever used Un*x pipes
>
> ```
> $ ls | grep .clj
> ```
>
> then this library gives you a power to do this in Clojure and a lot more. 
>
> You can use streams to chain any number of shell commands, processes and 
> Clojure functions to process the streams on the fly. The library handles 
> error exit codes, exceptions by shutting down the pipeline and closing 
> intermediate streams. It also lets you cancel the entire pipeline with a 
> single function call and much more.
>
> I just pushed out the first version of the library. I extracted it from 
> production code so it's safe to use despite its low version number.
>
> The documentation is rudimentary and work in progress, I'm going to add 
> more examples.
>
> I'm looking forward to your feedback and, most of all, critique. Thank you.
>

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

2015-11-12 Thread Dave Tenny
Thanks for the replies, as always lots of interesting ways to do it in
clojure.  No zipper sugestions?

For my own take, I happen to like the last suggestion (Gareth's) the most I
think, of the ones offered so far.  It has a lispy elegance and is still
relatively efficient in traversals and memory allocation, compared to some
solutions (particular with a revision to the merge-roles implementation to
eliminate all the set creation, see next sentence).

Some of you rewrote the problem a bit.  For example, the 'merge-roles'
conversion to sets is very expensive, especially since I know that the
input in my original problem isn't going to offer duplicate project rules
for a given project ID.

On efficiency in general, it is perhaps a generational thing that people
say "don't prematurely optimize" so often and then cons up intermediate
objects with wild abandon.  And while a well crafted stop and copy garbage
collector can be have negligable GC time given sufficient memory free
space, allocations are still not free even in the best case, not to mention
the time to build the object being allocated (like hashing/comparing all
the values in a set).

I'd like to suggest that there is a difference between premature
optimization and avoiding flagrantly inefficient code.
If you code so that you routinely copy sequences and nested data structures
without a care, then in a serious/large system
your performance will have death by a thousand cuts.  The big O matters, at
least in some applications.

As indicated in this problem, the input is coming from a database, i.e. a
potentially large record source. My bias is that per-record processing is
always best kept to a minimum.  So inverting maps, copying sequences,
creating sets and such _*for every record*_ is just a big "nope" for me.
 And that doesn't even consider what went into the retrieval of the records
from clojure.java.jdbc/query, where every record comes back as a map unless
you do something to prevent it.

Meanwhile there were good suggestions for both abstraction and efficiency
here, thanks.  I often forget about lazy-seq and have a tendency to lean
toward loop/recur, probably from too many years using Common Lisp.  And of
course elimination of the mutable change detection hack is good too.So
nice to see the different ways people tackle the problem.


On Wed, Nov 11, 2015 at 10:02 PM, Gareth Clapperton <gclapper...@live.com>
wrote:

> Hey Daves
>
> I too like the map idea (and using sets for roles for that matter). But
> sticking with collections, I might do something like this
>
> (defn upsert
>   "Updates or inserts v into coll"
>   [key-fn update-fn v coll]
>   (let [k(key-fn v)]
> (letfn [(step [v [x & xs]]
>   (lazy-seq
> (cond
>   (nil? x) (when v [v])
>   (and (some? v) (= (key-fn x) k)) (cons (update-fn x v)
> (step nil xs))
>   :default (consx
>  (step  v  xs)]
>   (step v coll
>
> (defn merge-roles [p1 {:keys [project_roles] :as p2}]
>   (update-in p1 [:project_roles] #(vec (clojure.set/union (set %) (set
> project_roles)
>
> (upsert :project_id merge-roles prj-role prj-roles)
>
> Gareth
>
>
> On Wednesday, November 11, 2015 at 4:25:51 PM UTC-5, Dave Tenny wrote:
>>
>> A colleague and I are debating various things clojure as we were
>> exploring alternative ways to solve a problem.
>>
>> Here's the description of the problem that a particular function is
>> trying to solve, and the first implementation of it.
>>
>> (defn update-roles
>>   "Given a vector of maps of the form {:project_id N :project_name S
>> :project_roles [...roles...]}
>>   if there is already a map for the indicated project id/name, add
>> new-role to it and returned
>>   a copy the updated input vector, otherwise return a vector with a new
>> map entry for the newly found
>>   project and initial role.  This function is basically aggregating
>> tuples from the database."
>>   [projects project-id project-name new-role]
>>   (let [updated? (atom nil)
>>
>> projects* (mapv (fn [m]
>>   (if (= (:project_id m) project-id)
>> (do (reset! updated? true)
>> (assoc m :project_roles (conj (:project_roles
>> m) new-role)))
>> m))
>> projects)]
>> (if @updated?
>>   projects*
>>   (conj projects {:project_id project-id :project_name project-name 
>> :project_roles
>> [new-role]}
>>
>>
>> ;; (update-roles [{:project_id 1 :project_name "O

Style, Efficiency, and updating nested structure

2015-11-11 Thread Dave Tenny
A colleague and I are debating various things clojure as we were exploring 
alternative ways to solve a problem.

Here's the description of the problem that a particular function is trying 
to solve, and the first implementation of it.

(defn update-roles 
  "Given a vector of maps of the form {:project_id N :project_name S 
:project_roles [...roles...]}
  if there is already a map for the indicated project id/name, add new-role 
to it and returned
  a copy the updated input vector, otherwise return a vector with a new map 
entry for the newly found
  project and initial role.  This function is basically aggregating tuples 
from the database."
  [projects project-id project-name new-role]
  (let [updated? (atom nil)

projects* (mapv (fn [m] 
  (if (= (:project_id m) project-id)
(do (reset! updated? true)
(assoc m :project_roles (conj (:project_roles 
m) new-role)))
m))
projects)]
(if @updated?
  projects*
  (conj projects {:project_id project-id :project_name project-name 
:project_roles 
[new-role]}


;; (update-roles [{:project_id 1 :project_name "One" :project_roles [:own]}] 
2 "Two" :edit)
;; => [{:project_id 1, :project_name "One", :project_roles [:own]} {:project_id 
2, :project_name "Two", :project_roles [:edit]}]
;; (update-roles [{:project_id 1 :project_name "One" :project_roles [:own]}] 
1 "Two" :edit)
;; => [{:project_id 1, :project_name "One", :project_roles [:own :edit]}]



Now here's another implementation:

(defn update-or-insert-project-role
  [prj-roles prj-role]
  (let [to-insert-prj-id (:project_id prj-role)
by-pid   (group-by :project_id prj-roles)]
(case (get by-pid to-insert-prj-id)
  nil (conj prj-roles prj-role)
  (->> (update-in by-pid [to-insert-prj-id 0 :project_roles] #(apply conj % 
(:project_roles prj-role)))
   (mapcat second)
   (into [])

;; (def prj-roles [{:project_id 1, :project_name "One", :project_roles [:own]} 
{:project_id 3 :project_name "Three" :project_roles [:edit]}])
;; (update-or-insert-project-role prj-roles {:project_id 2 :project_name "Two" 
:project_roles [:edit]})
;; => [{:project_id 1, :project_name "One", :project_roles [:own]} {:project_id 
3, :project_name "Three", :project_roles [:edit]} {:project_id 2, :project_name 
"Two", :project_roles [:edit]}]
;; (update-or-insert-project-role prj-roles {:project_id 1 :project_name "One" 
:project_roles [:edit]})
;; => [{:project_id 1, :project_name "One", :project_roles [:own :edit]} 
{:project_id 3, :project_name "Three", :project_roles [:edit]}]




The function is called in a loop to aggregate rows from a database, though 
it isn't an overriding concern, we're not going millions of records in this 
case.

The first thing my colleague and I disagreed on was the calling sequence, 
arguing over which is more readable.
The second thing was whether efficiency in this context is really 
important, or whether it's all moot in clojure.  

Finally, I'm sure there's a better way, probably with Zippers or something, 
but neither of us have used them. Suggestions for the stylistic and 
operational epitome of clojure expression on this routine are welcome!

Superficially, and probably incorrect in multiple ways, here is a poor 
attempt at breaking down efficiency in terms of search/traversal and memory 
allocations.  This was done by someone with no knowledge of clojure 
internals (including the library implementations of the called functions).

;; Comparing the two routines per function call, for existing project case 
(i.e. where roles are updated)
;;
;; Assuming each routine allocates new vector for new-role placement in 
existing project
;; and MapEntry for assoc of new vector on project_roles, so they aren't 
included in allocations 
;; below since both routines have to do it.
;;
;; Note that x-element map allocates storage for map and map-entries or 
clojure equivalent.
;; (and more expensive than an x-element vector, of course).
;;
;; n == length of input project list.
;; m == average length of input project list role vectors.
;; 
;; Object Allocations
;;   Function call:
;; update-roles: 
;;   1 atom
;;   1 O(n) vector for mapv 
;; update-or-insert-project-role: 
;;   1 3-entry map + 1 single-element vector for prj-role argument 
input.
;;   1 n-element map for group-by
;;   n vectors for group-by map values
;;   1 n-element map for update-in
;;   1 list/sequence for mapcat (+ n concat intermediaries?)
;;   1 vector for into
;;
;; If we discard the second 'into' and first 'mapv' allocations the 
update-or-insert-project-role routine allocates
;; 3 additional maps (two of which are O(n)), n additional vectors, and 1 
additional list/sequence.
;;   
;; Searches/traversals/copies
;;  update-roles: 
;;   O(n) - mapv
;;  update-or-insert-project-role: 
;;   O(n) - 

Re: is there a community "best practice" for including your co-workers libraries?

2015-11-02 Thread Dave Tenny
ok, that must be the part I missed.

On Mon, Nov 2, 2015 at 7:01 PM, Sean Corfield <s...@corfield.org> wrote:

> Dave Tenny wrote on Monday, November 2, 2015 at 3:59 PM:
>
> I'm slightly confused, is there some reason Clojars <http://clojars.org/> 
> doesn't
> work for sharing libraries in this context?
>
>
> Because it’s public and sharing your companies libraries with the world
> might be frowned upon…?
>
> Sean
>
> --
> 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/myxUzM7TzYA/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: is there a community "best practice" for including your co-workers libraries?

2015-11-02 Thread Dave Tenny
I'm slightly confused, is there some reason Clojars  
doesn't 
work for sharing libraries in this context? 

-- 
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: 'seq' performance for 'empty?' compared to 'count'. And where's !=?

2015-10-02 Thread Dave Tenny
Re: where I got this from:

user> (doc empty?)
>
> -
>
> clojure.core/empty?
>
> ([coll])
>
>   Returns true if coll has no items - same as (not (seq coll)).
>
>   Please use the idiom (seq x) rather than (not (empty? x))
>
>
Note that 'empty?' just calls 'seq'.



On Thu, Oct 1, 2015 at 6:40 PM, Nathan Davis <
nda...@positronic-solutions.com> wrote:

> On Thursday, October 1, 2015 at 2:31:46 PM UTC-5, Dave Tenny wrote:
>>
>> So I understand that 'seq' is the idiomatic way to see if a
>> collection/sequence is empty.
>>
>>
> I'm not sure where you got this from.  I personally use empty? to check
> whether a collection is empty.  It is true that (not (empty c)) is not
> encouraged.  I believe the main rationale for this this is that (empty c)
> is (not (seq c)), so (not (empty c)) is (not (not (seq c)).
>
>
>> Logically I'm looking for an O(1) predicate with which I can determine if
>> a seq/collection is empty, and a well behaved
>> one that is idempotent and side effect free (for general performance
>> reasons).
>>
>
> I believe all the implementations of seq in Clojure core are O(1),
> although some (most?) allocate objects.  I'm not sure if it's explicitly
> spelled out anywhere, but I would consider it a bug it was anything other
> than O(1) (or perhaps O(log n) at most).
>
> In what ways is the current implementation of empty not well behaved and
> idempotent?
>
> With regards to side effects, if you can find a completely generic,
> side-effect-free way of determining whether a lazy sequence is empty
> without potentially realizing its head, please let the Clojure community
> know!
>
> I'm not saying having an explicit 'empty' method is a bad idea, but I'm
> not sure the current situation is as bad as you think.
>
> Nathan Davis
>
> --
> 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/fUygeQMPqyI/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.


'seq' performance for 'empty?' compared to 'count'. And where's !=?

2015-10-01 Thread Dave Tenny
So I understand that 'seq' is the idiomatic way to see if a 
collection/sequence is empty.

Logically I'm looking for an O(1) predicate with which I can determine if a 
seq/collection is empty, and a well behaved
one that is idempotent and side effect free (for general performance 
reasons).

'seq'  leaves something to be desired here since it does heap allocations 
when called with various types of arguments.

I'll also freely confess that I dislike seq as an emptiness predicate, I 
like empty? and not-empty? types of things, even better,
I loved Common Lisp's treatment where NIL and empty lists have the same 
value in conditional situations
(i.e. if x is an empty list it is == nil and is false, unlike Clojure).  I 
guess what I'm saying here is that 'seq' as idiomatic clojure for
empty tests is distasteful.

In my own personal libraries I use a predicate to give the common lisp like 
semantics I desire, but it still calls clojure.core/empty?,
which still calls 'seq'.  So all I've done is make the test more expensive 
even if I find it more readable.

While looking at the Clojure 1.7 implementation of 'seq' today in RT.java, 
I happened across the implementation of 'count',
and it occurred to me that it was a much leaner and meaner test for empty 
sequences than 'seq'.  So here are some timings.

user> (doseq [thing [[] {} #{} (seq []) (into [] (range 0 1000)) (range 0 
1000)]]
(println "Time for 1M seq on" (type thing))
(time (dotimes [i 100] (seq thing
Time for 1M seq on clojure.lang.PersistentVector
"Elapsed time: 18.993869 msecs"
Time for 1M seq on clojure.lang.PersistentArrayMap
"Elapsed time: 14.461354 msecs"
Time for 1M seq on clojure.lang.PersistentHashSet
"Elapsed time: 23.044994 msecs"
Time for 1M seq on nil
"Elapsed time: 8.291876 msecs"
Time for 1M seq on clojure.lang.PersistentVector
"Elapsed time: 21.214759 msecs"
Time for 1M seq on clojure.lang.LongRange
"Elapsed time: 6.27834 msecs"

Note the time on PersistentVector, we may have an O(n) implemention of `seq`
which is undesirable for an emptiness predicate.  Larger inputs require 
more time for 'seq' to return.

Now compare the same timings with 'count', adding in a clojure-level 
emptyness test (which would
no doubt be faster in RT.java):

user> (doseq [thing [[] {} #{} (seq []) (into [] (range 0 1000)) (range 0 
1000)]]
(println "Time for 1M count on" (type thing))
(time (dotimes [i 100] (== (count thing) 0

Time for 1M count on clojure.lang.PersistentVector
"Elapsed time: 8.061005 msecs"
Time for 1M count on clojure.lang.PersistentArrayMap
"Elapsed time: 7.297715 msecs"
Time for 1M count on clojure.lang.PersistentHashSet
"Elapsed time: 10.165718 msecs"
Time for 1M count on nil
"Elapsed time: 4.190523 msecs"
Time for 1M count on clojure.lang.PersistentVector
"Elapsed time: 8.772564 msecs"
Time for 1M count on clojure.lang.LongRange
"Elapsed time: 27.166397 msecs"


Except for the LongRange input, `count` is much faster.

So I'm just bringing it up for discussion, wondering if we can get a faster 
clojure.core
implementation of `empty?`.

That said, there is one apples-to-apples problem in the above.

(seq x) returns nil if empty.  (== (count x) 0) returns true if nil is 
empty.

Clojure neophyte that I am, I can't understand where there is not a "!=" 
function for numbers.
Wrapping the above test in a 'not' gives:

user> (doseq [thing [[] {} #{} (seq []) (into [] (range 0 1000)) (range 0 
1000)]]
(println "Time for 1M count on" (type thing))
(time (dotimes [i 100] (not (== (count thing) 0)

Time for 1M count on clojure.lang.PersistentVector
"Elapsed time: 15.961422 msecs"
Time for 1M count on clojure.lang.PersistentArrayMap
"Elapsed time: 11.12519 msecs"
Time for 1M count on clojure.lang.PersistentHashSet
"Elapsed time: 12.899191 msecs"
Time for 1M count on nil
"Elapsed time: 7.119841 msecs"
Time for 1M count on clojure.lang.PersistentVector
"Elapsed time: 11.454936 msecs"
Time for 1M count on clojure.lang.LongRange
"Elapsed time: 28.544915 msecs"

The O(1) times double when wrapping the test in 'not'.

Perhaps some clojurian will tell me what I should use.

Btw, don't even thing about 'not=':

user> (doseq [thing [[] {} #{} (seq []) (into [] (range 0 1000)) (range 0 
1000)]]
(println "Time for 1M count on" (type thing))
(time (dotimes [i 100] (not= (count thing) 0
Time for 1M count on clojure.lang.PersistentVector
"Elapsed time: 44.768754 msecs"
Time for 1M count on clojure.lang.PersistentArrayMap
"Elapsed time: 40.158507 msecs"
Time for 1M count on clojure.lang.PersistentHashSet
"Elapsed time: 41.868068 msecs"
Time for 1M count on nil
"Elapsed time: 36.098277 msecs"
Time for 1M count on clojure.lang.PersistentVector
"Elapsed time: 42.149571 msecs"
Time for 1M count on clojure.lang.LongRange
"Elapsed time: 59.107886 msecs"

Well, that's not fair of course since '(not (==' and '(not (='  are two 
different things.
But then you'd expect '=' to 

Re: Stuart Sierra's Component: retries & restarts in production

2015-09-04 Thread Dave Tenny
I'm using components to encapsulate Langohr/RabbitMQ interactions in cases 
where Langohr auto-recovery wasn't happy with what was going on.

I make sure the Lifecycle methods are idempotent, built the component stack 
in the correct order.  

To make sure that I can deal with the exceptions that require restarting 
the component stack, I have some macros that wrap up exception handling, 
retries, and component stack restarts.

So

(with-rmq-publisher! [channel component-system]
  ... do my stuff ...)

The body of the macro ("... do my stuff ...") is turned into a function and 
and will be re-executed if the system is restarted, so you have to beware
of side effects or other things you may not want executed multiple times. 
 Not a problem for me, all I'm doing is entering the macro long enough
to get a channel and publish to it, or similar types of things.

The component-system is a wrap of the system-map call with some other data, 
in an atom, that will be mutated
if we do things like dynamically add subscribers to the system or call 
(restart! component-system).
There are some thread safety/locking concerns, since a connection failure 
is likely to be seen by callers
on multiple threads using the components, and I try to avoid race 
conditions on restarts (only one thread will do the restart until it 
succeeds, 
the unblock the others).

Hope this helps with strategy, even if the code is omitted.

The trick to me was not in restarting the component stack, but in managing 
the shared state across threads safely and making sure (with-stack-activity 
[system] )
code was prepared to re-execute on failures with new connections or other 
stack components.

In my case I also needed to add components to the stack dynamically.  Not 
often, but dynamcially, not at (system-map) call time.  That required some 
lock consideration,
and I'd have to call Lifecycle/start on the stack every time I added a 
component.  They methods have to be idempotent.

  

-- 
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: Stuart Sierra's Component: retries & restarts in production

2015-09-04 Thread Dave Tenny
Caveat: my approach may have been all wrong.  It's the first time I tried
stuartsierra components.  Frankly I'd have been happier with some CLOS
objects and before and after methods, I'm still getting the hang of this
clojure stuff.

On Fri, Sep 4, 2015 at 7:57 AM, Dave Tenny <dave.te...@gmail.com> wrote:

> I'm using components to encapsulate Langohr/RabbitMQ interactions in cases
> where Langohr auto-recovery wasn't happy with what was going on.
>
> I make sure the Lifecycle methods are idempotent, built the component
> stack in the correct order.
>
> To make sure that I can deal with the exceptions that require restarting
> the component stack, I have some macros that wrap up exception handling,
> retries, and component stack restarts.
>
> So
>
> (with-rmq-publisher! [channel component-system]
>   ... do my stuff ...)
>
> The body of the macro ("... do my stuff ...") is turned into a function
> and and will be re-executed if the system is restarted, so you have to
> beware
> of side effects or other things you may not want executed multiple times.
> Not a problem for me, all I'm doing is entering the macro long enough
> to get a channel and publish to it, or similar types of things.
>
> The component-system is a wrap of the system-map call with some other
> data, in an atom, that will be mutated
> if we do things like dynamically add subscribers to the system or call
> (restart! component-system).
> There are some thread safety/locking concerns, since a connection failure
> is likely to be seen by callers
> on multiple threads using the components, and I try to avoid race
> conditions on restarts (only one thread will do the restart until it
> succeeds,
> the unblock the others).
>
> Hope this helps with strategy, even if the code is omitted.
>
> The trick to me was not in restarting the component stack, but in managing
> the shared state across threads safely and making sure (with-stack-activity
> [system] )
> code was prepared to re-execute on failures with new connections or other
> stack components.
>
> In my case I also needed to add components to the stack dynamically.  Not
> often, but dynamcially, not at (system-map) call time.  That required some
> lock consideration,
> and I'd have to call Lifecycle/start on the stack every time I added a
> component.  They methods have to be idempotent.
>
>
>
> --
> 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/JCvKLIsfSgA/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: How can find something inside heavily nested data structure ?

2015-08-24 Thread Dave Tenny
Specter looks nice.  I didn't see any examples in the readme or tests for 
working with more deeply nested data structures such as those discussed in 
this thread, any pointers?

On Sunday, August 23, 2015 at 10:22:25 PM UTC-4, Brian Marick wrote:



 Andy- wrote: 
  I have yet to evaluate it myself but this might do help you: 
  
  https://github.com/nathanmarz/specter 
  

 Specter is great. 


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


:arglists metadata on defmulti/defmethod forms

2015-08-23 Thread Dave Tenny
defmulti+detmethod doesn't seem to maintain any :arglists metadata with the 
Var filled by defmulti.  

How can I look up arglist information for multimethods like I can for 
regular function vars?


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


Java constructor question

2015-08-23 Thread Dave Tenny
Is there a way to parameterize a bit of code that invokes a constructor 
without calling the java.lang.reflect.Constructor class?

e.g.

(defn make-it [class]
  (new class abc)) ; won't work

(make-it IllegalArgumentException)  

I was trying to parameterize the class of exception thrown in a bit of code 
in my case,
but it appears the compiler wants a Class name and nothing else in java 
interop constructor positiosn.


-- 
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: Rabid wild animals in my clojure argument lists, code gets infected.

2015-08-23 Thread Dave Tenny
Note Colin, if I had declared foo differenlty, e.g. (defn foo [a b {:keys
[c d]}), that would be slightly different since it requires a map as third
argument.  But that is not the case with
(defn foo [a b  {:keys [c d]}]).  It may be using maps under the hood, but
none of my formal parameters are necessarily intended to be bound to maps
in this case, and I'm looking for a very fixed set of keywords in the
function call.



On Sun, Aug 23, 2015 at 10:17 AM, Dave Tenny dave.te...@gmail.com wrote:

 The point of my colorful title and judgmental post is that in the example,
 passing :e for the declared parameters as declared is a pointless operation
 at best, and in most practical situations it is also an erroneous
 operation.

 The language designers have (arguably for the good) chosen to complain
 about various actual argument mismatches vs. formal parameters.

 If I tried to call foo with only one argument I'd get an error about
 missing arguments (or more generally, arity).
 Similarly, in this case, calling foo with :e should complain about
 superfluous arguments, all assuming that foo is declared as intended.
 Without an :as option on the destructuring, there is nothing that can be
 done to meaningfully process a keyword to the function named :e.

 I am proposing the language should do better in this case. If not now,
 perhaps 2.0.


 On Sat, Aug 22, 2015 at 9:06 PM, Colin Yates colin.ya...@gmail.com
 wrote:

 Hi Dave, it _isn't_ an Illegal argument though :-), your destructuring
 is simply ignoring that parameter.

 However, I get the pain and solutions might be (in order of 'heavyness'):
  - http://blog.fogus.me/2009/12/21/clojures-pre-and-post/
  - https://github.com/Prismatic/schema
  - http://typedclojure.org/

 HTH

 Dave Tenny writes:

  I sure wish Clojure would generate IllegalArgumentException in the
  following sample case:
 
  (defn foo [a b  {:keys [c d]}] 1)
  (foo 1 2 :e 5) ; blithely ignores :e 5
 
  I understand that Clojure's destructuring things are very nice, and more
  powerful than Common Lisp's, and I like
  that when I need it.
 
  However I can't tell you how many times I've been bitten by this. Some
  simple typo or other other parameter name error on keyword arguments
  with untended and way-too-long-to-debug consequences.
 
  In my mind, on this subject, Common Lisp lambda lists got this right and
  Clojure gets a poor grade.
  Something about being doomed to repeat history.  In Common Lisp, if you
  really wanted to allow other (arbitrary) keywords you'd
  just use allow-other-keys.
 
  Maybe clojure should only allow the above case to go
 un-complained-about if
  :as was specified for the map.
 
  If there's some automatic enforcement I'm missing that comes with 'defn'
  please let me know, I'm still learning the language.
 
  I've thought more that once about making a common lisp DEFUN statement
 that
  maps to DEFN but implements
  lambda list semantics (including 'supplied-p' parameters).  I've just
 been
  too lazy to do it.
 
  It would also likely perform poorly after injecting the additional
  checks/rearrangements into the function on top of what Clojure has
 already
  done,
  so I suppose it would have to be taken a step further so that it didn't
  generate DEFN expressions at all but was implemented at DEFN's level as
  a seperately named form.
 
  Tips welcome.  Just thinking aloud.
 
  - Dave

 --
 Sent with my mu4e

 --
 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/3-CevvzQg1s/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: Rabid wild animals in my clojure argument lists, code gets infected.

2015-08-23 Thread Dave Tenny
The point of my colorful title and judgmental post is that in the example,
passing :e for the declared parameters as declared is a pointless operation
at best, and in most practical situations it is also an erroneous
operation.

The language designers have (arguably for the good) chosen to complain
about various actual argument mismatches vs. formal parameters.

If I tried to call foo with only one argument I'd get an error about
missing arguments (or more generally, arity).
Similarly, in this case, calling foo with :e should complain about
superfluous arguments, all assuming that foo is declared as intended.
Without an :as option on the destructuring, there is nothing that can be
done to meaningfully process a keyword to the function named :e.

I am proposing the language should do better in this case. If not now,
perhaps 2.0.


On Sat, Aug 22, 2015 at 9:06 PM, Colin Yates colin.ya...@gmail.com wrote:

 Hi Dave, it _isn't_ an Illegal argument though :-), your destructuring
 is simply ignoring that parameter.

 However, I get the pain and solutions might be (in order of 'heavyness'):
  - http://blog.fogus.me/2009/12/21/clojures-pre-and-post/
  - https://github.com/Prismatic/schema
  - http://typedclojure.org/

 HTH

 Dave Tenny writes:

  I sure wish Clojure would generate IllegalArgumentException in the
  following sample case:
 
  (defn foo [a b  {:keys [c d]}] 1)
  (foo 1 2 :e 5) ; blithely ignores :e 5
 
  I understand that Clojure's destructuring things are very nice, and more
  powerful than Common Lisp's, and I like
  that when I need it.
 
  However I can't tell you how many times I've been bitten by this. Some
  simple typo or other other parameter name error on keyword arguments
  with untended and way-too-long-to-debug consequences.
 
  In my mind, on this subject, Common Lisp lambda lists got this right and
  Clojure gets a poor grade.
  Something about being doomed to repeat history.  In Common Lisp, if you
  really wanted to allow other (arbitrary) keywords you'd
  just use allow-other-keys.
 
  Maybe clojure should only allow the above case to go un-complained-about
 if
  :as was specified for the map.
 
  If there's some automatic enforcement I'm missing that comes with 'defn'
  please let me know, I'm still learning the language.
 
  I've thought more that once about making a common lisp DEFUN statement
 that
  maps to DEFN but implements
  lambda list semantics (including 'supplied-p' parameters).  I've just
 been
  too lazy to do it.
 
  It would also likely perform poorly after injecting the additional
  checks/rearrangements into the function on top of what Clojure has
 already
  done,
  so I suppose it would have to be taken a step further so that it didn't
  generate DEFN expressions at all but was implemented at DEFN's level as
  a seperately named form.
 
  Tips welcome.  Just thinking aloud.
 
  - Dave

 --
 Sent with my mu4e

 --
 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/3-CevvzQg1s/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: Rabid wild animals in my clojure argument lists, code gets infected.

2015-08-23 Thread Dave Tenny
Timothy, I think maps vs keywords is a matter of preference.  Certainly
there are cases where I use maps of options instead of keywords, but it
depends on what I'm doing.   Lisp and keywords go way back, and I like
keywords when I'm using lisp packages/namespaces as the equivalent of an
interactive query language.

Even for the case of pure options passed as a map, you'll still potentially
have cases where you might like to validate that only *expected* keywords
were used. Whether a map as argument or a :as option to destructuring. And
it's all well and good to let the user of those maps write code to enforce
that.

However in the traditional use of keywords naming formal parameters there's
a long Common Lisp (at least) history of validating these bindings,
and there's also compile time capabilities too, though perhaps less
effectively in Clojure than CL.  Clojure has provided these keyword
capabilities,
I just object to this one hole because it has zero up side that I can see,
and substantial downside to writing correct programs.

On Sun, Aug 23, 2015 at 10:12 AM, Timothy Baldridge tbaldri...@gmail.com
wrote:

 It's generally considered better practice to pass maps to a function
 instead of keyword arguments. This also has the nice side-effect of making
 it easier to call programmatically  from other functions. For example:

 (my-func 1 2 (assoc default-opts :c 42)) is way cleaner than

 (apply my-func 1 2 (mapcat identity (assoc default-opts :c 42)))

 So don't do keyword argument, it rarely works out well. Instead accept a
 map of options and validate it with asserts, ignoring extra data. A map
 is a map, it shouldn't matter if it contains extra data.

 Timothy

 On Sat, Aug 22, 2015 at 7:21 PM, James Reeves ja...@booleanknot.com
 wrote:

 https://github.com/roomkey/annotate is another possibility

 - James

 On 23 August 2015 at 02:06, Colin Yates colin.ya...@gmail.com wrote:

 Hi Dave, it _isn't_ an Illegal argument though :-), your destructuring
 is simply ignoring that parameter.

 However, I get the pain and solutions might be (in order of 'heavyness'):
  - http://blog.fogus.me/2009/12/21/clojures-pre-and-post/
  - https://github.com/Prismatic/schema
  - http://typedclojure.org/

 HTH

 Dave Tenny writes:

  I sure wish Clojure would generate IllegalArgumentException in the
  following sample case:
 
  (defn foo [a b  {:keys [c d]}] 1)
  (foo 1 2 :e 5) ; blithely ignores :e 5
 
  I understand that Clojure's destructuring things are very nice, and
 more
  powerful than Common Lisp's, and I like
  that when I need it.
 
  However I can't tell you how many times I've been bitten by this. Some
  simple typo or other other parameter name error on keyword arguments
  with untended and way-too-long-to-debug consequences.
 
  In my mind, on this subject, Common Lisp lambda lists got this right
 and
  Clojure gets a poor grade.
  Something about being doomed to repeat history.  In Common Lisp, if you
  really wanted to allow other (arbitrary) keywords you'd
  just use allow-other-keys.
 
  Maybe clojure should only allow the above case to go
 un-complained-about if
  :as was specified for the map.
 
  If there's some automatic enforcement I'm missing that comes with
 'defn'
  please let me know, I'm still learning the language.
 
  I've thought more that once about making a common lisp DEFUN statement
 that
  maps to DEFN but implements
  lambda list semantics (including 'supplied-p' parameters).  I've just
 been
  too lazy to do it.
 
  It would also likely perform poorly after injecting the additional
  checks/rearrangements into the function on top of what Clojure has
 already
  done,
  so I suppose it would have to be taken a step further so that it didn't
  generate DEFN expressions at all but was implemented at DEFN's level as
  a seperately named form.
 
  Tips welcome.  Just thinking aloud.
 
  - Dave

 --
 Sent with my mu4e

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

Re: decoding clojure generated class names

2015-08-23 Thread Dave Tenny
Thanks Alex, clojure.lang.Compiler/demunge is just what I wanted.

On Sat, Aug 22, 2015 at 7:28 PM, Alex Miller a...@puredanger.com wrote:

 There is a demunge function in clojure.lang.Compiler. It's not foolproof
 as the munging is not unambiguously reversible.

 --
 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/5-l7bxFSOxk/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.


decoding clojure generated class names

2015-08-22 Thread Dave Tenny
I wanted to write a function like this:

(defn fn-name-info
  Given a function, try to deduce the function name and clojure namespace 
by looking 
  at the function's java class name and decoding stuff.  Return a vector of 
name, namespace strings, 
  or nil if we can't find anything.
  
  For example, if in jdt.core we do (defn foo []), the resulting value foo 
is a thing whose class is
  jdt.core$foo, for which we can return [\jdt.core\ \foo\].
  
  However, for anonymous functions like (fn []) typed into the REPL, 
  you're going to get something like [\jdt.core\ \eval3676$fn__3677\]
  [f]
  )

Surely someone out there has a bit of code that knows how to decode 
classnames accounting for
many of the weird edge cases, question marks (e.g. QMARK), and so on?

Can anybody help me out?

FYI, the next step I had planned for this was for me to reach take that fn 
information, look for the var that defines it, and yank out some metadata, 
when all I have is the function pointer, not the var.

Tips appreciated.

Yes, I know it's probably a bad idea for a couple of reasons, but feel free 
to point them out.


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


Rabid wild animals in my clojure argument lists, code gets infected.

2015-08-22 Thread Dave Tenny
I sure wish Clojure would generate IllegalArgumentException in the 
following sample case:

(defn foo [a b  {:keys [c d]}] 1)
(foo 1 2 :e 5) ; blithely ignores :e 5

I understand that Clojure's destructuring things are very nice, and more 
powerful than Common Lisp's, and I like
that when I need it.

However I can't tell you how many times I've been bitten by this. Some 
simple typo or other other parameter name error on keyword arguments
with untended and way-too-long-to-debug consequences.

In my mind, on this subject, Common Lisp lambda lists got this right and 
Clojure gets a poor grade.
Something about being doomed to repeat history.  In Common Lisp, if you 
really wanted to allow other (arbitrary) keywords you'd
just use allow-other-keys.  

Maybe clojure should only allow the above case to go un-complained-about if 
:as was specified for the map.

If there's some automatic enforcement I'm missing that comes with 'defn' 
please let me know, I'm still learning the language.

I've thought more that once about making a common lisp DEFUN statement that 
maps to DEFN but implements
lambda list semantics (including 'supplied-p' parameters).  I've just been 
too lazy to do it.  

It would also likely perform poorly after injecting the additional 
checks/rearrangements into the function on top of what Clojure has already 
done,
so I suppose it would have to be taken a step further so that it didn't 
generate DEFN expressions at all but was implemented at DEFN's level as 
a seperately named form.

Tips welcome.  Just thinking aloud.

- Dave

-- 
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 can find something inside heavily nested data structure ?

2015-08-20 Thread Dave Tenny
I have found the core 'get-in' function to be useful for extracting data 
from big trees of clojure data structures, perhaps
that will help.

I'm still in search of tools that let me get a good sense of *what* to 
navigate when looking at such trees
of data structures from API's  and/or data sources I'm unfamiliar with.  I 
find that to be pretty painful, not least
because emacs (and maybe the REPL) get seriously compute wedged printing 
large data structures.

An example of this is Amazonica, which will flatten ALL the data in a 
hierarchy of java data structures from
the AWS SDK into one gigantic tree.  It's a nifty tool, but the resulting 
flood of data with one careless query or printed tree fragment has been 
known to knock out my emacs session for minutes at a time.

I wrote a tool to analyze unique key paths in large trees so that I might 
know, for a given tree, what would be useful to provide as the access path 
to 'get-in'.
However I'm not happy enough with my tool to post it here, it needs some 
kind of syntax for describing sequences in the tree (since you don't want 
to see every unique key
used to access a sequence of 10,000 things).


On Wednesday, August 19, 2015 at 10:18:06 AM UTC-4, Hussein B. wrote:

 Hi,

 I have transformed JSON response into the equivalent data structure using 
 Cheshire library.

 The result is a huge nested data structure , mostly vectors and maps. It 
 is actually a tree.

 How to find a property that is nested deep inside the tree ? For example 
 I'm search for the node that has the value zyx for property uuid.

 What I'm supposed to use? Something like zipper or walk? or something 
 simpler is available?

 Thanks for help.


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


apply, mapply, recur, looking for insights

2015-08-13 Thread Dave Tenny
These inconsistencies are bugging me, I just wondered if I was missing some 
standard language thing about argument passing or destructuring, so I'm 
looking for comments.

At issue (for me), keyword arguments and maps that bundle them.

user (defn foo [a b  {:keys [c d]}]
[a b c d])
#'user/foo
user (defn bar [a b  {:keys [c d] :as options}]
(println (apply foo a b options)))
#'user/bar
user (bar 1 2)
[1 2 nil nil]
nil
;; Okay so far

user (bar 1 2 :c 3)
IllegalArgumentException No value supplied for key: [:c 3] 
 clojure.lang.PersistentHashMap.create (PersistentHashMap.java:77)

;; I'm wishing the above was smarter, but okay, so I use 'mapply', which 
seems to me it ought to be in clojure.core but isn't.

user (defn mapply
  [f  args]
  (apply f (apply concat (butlast args) (last args
#'user/mapply
user (defn bar2 [a b  {:keys [c d] :as options}]
(println (mapply foo a b options)))
#'user/bar2
user (bar2 1 2 :c 3)
[1 2 3 nil]
nil

;; Okay, that works nicely


So maybe this is all fine, though if there's some standard way of doing 
this using things shipped with clojure please let me know.

However then 'recur' bucks the trend, which adds to confusion.

user (defn baz [a b  {:keys [c d] :as options}]
(if ( a 0)
  (recur (- a 1) b options)
  [a b c d]))
#'user/baz
user (baz 2 3 :c 4)
[0 3 4 nil]

So recur does this arguably very useful thing, but apply does not (and 
probably with good reason, otherwise how would we pass maps as regular 
arguments...)

I guess what I'm seeking is the canonical clojure approach to dealing with 
keyword arguments and maps in call sites, and I find
the apply/recur difference confusing, and the lack of 'mapply' an oversight.

Thoughts?  Comments?  Please educate on what I'm missing, 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.


com.stuartsierra.component dynamic component addition/removal question

2015-08-11 Thread Dave Tenny
I want to add components to a started system, but I'm unsure of a 
component-idiomatic way to do that.

I don't want to restart the whole component stack.  I'm guessing assoc'ing 
a new component to the system-map result isn't a good idea (though I've 
read words that sounded like it was a fine thing to do), but then I'd have 
a component that hasn't been started residing with other components that 
have been started.

I though of adding a static component called akin to a pooling component, 
which I would then modify directly in response to my needs, but then I'd 
have a mutable component and that isn't particularly desirable either.

For purposes of discussion let's say this is what I want:

(component/system-map
  {:connection (make-connection)
   :subscriber-1 (component/using (make-subscriber) [:connection])
   ... more subscribers after starting the system ...
  }
)

It isn't a nice prospect to declare all my subscribers at system-map 
declaration time or (start) lifecycle time,
I want my system to respond like a service and add new instances of what 
are essentially components.

So I either need to graft more components to the resulting system-map, or 
make a make a system map entity that is mutable and tracks the pool of 
subscribers.
Under this model I'd have 

(component/system-map
  {:connection (make-connection)
   :subscriber-pool (component/using (make-subscriber-pool) [:connection])
  })

Then I'd basically have functions to mutate (:subscriber-pool system) by 
adding/removing subscribers

Thoughts?


-- 
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: com.stuartsierra.component dynamic component addition/removal question

2015-08-11 Thread Dave Tenny
Or maybe I just do

(start (assoc system :new-subscriber (component/using (make-subscriber) 
[:connection])))
and ensure idempotent start capabilities across all components that will 
not attempt restarts.

?  

Just looking for the idiomatic component way of doing this.

On Tuesday, August 11, 2015 at 11:49:10 AM UTC-4, Dave Tenny wrote:

 I want to add components to a started system, but I'm unsure of a 
 component-idiomatic way to do that.

 I don't want to restart the whole component stack.  I'm guessing assoc'ing 
 a new component to the system-map result isn't a good idea (though I've 
 read words that sounded like it was a fine thing to do), but then I'd have 
 a component that hasn't been started residing with other components that 
 have been started.

 I though of adding a static component called akin to a pooling component, 
 which I would then modify directly in response to my needs, but then I'd 
 have a mutable component and that isn't particularly desirable either.

 For purposes of discussion let's say this is what I want:

 (component/system-map
   {:connection (make-connection)
:subscriber-1 (component/using (make-subscriber) [:connection])
... more subscribers after starting the system ...
   }
 )

 It isn't a nice prospect to declare all my subscribers at system-map 
 declaration time or (start) lifecycle time,
 I want my system to respond like a service and add new instances of what 
 are essentially components.

 So I either need to graft more components to the resulting system-map, or 
 make a make a system map entity that is mutable and tracks the pool of 
 subscribers.
 Under this model I'd have 

 (component/system-map
   {:connection (make-connection)
:subscriber-pool (component/using (make-subscriber-pool) [:connection])
   })

 Then I'd basically have functions to mutate (:subscriber-pool system) by 
 adding/removing subscribers

 Thoughts?




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


[clojure-rabbitmq] autorecovery failure on queue status operation

2015-07-24 Thread Dave Tenny
I have a number of rabbitmq clients, most of which fail over well enough, 
but one client is experiencing apparent thread death on a queue status 
operation when the connection times out on heartbeat.
I wondered if anybody had any clues here.  Note the 
langohr.queue$status.invoke()

Exception in thread async-dispatch-3 java.lang.Error: java.io.IOException
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1151)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:106)
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:102)
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:124)
at com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:873)
at 
com.rabbitmq.client.impl.recovery.AutorecoveringChannel.queueDeclarePassive(AutorecoveringChannel.java:287)
at langohr.queue$status.invoke(queue.clj:130)
at de.data.messaging.scheduler$fill_jobs_BANG_.invoke(scheduler.clj:115)
at 
de.data.messaging.scheduler$go_release_jobs_BANG_$fn__1064$state_machine__11049__auto1065$fn__1067.invoke(scheduler.clj:129)
at 
de.data.messaging.scheduler$go_release_jobs_BANG_$fn__1064$state_machine__11049__auto1065.invoke(scheduler.clj:129)
at 
clojure.core.async.impl.ioc_macros$run_state_machine.invoke(ioc_macros.clj:940)
at 
clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:944)
at 
clojure.core.async.impl.ioc_macros$take_BANG_$fn__11065.invoke(ioc_macros.clj:953)
at 
clojure.core.async.impl.channels.ManyToManyChannel$fn__7516.invoke(channels.clj:102)
at clojure.lang.AFn.run(AFn.java:22)
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
... 2 more
Caused by: com.rabbitmq.client.ShutdownSignalException: connection error
at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:67)
at 
com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:33)
at 
com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:348)
at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:221)
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:118)
... 14 more
Caused by: com.rabbitmq.client.MissedHeartbeatException: Heartbeat missing 
with heartbeat = 60 seconds
at 
com.rabbitmq.client.impl.AMQConnection.handleSocketTimeout(AMQConnection.java:597)
at com.rabbitmq.client.impl.AMQConnection.access$600(AMQConnection.java:65)
at 
com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:560)
... 1 more

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


Re: Supplied-p parameter in clojure similar to lisp lambda lists

2014-08-18 Thread Dave Tenny
I don't think that a :p feature is necessary, since all you need to do to
emulate it is a
(:baz all-keys) to know if the user explicitly specified it.  I.e. I think
the capability is already present in adequate form but the documentation on
map destructuring could be improved.




On Sun, Aug 17, 2014 at 11:02 PM, dennis zhuang killme2...@gmail.com
wrote:

 I think that adding a :p option to destructuring would be great:

 (let [ {:keys [a b c] :p {a a-p}} params]
 (if a-p
 (println a)
 (println a is not exists.)))






 2014-08-17 20:05 GMT+08:00 Dave Tenny dave.te...@gmail.com:

 Well, it took me a while to perhaps get what you were telling me here.

 In my case I I had something like

 (defn foo [  {:keys [bar ... more keys ...] :or {bar 1}} ] ...)

 and I wanted to know whether the user had explicilty invoked foo with
 :bar.

 What wasn't clear to me was that :as solved this problem.
 Reading http://clojure.org/special_forms#Special Forms--Binding Forms
 (Destructuring)-Map binding destructuring
 I guess I can see that it's telling me :as shows things that weren't in
 the init-form, but that's with hindsight.

 So, to emulated common lisp 'supplied-p' semantics, you can check the :as
 form, which will **not**
 contain :or values for keywords.

 E.g.

 user (defn bar [  {:keys [baz] :or {baz 'baz} :as all-keys} ] (println
 baz all-keys))
 #'user/bar
 user (bar :bof 1)
 baz {:bof 1}
 nil

 And not that the all-keys form does not show a binding for baz, and
 that's what I wanted.

 Just fyi in case anybody searches topics for 'supplied-p' again.


 On Saturday, June 21, 2014 7:22:13 PM UTC-4, Jason Felice wrote:

 If you destructure the parameters like this:
 (defn f [ {:as a-map}] ...)

 You can use map primitives on a-map.  But you can also supply defaults
 here.
  On Jun 20, 2014 2:14 PM, Dave Tenny dave@gmail.com wrote:

  What is the commonly accepted technique for declaring/using
 'supplied-p' type lambda list functionality in clojure?

 http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/
 HyperSpec/Body/sec_3-4-1.html


 I have some clojure functions with a large number of keywords and
 various defaults, I want to know if a keyword was specified by the caller
 (rather than defaulted) in some cases.

 Certainly I could implement my own destructuring macros that did this,
 but I'd like to avoid reinventing a wheel here if I can, and also to know
 the idiomatic clojure way to do it.

 Thanks for any tips.


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




 --
 庄晓丹
 Email:killme2...@gmail.com xzhu...@avos.com
 Site:   http://fnil.net
 Twitter:  @killme2008


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

Re: Supplied-p parameter in clojure similar to lisp lambda lists

2014-08-17 Thread Dave Tenny
Well, it took me a while to perhaps get what you were telling me here.

In my case I I had something like

(defn foo [  {:keys [bar ... more keys ...] :or {bar 1}} ] ...)

and I wanted to know whether the user had explicilty invoked foo with :bar.

What wasn't clear to me was that :as solved this problem.  
Reading http://clojure.org/special_forms#Special Forms--Binding Forms 
(Destructuring)-Map binding destructuring
I guess I can see that it's telling me :as shows things that weren't in the 
init-form, but that's with hindsight.

So, to emulated common lisp 'supplied-p' semantics, you can check the :as 
form, which will **not**
contain :or values for keywords.

E.g.

user (defn bar [  {:keys [baz] :or {baz 'baz} :as all-keys} ] (println 
baz all-keys))
#'user/bar
user (bar :bof 1)
baz {:bof 1}
nil

And not that the all-keys form does not show a binding for baz, and that's 
what I wanted.

Just fyi in case anybody searches topics for 'supplied-p' again.


On Saturday, June 21, 2014 7:22:13 PM UTC-4, Jason Felice wrote:

 If you destructure the parameters like this:
 (defn f [ {:as a-map}] ...)

 You can use map primitives on a-map.  But you can also supply defaults 
 here.
  On Jun 20, 2014 2:14 PM, Dave Tenny dave@gmail.com javascript: 
 wrote:

 What is the commonly accepted technique for declaring/using 'supplied-p' 
 type lambda list functionality in clojure?


 http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/sec_3-4-1.html


 I have some clojure functions with a large number of keywords and various 
 defaults, I want to know if a keyword was specified by the caller (rather 
 than defaulted) in some cases.

 Certainly I could implement my own destructuring macros that did this, 
 but I'd like to avoid reinventing a wheel here if I can, and also to know 
 the idiomatic clojure way to do it.

 Thanks for any tips.


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


Compilation failure to reject arguments matching formal parameters

2014-08-15 Thread Dave Tenny
This is getting old.   Any suggestions or plans to fix it?  Do I need to 
use some other common declaration style for functions?

; CIDER 0.5.0 (Clojure 1.6.0, nREPL 0.2.3)
user (defn foo [ {:keys [bar]}] bar)
#'user/foo
user (foo :baz 1)
nil

In my opinion the compilation of the call to foo should have complained 
about :baz not matching a known parameter.

Failure to do this leads to lots of extra debugging because someone had a 
typo in a keyword name,
e.g. :Name instead of :name or :product instead of :project, or 
whatever.

This is probably the leading cause of unexpected program operation in 
clojure for me.


-- 
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: Stumped: unable to resolve symbol in macro expansion

2014-07-22 Thread Dave Tenny
Doh!  Major face palm.  I had such a bad case of tunnel vision on the macro
definition I forgot to look up the stack once I'd fixed the macro.  Thanks.
 Good to have extra eyes.


On Mon, Jul 21, 2014 at 1:04 PM, Matthew DeVore matv...@gmail.com wrote:

 I haven't taken the time to fully grok your macro, but the error is not
 the fault of your macro, but of the function invocation. (foo x) is causing
 the error because x is undefined. foo is a plain function, not a macro, so
 it tries to evaluate each argument. (foo 'x) works fine for me, as does
 (let [x 42] (foo x))

 I guess the fact that (foo x) recycled the name of the parameter used in
 the function definition is what made the error message confusing?


 On Monday, July 21, 2014 9:49:10 AM UTC-7, Dave Tenny wrote:

 In my case, I'm trying to use a the expression '[x] that is available to
 the macro in the resulting product.  So I don't want the value of x at all,
 just a vector with the symbol x.

 That vector is in a variable I have in the macro named
 'positional-parameters', so I substitute '~positional-parameters to with
 the hope of getting '[x] in the resulting definition.

 Here's a fragment of the overall defs.  As you can see I'm just messing
 around, I was trying to write a defun with 'supplied-p' lambda list
 semantics, and my clojure/macrology is awful.  It's the macro near the
 bottom.  You can append this to
 https://github.com/dtenny/clojdt/blob/master/src/jdt/cl.clj if you want
 to git clone and compile it.

 (def lambda-list-keyword-symbols
   Symbols without namespace specifications
   (into #{} (map symbol [allow-other-keys key rest aux
 optional])))

 (defn lambda-list-keyword?
   If x is a lambda list keyword, in any case, return the canonicalized
 form as a symbol.
If it starts with an ampersand but is not a valid lambda list keyword,
 throw an exception.
   [x]
   (let [sym-name (.toLowerCase (name x))]
 (if (= (first sym-name) \)
   (if-let [lambda-sym (lambda-list-keyword-symbols (symbol sym-name))]
 lambda-sym
 (throw (Exception. (str ' x ' is not a valid lambda list
 keyword.
   nil)))

 (defn lambda-list-segment
   Return three values in a vector.

The first value is a vector of non-lambda-list-keywords
in l before the next lambda list keyword in the list.  Order is
 preserved.

The second value is the canonicalized lambda list keyword (as a
 clojure symbol, e.g. 'aux)
that terminated accumulation, or nil if we reached the end of the list.

The third value is the rest of the list following the lambda list
 keyword, or nil if there aren't
any more values.

E.g. (lambda-list-segment '(a b optional c))
 = [[a b] optional (c)]
   [l]
   (loop [result [] l l]
 (if (empty? l)
   [result nil nil]
   (let [head (first l)
 tail (rest l)
 lambda-keyword (lambda-list-keyword? head)]
 (if lambda-keyword
   [result lambda-keyword tail]
   (recur (conj result head) tail))

 (defn partition-lambda-list
   Return a map keyed by lambda list keyword (or the pseudo keyword
 'positional'
for positional args), and valued by a vector lambda vars associated
 with the
type of lambda list element, in the order specified by the caller.
E.g. (partition-lambda-list [a b c optional (d nil d-supplied-p) key
 e])
 = {positional [a b c] optional [(d nil d-supplied-p)] key [e]}
Ignore case in things appearing to be lambda list keywords.
Complain if any symbol begins with an ampersand and is not a valid
 lambda list keyword.
Preserve order of parameters.
   [lambda-list]
   (let [first-chunk (lambda-list-segment lambda-list)
 positionals (first first-chunk)]
 (loop [result {'positional positionals}
next-lambda-key (second first-chunk)
lambda-list (nth first-chunk 2)]
   (if (empty? lambda-list)
 (if next-lambda-key
   (merge result {next-lambda-key []}) ; in case it's
 allow-other-keys
   result)
 (let [chunk (lambda-list-segment lambda-list)]
   (recur (merge result {next-lambda-key (first chunk)})
  (second chunk)
  (nth chunk 2)))

 (defn parse-defun-decls
   Parse defun elements following the lambda list.
If there are declarations, strip them from the sequence.
Return a vector of two things.
1) the docstring, or nil if there isn't one.
2) forms following the optional declarations and docstring, nil if
 there aren't any.
   [s]
   (let [declare? (fn [l]
(and (list? l)
 (.equalsIgnoreCase (name (first l)) declare)))]
 (loop [s s]
   (if (empty? s)
 [nil nil]
 (let [head (first s)]
   (cond (string? head) [head (rest s)] ; **BUG** won't work if
 declare is after docstring
 (declare? head) (recur (rest s))
 :else [nil s]))

 (defn positional-values

Re: Stumped: unable to resolve symbol in macro expansion

2014-07-21 Thread Dave Tenny
In my case, I'm trying to use a the expression '[x] that is available to
the macro in the resulting product.  So I don't want the value of x at all,
just a vector with the symbol x.

That vector is in a variable I have in the macro named
'positional-parameters', so I substitute '~positional-parameters to with
the hope of getting '[x] in the resulting definition.

Here's a fragment of the overall defs.  As you can see I'm just messing
around, I was trying to write a defun with 'supplied-p' lambda list
semantics, and my clojure/macrology is awful.  It's the macro near the
bottom.  You can append this to
https://github.com/dtenny/clojdt/blob/master/src/jdt/cl.clj if you want to
git clone and compile it.

(def lambda-list-keyword-symbols
  Symbols without namespace specifications
  (into #{} (map symbol [allow-other-keys key rest aux
optional])))

(defn lambda-list-keyword?
  If x is a lambda list keyword, in any case, return the canonicalized
form as a symbol.
   If it starts with an ampersand but is not a valid lambda list keyword,
throw an exception.
  [x]
  (let [sym-name (.toLowerCase (name x))]
(if (= (first sym-name) \)
  (if-let [lambda-sym (lambda-list-keyword-symbols (symbol sym-name))]
lambda-sym
(throw (Exception. (str ' x ' is not a valid lambda list
keyword.
  nil)))

(defn lambda-list-segment
  Return three values in a vector.

   The first value is a vector of non-lambda-list-keywords
   in l before the next lambda list keyword in the list.  Order is
preserved.

   The second value is the canonicalized lambda list keyword (as a clojure
symbol, e.g. 'aux)
   that terminated accumulation, or nil if we reached the end of the list.

   The third value is the rest of the list following the lambda list
keyword, or nil if there aren't
   any more values.

   E.g. (lambda-list-segment '(a b optional c))
= [[a b] optional (c)]
  [l]
  (loop [result [] l l]
(if (empty? l)
  [result nil nil]
  (let [head (first l)
tail (rest l)
lambda-keyword (lambda-list-keyword? head)]
(if lambda-keyword
  [result lambda-keyword tail]
  (recur (conj result head) tail))

(defn partition-lambda-list
  Return a map keyed by lambda list keyword (or the pseudo keyword
'positional'
   for positional args), and valued by a vector lambda vars associated with
the
   type of lambda list element, in the order specified by the caller.
   E.g. (partition-lambda-list [a b c optional (d nil d-supplied-p) key
e])
= {positional [a b c] optional [(d nil d-supplied-p)] key [e]}
   Ignore case in things appearing to be lambda list keywords.
   Complain if any symbol begins with an ampersand and is not a valid
lambda list keyword.
   Preserve order of parameters.
  [lambda-list]
  (let [first-chunk (lambda-list-segment lambda-list)
positionals (first first-chunk)]
(loop [result {'positional positionals}
   next-lambda-key (second first-chunk)
   lambda-list (nth first-chunk 2)]
  (if (empty? lambda-list)
(if next-lambda-key
  (merge result {next-lambda-key []}) ; in case it's
allow-other-keys
  result)
(let [chunk (lambda-list-segment lambda-list)]
  (recur (merge result {next-lambda-key (first chunk)})
 (second chunk)
 (nth chunk 2)))

(defn parse-defun-decls
  Parse defun elements following the lambda list.
   If there are declarations, strip them from the sequence.
   Return a vector of two things.
   1) the docstring, or nil if there isn't one.
   2) forms following the optional declarations and docstring, nil if there
aren't any.
  [s]
  (let [declare? (fn [l]
   (and (list? l)
(.equalsIgnoreCase (name (first l)) declare)))]
(loop [s s]
  (if (empty? s)
[nil nil]
(let [head (first s)]
  (cond (string? head) [head (rest s)] ; **BUG** won't work if
declare is after docstring
(declare? head) (recur (rest s))
:else [nil s]))

(defn positional-values
  Given a sequence of formal parameter names for positional values
   and a sequence of actual arguments to a defun'ed function call,
   return a vector of values from actual args to be bound to parameters.
   Return [] if there aren't any.
  [parameters actual-args]
  (if parameters
(if ( (count actual-args) (count parameters))
  (throw (Exception. (str Insufficient arguments in  actual-args
   to match positional parameters in 
parameters)))
  (loop [values [] args actual-args]
(if (empty? args)
  values
  (recur (conj values (first args)) (rest args)
[]))

;; *FINISH*: define/support RETURN-FROM

(defmacro defun
  defun function-name lambda-list [[declaration* | documentation]] form*
   = function-name
   Arguments and Values:
function-name---a function name.
lambda-list---an ordinary 

Supplied-p parameter in clojure similar to lisp lambda lists

2014-06-20 Thread Dave Tenny
What is the commonly accepted technique for declaring/using 'supplied-p' 
type lambda list functionality in clojure?

http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/sec_3-4-1.html


I have some clojure functions with a large number of keywords and various 
defaults, I want to know if a keyword was specified by the caller (rather 
than defaulted) in some cases.

Certainly I could implement my own destructuring macros that did this, but 
I'd like to avoid reinventing a wheel here if I can, and also to know the 
idiomatic clojure way to do it.

Thanks for any tips.


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


Checking: Java 8 and Clojure

2014-06-03 Thread Dave Tenny
The clojure site says 1.6.0 is supported with java 6 and higher.

I just wanted to double check whether people have been using it with Java 8 
and whether it's believed to be stable when used with Java 8 before I tell 
people I work with that they can use it with Java 8.

Thumbs up for java 8 and clojure?

Thanks,

Dave

-- 
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: Checking: Java 8 and Clojure

2014-06-03 Thread Dave Tenny
Thanks all, good to know.

On Tuesday, June 3, 2014 12:17:52 PM UTC-4, Dave Tenny wrote:

 The clojure site says 1.6.0 is supported with java 6 and higher.

 I just wanted to double check whether people have been using it with Java 
 8 and whether it's believed to be stable when used with Java 8 before I 
 tell people I work with that they can use it with Java 8.

 Thumbs up for java 8 and clojure?

 Thanks,

 Dave


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


Question: defrecord accessor efficiency without protocols

2014-05-16 Thread Dave Tenny
(defrecord Foo [bar])

(:bar (Foo. 1))

Is clojure smart enough to make the :bar lookup O(1) as a known field of 
Foo?  Or is it still a map-like O(logN) lookup?


-- 
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: determining repl environment vs. uberjar environment?

2014-05-08 Thread Dave Tenny
Here's a solution to the problem I was trying to solve.  I'm not happy with
it (the definition of has-repl?), but it's working for now.
It's also Sun/Oracle JVM specific with the sun.java.command clause.

Again, the problem is that I wanted an exit routine I could call that
wouldn't terminate the jvm when I'm running -main from the REPL, but that
otherwise calls System/exit when running as an uberjar.

Other suggestions welcome.

(defn has-repl?
  Return true if we appear to be running with a REPL, false otherwise.
  []
  ;; *TBD*: Consider looking for some particular repl routine in jvm stack
traces
  ;; Don't care about the clojure.* prop vals, just that the property
exists.
  (if (or (System/getProperty clojure.debug)
  (System/getProperty clojure.compile.path)
  (if-let [command (System/getProperty sun.java.command)]
(.contains command clojure.main)))
true
false))

(defn- exit [status  [msg]]
  (when msg
(println msg))
  (flush)
  (if (has-repl?)
(throw (ex-info msg {:repl-exit true :status status}))
(System/exit status)))

;; And in (-main)
...
  (catch Exception e
(if-let [m (ex-data e)]
  ;; exception is of type clojure.lang.ExceptionInfo
  (if (:repl-exit m)
(:status m)
(exit 2 (str Unexpected ex-data: m on e)))
  ;; Caught an exception that wasn't thrown via pseudo-exit
  (if (has-repl?)
(println (str e))   ;print to REPL
(exit 2 (str e  ;print and exit java



On Tue, Apr 22, 2014 at 12:59 PM, Dave Tenny dave.te...@gmail.com wrote:

 I have an app I'm building.  It calls System/exit.  That doesn't works so
 well if I'm debugging in the REPL however.

 What's the preferred method of determining whether I'm in REPL mode
 interaction vs running as a standalone app?

 Also, long as I'm asking and being lazy, does the -main function return
 value translate to a System/exit value if it's numeric?
 Or is System/exit the way to go?

 --
 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/KZJQsmOeiHc/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: determining repl environment vs. uberjar environment?

2014-05-08 Thread Dave Tenny
When running as an uberjar, i.e. java -jar myapp.jar [args]
the return code of the process to the shell is very important.  System/exit
is how that return code is sent.


On Thu, May 8, 2014 at 9:20 AM, James Reeves ja...@booleanknot.com wrote:

 Having your application call System/exit directly is often indicative of
 some unnecessary coupling in your code.

 Under what circumstances does your application need to exit?

 - James


 On 22 April 2014 17:59, Dave Tenny dave.te...@gmail.com wrote:

 I have an app I'm building.  It calls System/exit.  That doesn't works so
 well if I'm debugging in the REPL however.

 What's the preferred method of determining whether I'm in REPL mode
 interaction vs running as a standalone app?

 Also, long as I'm asking and being lazy, does the -main function return
 value translate to a System/exit value if it's numeric?
 Or is System/exit the way to go?

 --
 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 a topic in the
 Google Groups Clojure group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/clojure/KZJQsmOeiHc/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: determining repl environment vs. uberjar environment?

2014-05-08 Thread Dave Tenny
James, All well and good, but you still need to know if you're running in a
REPL environment, and make sure you do NOT call System/exit for any
(typical) reason in that environment.  The idea is to test your (-main)
function from the REPL, without having to restart the lisp every time.


On Thu, May 8, 2014 at 10:28 AM, James Reeves ja...@booleanknot.com wrote:

 Sure, but those return codes correspond to some ending state of your
 application, which can occur via a normal function return, or through an
 exception. In both cases, your -main function can map state to exit code.

 For instance, let's assume that your application will return or except. In
 example below I'm using Slingshot to handle the exceptions:

 (defn -main [ args]
   (try+
 (apply app args) (System/exit 0)
 (catch [:exit :app/bad-data] _ (System/exit 1))
 (catch [:exit :app/connect-failed] _ (System/exit 2


 Alternatively, if the app function returns the status rather than excepts:

 (defn -main [ args]
   (System/exit
(case (apply app args)
  :app/ok 0
  :app/bad-data 1
  :app/connect-failed 2)))


 - James



 On 8 May 2014 14:23, Dave Tenny dave.te...@gmail.com wrote:

 When running as an uberjar, i.e. java -jar myapp.jar [args]
 the return code of the process to the shell is very important.
 System/exit is how that return code is sent.


 On Thu, May 8, 2014 at 9:20 AM, James Reeves ja...@booleanknot.comwrote:

 Having your application call System/exit directly is often indicative of
 some unnecessary coupling in your code.

 Under what circumstances does your application need to exit?

 - James


 On 22 April 2014 17:59, Dave Tenny dave.te...@gmail.com wrote:

 I have an app I'm building.  It calls System/exit.  That doesn't works
 so well if I'm debugging in the REPL however.

 What's the preferred method of determining whether I'm in REPL mode
 interaction vs running as a standalone app?

 Also, long as I'm asking and being lazy, does the -main function return
 value translate to a System/exit value if it's numeric?
 Or is System/exit the way to go?

 --
 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 a topic in the
 Google Groups Clojure group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/clojure/KZJQsmOeiHc/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.


  --
 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/KZJQsmOeiHc/unsubscribe.
 To unsubscribe from this group and all its topics, send

Re: determining repl environment vs. uberjar environment?

2014-05-08 Thread Dave Tenny
Gotcha. I suppose that makes sense as long as I undo some poor design and
make sure that the 'exit' wrapper I have never attempts to call System/exit
directly and always throws some suitable exception for interpretation at
the top level.  Right now my exit wrapper calls exit immediately if we're
not in a REPL environment.  Very few applications would care about the
distinction
(including mine) between unwinding a thread then calling exit, vs calling
exit without unwinding.

Independent of my exit situation, I can still think of situations in which
people may want to perform logic only when it was known to be a REPL
environment. Of course in the worst case you can always add a -D flag to
the JVM on startup indicating some 'interactive mode desires.  I'm not
sure how that goes with repls from cider in emacs and such.

Meanwhile I'm set with a workaround, and the points made on (app) vs.
(-main (app)) are good if you always throw and never call exit down the
stack.


On Thu, May 8, 2014 at 12:14 PM, Ray Miller r...@1729.org.uk wrote:

 On 8 May 2014 16:22, Dave Tenny dave.te...@gmail.com wrote:
  James, All well and good, but you still need to know if you're running
 in a
  REPL environment, and make sure you do NOT call System/exit for any
  (typical) reason in that environment.  The idea is to test your (-main)
  function from the REPL, without having to restart the lisp every time.

 I think James's point was that, if your -main function is a thin
 wrapper that calls (app ...), then it's (app ...) you'd test at the
 REPL (apologies if I'm putting words into your mouth, James).

 Ray.

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


defrecord, looking for more info on the __meta and __extmap fields and constructor arguments

2014-05-07 Thread Dave Tenny
The documentation for defrecord mentions additional arguments but doesn't 
give any examples of their use.

I take it that the __extmap field generated for the class is for map slots 
that aren't defined with the defrecord fields.

What is the __meta slot for and how is it typically used?


-- 
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: Converting sequence from sort into a list

2014-05-06 Thread Dave Tenny
In my case I was just trying to ensure a list type for a java API, though
perhaps the clojure reflection layer would have converted a non list seq to
a list to match the call, I don't know.



On Mon, May 5, 2014 at 9:01 PM, Sean Corfield s...@corfield.org wrote:

 My question would be: why do you specifically need a list? i.e., why isn't
 a sequence good enough?

 Sean

 On May 3, 2014, at 6:30 AM, Dave Tenny dave.te...@gmail.com wrote:
  After nosing around all I've come up with via clojure mechanisms is to
 use (apply list (sort ...)).
  It seems to work well enough for lists of arbitrary size (subject to
 usual memory/size limitations of large lists).
 
  I also considered some native java abuse such as
 java.util.Arrays.asList(Enumeration),
  though I didn't quickly find a way to convert the clojure.lang.ArraySeq
 from my sort() in testing to an Enumeration.
 
  Guess I'm set for now, I was just hoping to avoid consing a new list on
 my sort result in order to get a specific collection type.




-- 
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: Converting sequence from sort into a list

2014-05-03 Thread Dave Tenny
After nosing around all I've come up with via clojure mechanisms is to use
(apply list (sort ...)).
It seems to work well enough for lists of arbitrary size (subject to usual
memory/size limitations of large lists).

I also considered some native java abuse such as
java.util.Arrays.asList(Enumeration),
though I didn't quickly find a way to convert the clojure.lang.ArraySeq
from my sort() in testing to an Enumeration.

Guess I'm set for now, I was just hoping to avoid consing a new list on my
sort result in order to get a specific collection type.


On Fri, May 2, 2014 at 10:53 AM, Dave Tenny dave.te...@gmail.com wrote:

 I have a sequence from a call to 'sort'.
 I want a list.

 What is the best way to do this?

 (apply list (sort ...))?

 Will it have problems on large sequence inputs?


 I can't use (into () (sort ...))
 since that conjoins and ruins the sort order.


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


Clojure equivalent of special common lisp vars: still looking for that zen place...

2014-05-03 Thread Dave Tenny
I'm still struggling with how to write the most readable, simple clojure 
code
to deal with dynamically bindings.

What is the graceful clojure equivalent of common lisp special variables 
for the following scenario.

If I were writing common lisp I'd just do something like (pardon if my lisp 
is rusty here):

(defvar *x* 1)
... do stuff with *x* ...
(setq *x* 2)
... do stuff with *x* ...
(let ((*x* 3))  (do stuff with *x*...)
;; do stuff with *x* that's currently at 2


The way I'm tempted to do this in clojure is

(def ^{:dynamic true} *x* (atom 1))
... do stuff with @*x* ...
(reset! *x* 2)
... do stuff with @*x* ...
(binding [*x* (atom 3)] (do stuff with @*x*))


Is that the simplest way to map between the two language scenarios?
Or is there something simpler, perhaps using some var-* apis or what have 
you?


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
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: Clojure equivalent of special common lisp vars: still looking for that zen place...

2014-05-03 Thread Dave Tenny
On Sat, May 3, 2014 at 10:53 AM, Bob Hutchison hutch-li...@recursive.cawrote:

 You can also just use ‘def’ to redefine the global binding.



Thanks, though in this case it's a mixed use.  In some cases I want to
change the root of the global binding, in others I want to rebind to a new
value in some context without changing the value seen in other contexts.

-- 
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: Clojure equivalent of special common lisp vars: still looking for that zen place...

2014-05-03 Thread Dave Tenny
re: binding behavior, I've only been using clojure since 1.5.1, but in my
travels I get the impression that the binding form didn't always enforce
the variable to be declared dynamic, and so maybe didn't behave the way
you'd expect if the ^:dynamic was missing from the target of the binding
form.  Just guessing.


On Sat, May 3, 2014 at 11:08 AM, Lee Spector lspec...@hampshire.edu wrote:


 On May 3, 2014, at 9:45 AM, Dave Tenny dave.te...@gmail.com wrote:
 
  The way I'm tempted to do this in clojure is
 
  (def ^{:dynamic true} *x* (atom 1))
  ... do stuff with @*x* ...
  (reset! *x* 2)
  ... do stuff with @*x* ...
  (binding [*x* (atom 3)] (do stuff with @*x*))


 Having also come from Common Lisp and having once done things similar to
 your suggestion in Clojure, I got burned by the fact (I *think* it was a
 fact) that binding created thread-local bindings that reverted to global
 bindings inside of code executed in another thread, e.g. in a pmap buried
 somewhere within the code executed within the binding form. I found this to
 be unexpected and problematic.

 Trying some simple examples with your outline, however, I don't see this
 happening. And I wonder if it's because of changes in more recent versions
 of Clojure related to ^{:dynamic true}.

 Does anyone know if the reversion of binding-bound vars to global
 bindings when crossing thread boundaries has really been eliminated? Or am
 I just not seeing it because my examples have been too simple?

   -Lee

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


Converting sequence from sort into a list

2014-05-02 Thread Dave Tenny
I have a sequence from a call to 'sort'.
I want a list.

What is the best way to do this?

(apply list (sort ...))?

Will it have problems on large sequence inputs?


I can't use (into () (sort ...))
since that conjoins and ruins the sort order.


-- 
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: Converting sequence from sort into a list

2014-05-02 Thread Dave Tenny
Sort returns a seq,  but not necessarily something for which list? is true.


On Fri, May 2, 2014 at 11:01 AM, Plínio Balduino pbaldu...@gmail.comwrote:

 Hi Dave

 Sorry if I didn't get it, but doesn't sort already return a list?

 Could explain?

 Plínio



 On Fri, May 2, 2014 at 11:53 AM, Dave Tenny dave.te...@gmail.com wrote:

 I have a sequence from a call to 'sort'.
 I want a list.

 What is the best way to do this?

 (apply list (sort ...))?

 Will it have problems on large sequence inputs?


 I can't use (into () (sort ...))
 since that conjoins and ruins the sort order.


  --
 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 a topic in the
 Google Groups Clojure group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/clojure/sN37zftHSQ4/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.


determining repl environment vs. uberjar environment?

2014-04-22 Thread Dave Tenny
I have an app I'm building.  It calls System/exit.  That doesn't works so 
well if I'm debugging in the REPL however.

What's the preferred method of determining whether I'm in REPL mode 
interaction vs running as a standalone app?

Also, long as I'm asking and being lazy, does the -main function return 
value translate to a System/exit value if it's numeric?
Or is System/exit the way to go?

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


This is why clojure, for those who are always asking.

2014-04-20 Thread Dave Tenny
A lot of people who've used lisp dialect languages will get why clojure.

Even then, a lot of us lispers wanted more.  We wanted to leverage some of 
the vast amounts of code that have been written in recent years, in my 
case, for Java.
I like lisp a lot but had sworn it off for many years because the older 
lisp implementations I enjoyed weren't sufficiently blended with the newer 
tools I used to solve
problems.   So for a long time I've been looking at Scheme and Lisp 
implementations that interfaced with Java or had other 'critical support 
factors' that appealed to me.
Clojure seems to fit my needs for Lisp in 2014.

Here's an example of why clojure based on some recent Clojure scripting I 
was involved with.

Last week I decided I was tired of my hacks for calling 'ssh' via shell 
interfaces from Java (mostly because of pty hacks for sudo commands).
Granted, this is not a modern problem, but it was a very nice trip down 
lisp lane with a rewarding result in a few minutes at the lisp REPL prompt.

The ganymed2 java ssh library has been around a long time, so I decided to 
try that. I'd never used it before.

There was an example of using proxies with ganymed here:

https://code.google.com/p/ganymed-ssh-2/source/browse/trunk/examples/BasicWithHTTPProxy.java
(101 lines)

I adapted that in one REPL session to something like this:

http://pastebin.com/r0aTqFXp
(33 lines)

Throw a single dependency into your lein dependencies, experiment from the 
REPL,
and poof, ssh problems solved.

It isn't just the lines of code.
It isn't just that all the maven or ant and other build headaches went away.

It's just the best of both worlds, java and all that that implies, and lisp
and all that that implies, nicely brought together to solve whatever the 
problem-du-jour may be.

Actually, to solve my particular problem, I also needed to add one more 
line of code to the example I posted in the pastebin.

 (.requestDumbPTY session)

Now I can do my 'sudo' commands on Amazon EC2 instances with a pseudo tty 
with a lisp scripting environment.


So Lisp + Java + Good Interoperability == loads of fun and quick solutions.
That's Why Clojure for me.

Hope that helps any of you who (a) are wondering about  clojure and (b) 
need an ssh client from Clojure.

-- 
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: Amazonica performance: options?

2014-03-28 Thread Dave Tenny
Actually, let me withdraw the question for now.  If I call an unfiltered
(describe-images) on my account I'll get ~27,900 images.  It takes 70
seconds to retrieve them using the Java api
(from clojure).

If I then print (str image) for all those images to a file, that makes adds
another 153 seconds for a total of 223 seconds.  Presumably that's the
normal java toString() method invocation.

If I print out the Amazonica version of it, it takes 195 seconds,
presumably because we're sharing keyword references internally and so
abusing memory less overall (just a wild guess).

So if I do the native calls and cherry pick the information I want (like
the java EC2 CLI does), then I can get the time down significantly.
Otherwise Amazonica is probably doing a reasonable job given what I'm
asking of it.

And, in the wisdom gained department, never do unfiltered (describe-images)
requests if you can help it :-)




On Fri, Mar 28, 2014 at 12:52 PM, Michael Cohen mcohe...@gmail.com wrote:

 time ec2-describe-images -a  ec2-cli-images.txt

 real  1m26.401s
 user  0m6.551s
 sys 0m1.159s

 and writes a 7.5MB file to disk. Note the -a flag, to list all of the
 available public images.

 in a repl,

 (time (spit clj-awz-images.txt (describe-images)))

 Elapsed time: 90258.47 msecs

 and writes an 18MB file to disk containing all the available public
 images.

 Am I missing something?

 You can also pass a list of filters to the call to narrow the result.



 On Friday, March 28, 2014 7:59:48 AM UTC-7, Dave Tenny wrote:

 I'm trying to code some amazonica based solutions in a nontrivial AWS
 environment.
 I work with many AWS accounts and it isn't unusual to see a thousand
 instances running on one account, and similar excesses in other types of
 AWS resources.  So if you're going an ec2-describe-instances (or amazonica
 equivalent), it needs not to choke in this environment.

 I like the way amazonica does all the bean marshalling for me so I can
 express queries simply.  But the returned datasets need to be more
 pragmatic/performant.

 The problem for me is that Amazonica doesn't seem up to the task of
 dealing with queries that return large volumes of data.
 It has nothing to do with reflection I suspect, and more to do with
 unwieldy amounts of duplicate information in the result unmarshalling
 process.
 The clojure all the way down philosophy results of duplicated
 information and just printing the result to a file takes a long time.
 If I accidentally let the output go to an emacs cider repl buffer, then
 things get so wedged up to the point I  may as well kill -9 emacs.
 (Known cider repl issues here, it isn't all amazonica).

 For example:  here's how long it takes to run the java based ec2 cli to
 describe instances on an account:

 $ time ec2-describe-images /tmp/ec2-cli-images.out

 real0m11.484s
 user0m2.564s
 sys 0m0.129s


 And here's how long it takes from a 'lein repl' to run the same query on
 the same account:

 (time (with-output [/tmp/clj-awz-images.out] (println
 (ec2/describe-images
 Elapsed time: 194685.552683 msecs

 Now the amount of data being printed by the EC2 CLI is of course much
 different than the output from Amazonica,
 amazonica is returning everything in gory duplicate map detail, ec2 is
 not, as evidenced by the relative output sizes:

 -rw-rw-r--.  1 dave dave 17201290 Mar 28 10:35 clj-awz-images.out
 -rw-rw-r--.  1 dave dave99342 Mar 28 10:26 ec2-cli-images.out.11.5s

 Where the amazonica output starts with:
 {:images [{:hypervisor xen, :state available, :virtualization-type
 paravirtual, :root-device-type instance-store,
 ... and goes on like that with duplicate keywords all the way down.

 Anyway, my goal isn't to turn amazonica into ec2 cli.  But even the most
 trivial operations in amazonica (especially the most trivial, i.e. those
 lacking filters against large data sets), pretty  much whack me left and
 right
 with CPU wedged tools and (completely unacceptable) long waits for
 results.

 Any suggestions on how to use amazonica in a way where the output is ...
 different, and minimal/workable?

 Or am I left with going to another package or writing my own java sdk
 api's directly?

 I'm pretty sure the results need to be structures whose relationship to
 data values is implicit (and not explicit in map keys). I don't see any
 options with amazonica to change this however.

 Thanks for suggestions, forgive me if I've missed something obvious.  I'm
 just trying to see what's out there and at the same time move along quickly
 enough that I can get some usable tools for work (so I can lose all my
 python and bash scripts for various interfaces, I want clojure!).

 - Dave


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

traversing amazonica (or other nested data) results

2014-03-12 Thread Dave Tenny
If I do something like a describe-instances call in amazonica, I get a 
typical clojure-y set of data fairly deeply nested data structures
that I have yet to master with respect to traversing  using basic clojure 
operations.

Given a result that basically ends up looking like pages of interleaved 
maps and arrays, what should I be using to pick out
nested key/value information?

{:reservations [{:reservation-id r-3da23a55,
... pages of output ...
}]}]}]}
user=

'get-in' won't do it because of the arrays (or PersistentArrayMaps, as the 
case may be).
I was hoping to avoid zippers, but maybe that is the idiomatic way to do 
it, I don't know.

 What's the easy way to traverse these things?  This is a very common data 
pattern in using clojure to access everything from html content to AWS data.
 I just want to pluck out the :instance k/v information in the nested 
morass of data printed at my REPL but I haven't yet found the intuitive and 
idiomatic way to do 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
--- 
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.


isa? problem with collection type for multiple argument dispatch

2014-03-01 Thread Dave Tenny
(isa? [String String] [Object Object]) returns true. This is nice and 
useful.

However

(isa? '(String String) '(Object Object) returns false, this is not so nice.

(isa? '(String String) [Object Object]) also return false.


So the moral of the story is that for multiple argument dispatch to work, I 
need to use 'mapv' instead of 'map' in my dispatch function, which I have 
done.
But it was sort of a pain to find out the hard way (i.e. time spent 
debugging) that 'map' won't work in this regard.

I.e. this fails:

(defmulti foo (fn [  args ] (map class args)))
(defmethod foo [Object Object] [a b] (println a b))
(foo a b)
IllegalArgumentException No method in multimethod 'foo' for dispatch value: 
clojure.lang.LazySeq@86465241  clojure.lang.MultiFn.getFn (MultiFn.java:160)

but this works:

(defmulti bar (fn [  args ] (mapv class args)))
(defmethod bar [Object Object] [a b] (println a b))
(bar a b)
a b

Bug or feature?

Clojure 1.5.1


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


Closing open files when with-open was not used, possibly useful gist.

2014-02-19 Thread Dave Tenny
I'm posting this on the off chance it's useful to those of you writing REPL 
shell tools or I/O abstractions (e.g. java's NIO.2 DirectoryStream 
wrappers) that might benefit from a close-when-GC'd backstop.

For example, clj-nio2 has a nice little lazy directory sequence function:

(defn- lazy-dir-stream-seq [^DirectoryStream dir-stream]
  (let [it (.iterator dir-stream)
iter (fn thisfn []
   (if (.hasNext it)
 (cons (.next it)
   (lazy-seq (thisfn)))
 (.close dir-stream)))]
(lazy-seq (iter


However that will result in the stream being closed only if we reach the 
end of the directory stream.  
So I wrote the code in the referenced gist to address that problem, though 
I haven't hooked it up into my own or one of the existing NIO wrappers yet.

So FWIW.  And suggestions welcome.
I hate the bit of reflection I used but was having difficulty doing it any 
other way with PhantomReference instances.

https://gist.github.com/dtenny/9104215

Basically any open Closeable reference can be called in an (ensure-close 
x) fashion to make sure it gets closed eventually,
as my exhaustive (NOT!) test case at the end shows (file content gets 
flushed).

It's very side effect-y, I feel so dirty...  Bad java followed by worse 
clojure.   Tips welcome.  It was just a clojure learning thing for me.

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


cdoc, lein, profiles.clj, strange behavior

2014-02-19 Thread Dave Tenny
I'm trying to figure out some strange behavior ensuring that 'cdoc' is 
always available in my user namespace.

I have in my ~/.lein/profiles.clj this block:

{:user {:dependencies [[jdt 0.1.0-SNAPSHOT] ;jdt.*
   [org.clojure/tools.trace 0.7.6]
   [org.thnetos/cd-client 0.3.6] ;cd-client.core
   [org.clojure/tools.logging 0.2.6]
   ;;[spyscope 0.1.4]
   ]
:injections [(use '[jdt core cl shell java])
 (use 'clojure.tools.trace)
 (use '[clojure.tools.logging :exclude [trace]])
 (require 'clojure.inspector)
 (require 'cd-client.core) ; cdoc, sometimes already 
'use'd
 (if-not (defined? 'cdoc)
   (use 'cd-client.core))
 ;;(require 'spyscope.core)
 (println ~/.lein/profiles.clj)
 (println   using jdt.*, 
clojure.tools.{trace,logging}, cd-client.core)
 ]}}

If I run 'cider' from emacs, I get no problems.

If I do 'lein repl' however I get this:

$ lein repl
~/.lein/profiles.clj
  using jdt.*, clojure.tools.{trace,logging}, cd-client.core
nREPL server started on port 56072 on host 127.0.0.1
REPL-y 0.3.0
Clojure 1.5.1
IllegalStateException cdoc already refers to: #'cd-client.core/cdoc in 
namespace: user  clojure.lang.Namespace.warnOrFailOnReplace 
(Namespace.java:88)
#Namespace user
Error loading namespace; falling back to user
nil
user= 

for Leiningen 2.3.4 on Java 1.7.0_45 Java HotSpot(TM) 64-Bit Server VM

It appears that something is executed *after* the injections that is trying 
to add cdoc to the user namespace.  

This thing has been on-again off again depending on where I'm running 
clojure.  If I unconditionally attempt to use cdoc, it fails in some 
situations.  If I conditionally use it, it fails in some situations.

Ideas?

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


data-readers, spyscope

2014-02-01 Thread Dave Tenny
Java 1.7.0.45
Lein 2.3.4
Clojure 1.5.1

I'm trying to use https://github.com/dgrnbrg/spyscope and have put the 
documented bits in my ~/.lein/profiles.clj
but cannot get it to work.

{:user {:dependencies [...  [spyscope 0.1.4] ...]
:injections [(require 'spyscope.core)
 ]}}

But when I do 'lein repl'
*data-readers* doesn't contain the required mappings to the spy definitions.

If at the REPL I try something like

(set! *data-readers* '{spy/p spyscope.core/print-log})

and then

#spy/p abc

I get 

RuntimeException No dispatch macro for: s 
 clojure.lang.Util.runtimeException (Util.java:219)


What's the proper way to make spyscope work for all lein user profiles?



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


clojuredocs macro

2014-01-28 Thread Dave Tenny
Does anybody happen to know where 'clojuredocs' is defined?  I grepped the 
clojure and leiningen git trees but the word didn't show up.

I noticed it mentioned in some leiningen tutorials and it's present in my 
REPL, in the user namespace.

clojuredocs
  is a clojure.lang.Symbol

  in namespace user:
{:interns #'user/clojuredocs, :maps-to #'user/clojuredocs, 
:interns-publicly #'user/clojuredocs}

  #'user/clojuredocs
is a clojure.lang.Var

with metadata:
  :arglists ([v] [ns-str var-str])
  :ns #Namespace user
  :name clojuredocs
  :column 6300
  :macro true
  :line 1
  :file NO_SOURCE_PATH
  :doc
  Lazily checks if the clojuredocs client is available, and uses it to
retrieve examples if it is.

with value #exports$lazy_clojuredocs 
reply.exports$lazy_clojuredocs@5ce9f026
of type reply.exports$lazy_clojuredocs

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


Re: clojuredocs macro

2014-01-28 Thread Dave Tenny
Thank you.

Is there some easy way I've missed to figure this sort of thing out in the
future?




On Tue, Jan 28, 2014 at 10:34 AM, Andy Fingerhut
andy.finger...@gmail.comwrote:

 It is defined in the project 'reply', used by Leiningen for 'lein repl'
 tasks:

 https://github.com/trptcolin/reply

 That in turn depends upon a cd-client library for sending requests to the
 clojuredocs.org web site and doing some parsing on the responses received:

 https://github.com/dakrone/clojuredocs-client

 Andy


 On Tue, Jan 28, 2014 at 7:04 AM, Dave Tenny dave.te...@gmail.com wrote:

 Does anybody happen to know where 'clojuredocs' is defined?  I grepped
 the clojure and leiningen git trees but the word didn't show up.

 I noticed it mentioned in some leiningen tutorials and it's present in my
 REPL, in the user namespace.

 clojuredocs
   is a clojure.lang.Symbol

   in namespace user:
 {:interns #'user/clojuredocs, :maps-to #'user/clojuredocs,
 :interns-publicly #'user/clojuredocs}

   #'user/clojuredocs
 is a clojure.lang.Var

 with metadata:
   :arglists ([v] [ns-str var-str])
   :ns #Namespace user
   :name clojuredocs
   :column 6300
   :macro true
   :line 1
   :file NO_SOURCE_PATH
   :doc
   Lazily checks if the clojuredocs client is available, and uses it to
 retrieve examples if it is.

 with value #exports$lazy_clojuredocs
 reply.exports$lazy_clojuredocs@5ce9f026
 of type reply.exports$lazy_clojuredocs

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

 For more options, visit https://groups.google.com/groups/opt_out.


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


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


Redefining the notion of S-EXP, and pattern matching S-EXPs in clojure

2014-01-19 Thread Dave Tenny
As I try to reconcile my ancient past in writing common lisp code with a 
clojure learning exercise, 
I wonder whether clojure philosophy redefines the notion of an s-expression
or whether it just  adds vectors and maps to s-expressions in without 
trying to define what an s-expression is.

The question came up as I was looking for a certain capability in clojure 
libraries.

Back in the day when lisps had only parenthesized collection types, there 
were lisp libraries
(whose names I've long since forgotten) that would allow pattern matching 
of s-expressions,
so that you could describe a pattern, match it to some tree, pick up 
matches and continue to match some more.

Sort of like java.util.Matcher.find().

However with every clojure program (and program output) being a huge set of 
lists, vectors, and maps
I was looking for an s-exp matcher that would allow pattern expressions of 
and matching against paths of combinations of these data structures.

Sort of like enlive/select can traverse a nasty list/vector/map output of 
enlive/html-resource with predicates that will match a sequence of nodes in 
the web page.
(Only I don't think enlive/select returns matcher state that allows 
continuation from where you left off, maybe it does, and of course it's 
html oriented).

Looking at the clojure.walk and clojure.zip stuff, I don't see anything 
other than low level tools for certain kinds of traversals.

What libraries are there for higher level reach in and grab patterns of 
data abstractions that will work against a tree of lists/vectors/maps (and 
preferably any other walkable data structure in clojure)?

Looking for suggestions, and whatever philosophy there is about 
s-expressions in clojure like reader environments.

If I wanted lists, vectors, and maps with no zen, I'd be using python ;-)

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/groups/opt_out.


HttpKit, Enlive (html retrieval and parsing)

2014-01-11 Thread Dave Tenny
I'm just playing around with tool kits to retrieve and parse html from web 
pages and files that I already have on disk (such as JDK API documentation).

Based on too little time, it looks like [http-kit 2.1.16] will retrieve 
but not parse html, and [enlive 1.1.5] will retrieve AND parse html.

Or is there a whole built-in parse capability I'm missing in http-kiit?

Also, http-kit doesn't seem to want to retrieve content from a file:/// 
url, whereas enlive is happy with both local and remote content.

I'm just messing around, I wanted to have some REPL javadoc logic that 
didn't fire up a browser or use the swing app (whose fonts are unreadable 
for me, and half a day spent trying to change it was not fruitful).

Any tips or suggestions?  Just don't want to make sure I'm missing obvious 
things.

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/groups/opt_out.


Re: HttpKit, Enlive (html retrieval and parsing)

2014-01-11 Thread Dave Tenny
I was using net.cgrand.enlive-html/html-resource and org.httpkit.client/get 
for the page retrievals.

On Saturday, January 11, 2014 6:24:48 PM UTC-5, Dave Tenny wrote:

 I'm just playing around with tool kits to retrieve and parse html from web 
 pages and files that I already have on disk (such as JDK API documentation).

 Based on too little time, it looks like [http-kit 2.1.16] will retrieve 
 but not parse html, and [enlive 1.1.5] will retrieve AND parse html.

 Or is there a whole built-in parse capability I'm missing in http-kiit?

 Also, http-kit doesn't seem to want to retrieve content from a file:/// 
 url, whereas enlive is happy with both local and remote content.

 I'm just messing around, I wanted to have some REPL javadoc logic that 
 didn't fire up a browser or use the swing app (whose fonts are unreadable 
 for me, and half a day spent trying to change it was not fruitful).

 Any tips or suggestions?  Just don't want to make sure I'm missing obvious 
 things.

 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/groups/opt_out.


Re: Clojure deployment questions w.r.t. jars, clojure source files, compiled class files

2014-01-08 Thread Dave Tenny
Excellent answers and I usually find a use for extra wrenches.

I'm still confused about when anybody actually calls the (compile)
function, any more tips here?  Or is it being done for me by leiningen?


On Wed, Jan 8, 2014 at 1:54 AM, Softaddicts lprefonta...@softaddicts.cawrote:

 To complement my previous post and in relation to this one,
 we use (if-not *compile-file* ...) to wrap expressions that cannot be
 AOT compiied (like loading configuration or connecting to external
 resources which you do not want  to do at compile time but at run time
 only:)

 This confused a lot of people in the past trying to use AOT.
 For many the compilation phase and code execution are perceived
 as a single step. When working in the REPL you do not need to be aware of
 this. With AOT it's important to be aware of the difference when writing
 code
 in dev.

 Luc P.


  On Tue, Jan 7, 2014 at 4:26 PM, Dave Tenny dave.te...@gmail.com wrote:
   1) When and under what circumstances projects are compiled in  source
 versus
   .class form?
 
  Most Clojure projects ship in source form (and are therefore compiled
  to bytecode on demand as they are loaded).
 
   2) Why there is no project.clj in the org.clojure jar file?
 
  It's built with Maven. As are most of the Clojure contrib libraries
  too, although some are now starting to sport project.clj files to make
  local development easier. In the last round of development, I added
  Leiningen support to clojure.java.jdbc to make it easier to jack in
  with Emacs and test the code. It still uses Maven for primary testing
  (on build.clojure.org) and packaging - and Clojure plus its contrib
  libraries are hosted on Maven Central (where they are retrieved
  primarily by Leiningen into other Clojure projects).
 
   3) When the clojure 'compile' function comes into play in your typical
   clojure project deployments? (vs. :aot targets or other leiningen
 deployment
   techniques).
 
  At World Singles, we AOT compile very little of our code. We only AOT
  namespaces that generate Java-compatible classes for situations where
  we must be natively callable from Java (e.g., we have a log4j appender
  written in Clojure). Within that AOT-compiled code, we require
  namespaces and resolve symbols dynamically (at runtime) to bind the
  Java-called code to the rest of our code base.
 
  Part of the reason is for the flexibility that source deployments
  provide: the ability to REPL into a live, running process and reload
  code from updated source files without needing to stop the world,
  for example.
 
  If you're relatively new to Clojure, I'd recommend completely ignoring
  the whole compilation thing unless you specifically need to generate
  natively callable code for Java to Clojure interop.
 
  In case anyone is interested, our pattern for bridging from the
  AOT-compiled namespace to the rest of the code base tends to look like
  this:
 
  (def the-symbol
(delay
  (do
(require 'the.namespace)
(resolve (symbol the.namespace/the-symbol)
 
  and then:
 
... (@the-symbol arg1 arg2) ...
 
  Our AOT-compiled layer is deliberately minimal and serves only to
  provide the Java-callable API so the rest of our code can be developed
  and tested in our normal interactive, incremental way.
  --
  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
  ---
  You received this message because you are subscribed to the Google
 Groups Clojure group.
  To unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+unsubscr...@googlegroups.com.
  For more options, visit https://groups.google.com/groups/opt_out.
 
 --
 Softaddictslprefonta...@softaddicts.ca sent by ibisMail from my ipad!

 --
 --
 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/sU0r00i7Ls0/unsubscribe.
 To unsubscribe from

Re: Namespaces in waiting

2014-01-07 Thread Dave Tenny
Thanks for the pointer.  This appears to work solely off the clojure source
and may be very useful.  It raises all kinds of non-namespace-related
questions for me though that I'll ask in another topic.


On Tue, Jan 7, 2014 at 9:02 AM, Alex Ott alex...@gmail.com wrote:

 You can use find-namespaces from
 http://clojure.github.io/tools.namespace/#clojure.tools.namespace.find to
 + clojure.java.classpath to get a list of all namespaces in current
 classpath...


 On Mon, Jan 6, 2014 at 7:45 PM, Stephen C. Gilardi scgila...@gmail.comwrote:


 On Jan 1, 2014, at 3:26 PM, Dave Tenny dave.te...@gmail.com wrote:

  When I use 'lein repl' in some project context and get to the REPL
 prompt, there's an available but as yet not ... present ... namespace, i.e.
 (all-ns) won't list the namespace(s) created in the lein project directory
 tree.
 
  Is there some API I can use to see a list these available but not
 active namespaces?

 I’m not aware of one.

  I'm guessing that looking at what's on the class path doesn't
 necessarily tell me what namespaces might be USE-able via (use 'x).

 Walking the classpath including the contents of jar files would be a way
 to construct such a list of USE-able (or REQUIRE-able) namespaces. It would
 involve  traversing the directory structure under each entry in the
 classpath and reading at least the first ns form in each candidate file (or
 jar entry).

 —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
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.

 For more options, visit https://groups.google.com/groups/opt_out.




 --
 With best wishes,Alex Ott
 http://alexott.net/
 Twitter: alexott_en (English), alexott (Russian)
 Skype: alex.ott

 --
 --
 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/mu25hM3Cw4w/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/groups/opt_out.


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


Clojure deployment questions w.r.t. jars, clojure source files, compiled class files

2014-01-07 Thread Dave Tenny
So if I sample some clojure jars in my local maven .m2 directory, most of 
the jar files have only clojure code, and a project.clj.
If I look at the org.clojure project there, it has many java class files, 
what appear to be corresponding clojure source files, and *no* project.clj.

With only a little experiencing on some single AOT compiled modules, I 
wondered 

1) When and under what circumstances projects are compiled in  source 
versus .class form?
2) Why there is no project.clj in the org.clojure jar file?
3) When the clojure 'compile' function comes into play in your typical 
clojure project deployments? (vs. :aot targets or other leiningen 
deployment techniques).

Any pointers or enlightenment on the above questions appreciated.
I read the clojure compilation page, but I haven't quite put together 
what that's telling me about *how* to comjpile a file and gen-class a class,
versus why I see all these clojure .m2 jar files with no classes whatsoever.

Thanks,

Dave

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


Re: Namespaces in waiting

2014-01-07 Thread Dave Tenny
I just stumbled across this, which looks very much like it may be what I 
wanted:  clojure.core/loaded-libs

http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/loaded-libs

E.g.

$ lein repl
user= (loaded-libs)
bultitude.core
cemerick.pomegranate
cemerick.pomegranate.aether
classlojure.core
clj-stacktrace.core
clj-stacktrace.repl
clj-stacktrace.utils
clojure.core
clojure.core.protocols
clojure.instant
...
clojure.zip
complete.core
dynapath.defaults
dynapath.dynamic-classpath
dynapath.util
flatland.useful.fn
flatland.useful.seq
flatland.useful.utils
jdt.cl
jdt.core
jdt.java
jdt.shell
leiningen.core.classpath
leiningen.core.eval
leiningen.core.main
leiningen.core.project
leiningen.core.ssl
leiningen.core.user
leiningen.core.utils
leiningen.repl
leiningen.trampoline
me.raynes.conch
me.raynes.conch.low-level
net.cgrand.parsley
net.cgrand.parsley.fold
net.cgrand.parsley.grammar
net.cgrand.parsley.lrplus
net.cgrand.parsley.stack
net.cgrand.parsley.tree
...

and so on

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


Namespaces in waiting

2014-01-01 Thread Dave Tenny
When I use 'lein repl' in some project context and get to the REPL prompt, 
there's an available but as yet not ... present ... namespace, i.e. 
(all-ns) won't list the namespace(s) created in the lein project directory 
tree.

Is there some API I can use to see a list these available but not active 
namespaces?

I'm guessing that looking at what's on the class path doesn't necessarily 
tell me what namespaces might be USE-able via (use 'x).




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


computed docstrings

2013-12-20 Thread Dave Tenny
I'm guessing the answer to this is that I'd have to write my own 'defn' 
equivalent that would parse a form rather than requiring a string, but 
here's hoping.

One of the things I did in Common Lisp was to occasionally compute the 
docstring for a function with a little function that formatted them the way 
I wanted them.

e.g.

(defun foo (bar)
  #.(docstring some text to be made into a docstring for foo
   some more text to be formatted as part of the docstring of 
foo)
   ...


There's no #. equivalent that I know of in clojure, so that approach is out.

I also can't do a 

(def docstring abc)
(defn foo docstring [] 'bar)

or an error crops up.   

Is there any alternative I'm missing short of writing my own macro to allow 
non-string forms for docstrings?

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


Re: computed docstrings

2013-12-20 Thread Dave Tenny
Good, thanks

On Friday, December 20, 2013 8:08:39 PM UTC-5, guns wrote:

 On Fri 20 Dec 2013 at 05:04:13PM -0800, Dave Tenny wrote: 

  Is there any alternative I'm missing short of writing my own macro to 
  allow non-string forms for docstrings? 

 Use the ^ reader macro to set the :doc entry: 

 (def my-docstring foo bar) 

 (defn ^{:doc my-docstring} foo []) 

 guns 


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


Why are vectors and sets inconsistent with maps, keywords, and symbols when used as operators?

2013-12-05 Thread Dave Tenny
Maps, keywords, and symbols when used as operators allow optional second 
arguments for 'default-not-found' values is if to 'get'.

E.g.

({:a 1} :b 'b) = b

However sets don't support this behavior (though they do with 'get') and 
vectors don't allow the optional default-not-found in their pseudo 'nth' 
semantics.

Seems like an inconsistency, any plans to fix it?  Or is there some reason 
why they were deliberately excluded from supporting similar behavior to 
maps, keywords, and symbols?


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


Re: Suggestions for state modification improvements in this bit of code?

2013-12-01 Thread Dave Tenny
Wow, lots of good tips, thanks.I'm still digesting some of the finer
bits.

Observations:

- The refheap pastebin link was useful for future code posts.
- The :pre/:post conditions pointer was good, I vaguely new of them, but
hadn't used them.
- The as- form was new (and useful) to me.  In general I'm still
struggling to fit - and friends into my style.
- I found the #4 variant easiest to read, didn't even occur to me to do
such a thing, coming from common lisp I'm still trying to get used to [],
{}, #{} options.  Unfortunately #4 also added the most undesired entries to
the map (see question below).

Questions:

- The only problem with the variants is that they introduce nil valued
entries in the map where my original function only added map entries if the
namespace relationships existed, I'd like to preserve that.  Presumably I
could add an assoc-if or similar type thing to avoid adding nil valued
entries. Maybe clojure already has such a construct?  My preference is to
avoid adding them in the first place, rather than filtering them from the
map in a post-construction operation.

- 'pr-str' almost seems redundant with 'str', but I suppose it observes
pretty printing guidelines where str would not?  Any significant nuances
here, or are these two functions largely redundant?

- Your many suggestions certainly seem preferable to my state based
approach, but for my edification, what is the optimal way to implement a
state based approach in this example?  I wasn't sure about my use of vars
versus, say, atoms, or other clojure constructs for mutable state.  Just
looking for suggestions here.

Thanks again, really useful stuff!

On Sat, Nov 30, 2013 at 7:41 PM, Sean Grove s...@zenboxapp.com wrote:

 Dave, I may not have totally understood the original function, but here
 are a few possible implementations, each moving towards what I would think
 of as being simpler: https://www.refheap.com/21379

 It could of course be made more efficient and slightly cleaner, but maybe
 it's a start.

 On Sat, Nov 30, 2013 at 3:49 PM, Dave Tenny dave.te...@gmail.com wrote:

 What, not conj!urers?


 On Sat, Nov 30, 2013 at 6:33 PM, Thomas th.vanderv...@gmail.com wrote:

 On Saturday, November 30, 2013 11:17:01 PM UTC, Dave Tenny wrote:

 I'm still learning clojure and wrote this decidedly unfunctional bit of
 code as part of a common lisp style DESCRIBE function.

 I was wondering what experienced clojure-ers  (what's the proper
 reference?)


 Clojurians ;)

 Thomas

 --
 --
 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/gbg1ABsbT-I/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/groups/opt_out.


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

 For more options, visit https://groups.google.com/groups/opt_out.


  --
 --
 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/gbg1ABsbT-I/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/groups/opt_out.


-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com

exporting imported symbols

2013-12-01 Thread Dave Tenny
(ns mine 
   (:use foo)) ; has public symbol bar

What is the proper use/require/refer entry to export foo's bar as mine's 
bar without defining a new public bar in mine?


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


Re: exporting imported symbols

2013-12-01 Thread Dave Tenny
OK.  If it were supported, I'd still be able to tell where the symbol came
from, it would just feature an indirection, right?


On Sun, Dec 1, 2013 at 10:58 AM, Stuart Sierra
the.stuart.sie...@gmail.comwrote:

 Not supported. This is a feature. As long as you use `:require :as` or
 `:require :refer`, you can always tell where a symbol comes from.
 -S



 On Sunday, December 1, 2013 10:10:46 AM UTC-5, Dave Tenny wrote:

 (ns mine
(:use foo)) ; has public symbol bar

 What is the proper use/require/refer entry to export foo's bar as mine's
 bar without defining a new public bar in mine?


  --
 --
 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/kuYxmbn7jls/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/groups/opt_out.


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


Re: .cljrc

2013-11-30 Thread Dave Tenny
Thanks, that was one of the sample files I mentioned looking at, but it
still didn't have the :injections stuff in it, and I was just wondering
what else I was missing.  I have yet to find any real documentation on
project and profiles [.clj] content other than examples, I was looking for
the reference guide on these entities, but I suspect that's an exercise
left for readers of the code at this time.


On Thu, Nov 28, 2013 at 1:39 PM, Justin Smith noisesm...@gmail.com wrote:

 the leinengen project has an example project.clj
 https://github.com/technomancy/leiningen/blob/master/sample.project.clj


 On Wednesday, November 27, 2013 4:53:02 PM UTC-8, Dave Tenny wrote:

 Thanks, I seem to have accomplished what I need for now.  It was a bit
 frustrating to figure out exactly what I could do in profiles.clj.  For
 example, I can't find any documentation on :injections, which was key to
 evaluating some code once I'd specified libraries as dependencies.

 Where are the full options of projects.clj and profiles.clj documented?
  I can't find it anywhere in the git tree except by way of example in the
 sample project.clj, and the tutorial.


 On Mon, Nov 25, 2013 at 5:49 PM, dgrnbrg dsg123...@gmail.com wrote:

 Another great feature of Leiningen is the :injections key in
 project.clj. This lets you run arbitrary code on the Leiningen-managed JVM
 startup. I recommend this when using Spyscope, which is a debugging tool
 that only needs to be required before you can use it:
 https://github.com/dgrnbrg/spyscope#usage

 Using :injections is a powerful to customize the default referred vars,
 as well.

 On Monday, November 25, 2013 10:01:12 AM UTC-5, Moritz Ulrich wrote:

 Leiningen profiles in ~/.lein/profiles.clj will be merged into the
 current project.clj by leiningen. Also dumented in
 https://github.com/technomancy/leiningen/blob/stable/doc/PROFILES.mdhttps://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Ftechnomancy%2Fleiningen%2Fblob%2Fstable%2Fdoc%2FPROFILES.mdsa=Dsntz=1usg=AFQjCNGPecCbKEDAS5MWZP4qvsqXetVkTw

 On Mon, Nov 25, 2013 at 3:34 PM, Dave Tenny dave@gmail.com
 wrote:
  With all my attention on trying to learn things about clojure, I've
 either
  missed or forgotten how do to a simple thing.
 
  As I learn clojure I'm writing a few definitions that represent tools
 I like
  to use in development.
 
  What is the simplest way to have those tools present in arbitrary
 clojure
  REPLs started with lein repl, emacs cider-jack-in, etc., without
 putting
  them in project.clj files for every lein project I'm working on ?
 
  I just want to load some things into the user (or other default ns if
 my
  hypothetical .cljrc changes it) namespace and have it happen all the
 time,
  except when I'm doing release builds and such of a particular
 project.
 
  Suggestions?
 
 
  --
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clo...@googlegroups.com
  Note that posts from new members are moderated - please be patient
 with your
  first post.
  To unsubscribe from this group, send email to
  clojure+u...@googlegroups.com
  For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en
  ---
  You received this message because you are subscribed to the Google
 Groups
  Clojure group.
  To unsubscribe from this group and stop receiving emails from it,
 send an
  email to clojure+u...@googlegroups.com.
  For more options, visit https://groups.google.com/groups/opt_out.

  --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to 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 a topic in the
 Google Groups Clojure group.
 To unsubscribe from this topic, visit https://groups.google.com/d/
 topic/clojure/7NWXyQsG3WU/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 clojure+u...@googlegroups.com.

 For more options, visit https://groups.google.com/groups/opt_out.


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

Suggestions for state modification improvements in this bit of code?

2013-11-30 Thread Dave Tenny
I'm still learning clojure and wrote this decidedly unfunctional bit of 
code as part of a common lisp style DESCRIBE function.

I was wondering what experienced clojure-ers  (what's the proper 
reference?) might suggest to make this function less ugly.

I realize making a purely functional version of this is probably the 
clojure thing to do, but it wasn't worth my time,
nor did I think it would make the code shorter (correct me if I'm wrong).

Anyway, with regard to mutable state is there a more concise and/or 
preferred way to do this?

The function in question is just querying the many maps of a namespace to 
yield another map with some interpretations of the namespace with respect 
to a given symbol.  I am struggling with some of the capabilities of 
namespaces and so this was just a bit of learning code for me, though I 
have to say my resulting DESCRIBE function has been really useful to me. 
 At some point when it's not a total embarrassment perhaps I'll post it.

Thanks for your suggestions:

(defn ns-symbol-relationship
  Return a map of entries that describe the relationship of a symbol to a 
given namespace.
  [ns symbol]
  (if (not (symbol? symbol))
(throw (Exception. (str ns-symbol-relationship expected symbol, got  
symbol
  ;; ns-name ns-aliases ns-imports ns-interns ns-map ns-publics ns-refers
  (with-local-vars [result (transient {})]
(when (= (ns-name ns) symbol);ns-name gives a symbol
  (var-set result (assoc! (var-get result) :names-ns ns))) ;symbol 
names namespace
; ns-aliases gives a map, but the k/v types/semantics are presently 
unknown
(doseq [[k v] (seq (ns-aliases ns))]
  (when (= k symbol)
(var-set result (assoc! (var-get result) :alias-for v)))
  (when (= v symbol)
(var-set result (assoc! (var-get result) :aliased-by k
;; ns-imports keyed by symbol, valued by class
(if-let [v (get (ns-imports ns) symbol)]
  (var-set result (assoc! (var-get result) :imports v)))   ;symbol 
names imported class
;; ns-interns gives a map, keys are symbols in the namespace, values 
are vars( and special forms?)
;; that they map to. 
(if-let [v (get (ns-interns ns) symbol)]
  (var-set result (assoc! (var-get result) :interns v)))
;; ns-maps gives a map, value types/semantics are unknown
(if-let [v (get (ns-map ns) symbol)]
  (var-set result (assoc! (var-get result) :maps-to v)))
;; ns-publics gives a map of public intern mappings, presumably a 
subset of ns-interns
(if-let [v (get (ns-publics ns) symbol)]
  (var-set result (assoc! (var-get result) :interns-publicly v)))
;; ns-refers gives a map of refer-mappings, value semantics unknown
(if-let [v (get (ns-refers ns) symbol)]
  (var-set result (assoc! (var-get result) :refers-to v)))
(persistent! (var-get result

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


Re: Suggestions for state modification improvements in this bit of code?

2013-11-30 Thread Dave Tenny
What, not conj!urers?


On Sat, Nov 30, 2013 at 6:33 PM, Thomas th.vanderv...@gmail.com wrote:

 On Saturday, November 30, 2013 11:17:01 PM UTC, Dave Tenny wrote:

 I'm still learning clojure and wrote this decidedly unfunctional bit of
 code as part of a common lisp style DESCRIBE function.

 I was wondering what experienced clojure-ers  (what's the proper
 reference?)


 Clojurians ;)

 Thomas

 --
 --
 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/gbg1ABsbT-I/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/groups/opt_out.


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


Re: .cljrc

2013-11-27 Thread Dave Tenny
Thanks, I seem to have accomplished what I need for now.  It was a bit
frustrating to figure out exactly what I could do in profiles.clj.  For
example, I can't find any documentation on :injections, which was key to
evaluating some code once I'd specified libraries as dependencies.

Where are the full options of projects.clj and profiles.clj documented?  I
can't find it anywhere in the git tree except by way of example in the
sample project.clj, and the tutorial.


On Mon, Nov 25, 2013 at 5:49 PM, dgrnbrg dsg123456...@gmail.com wrote:

 Another great feature of Leiningen is the :injections key in project.clj.
 This lets you run arbitrary code on the Leiningen-managed JVM startup. I
 recommend this when using Spyscope, which is a debugging tool that only
 needs to be required before you can use it:
 https://github.com/dgrnbrg/spyscope#usage

 Using :injections is a powerful to customize the default referred vars, as
 well.

 On Monday, November 25, 2013 10:01:12 AM UTC-5, Moritz Ulrich wrote:

 Leiningen profiles in ~/.lein/profiles.clj will be merged into the
 current project.clj by leiningen. Also dumented in
 https://github.com/technomancy/leiningen/blob/stable/doc/PROFILES.mdhttps://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Ftechnomancy%2Fleiningen%2Fblob%2Fstable%2Fdoc%2FPROFILES.mdsa=Dsntz=1usg=AFQjCNGPecCbKEDAS5MWZP4qvsqXetVkTw

 On Mon, Nov 25, 2013 at 3:34 PM, Dave Tenny dave@gmail.com wrote:
  With all my attention on trying to learn things about clojure, I've
 either
  missed or forgotten how do to a simple thing.
 
  As I learn clojure I'm writing a few definitions that represent tools I
 like
  to use in development.
 
  What is the simplest way to have those tools present in arbitrary
 clojure
  REPLs started with lein repl, emacs cider-jack-in, etc., without
 putting
  them in project.clj files for every lein project I'm working on ?
 
  I just want to load some things into the user (or other default ns if
 my
  hypothetical .cljrc changes it) namespace and have it happen all the
 time,
  except when I'm doing release builds and such of a particular project.
 
  Suggestions?
 
 
  --
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clo...@googlegroups.com
  Note that posts from new members are moderated - please be patient with
 your
  first post.
  To unsubscribe from this group, send email to
  clojure+u...@googlegroups.com
  For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en
  ---
  You received this message because you are subscribed to the Google
 Groups
  Clojure group.
  To unsubscribe from this group and stop receiving emails from it, send
 an
  email to clojure+u...@googlegroups.com.
  For more options, visit https://groups.google.com/groups/opt_out.

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


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


.cljrc

2013-11-25 Thread Dave Tenny
With all my attention on trying to learn things about clojure, I've either 
missed or forgotten how do to a simple thing.

As I learn clojure I'm writing a few definitions that represent tools I 
like to use in development.

What is the simplest way to have those tools present in arbitrary clojure 
REPLs started with lein repl, emacs cider-jack-in, etc., without putting 
them in project.clj files for every lein project I'm working on ?

I just want to load some things into the user (or other default ns if my 
hypothetical .cljrc changes it) namespace and have it happen all the time, 
except when I'm doing release builds and such of a particular project.

Suggestions?


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


What's new and exciting w.r.t. Clojure use in data analytics, and cloud apps that scale out?

2013-11-20 Thread Dave Tenny
Just looking for interesting tidbits on recent spearheads with, or wins 
for, Clojure in the cloud with the buzzwords du jour.

Part of an interest to take the pulse of Clojure in the domains for which 
my employer presently uses other tools.

I like Java just fine (for what it is), and I have a lot of hope for 
Clojure to rectify some of the things that Java isn't.
Some of these modern languages like Coffeescript, Groovy, or Python 
almost make the limitations of Fortran syntax look good.  

(Yes, my indentation of one language statement was off by 2 spaces today 
and my program didn't work, I confess irritation as a source of motivation 
to learn new things).

What's new and exciting!?  My personal interest is directed at large AWS 
cloud apps where clojure might be bringing the logic to data or the data to 
logic in an interesting fashion,
and the ever present need for portals on the results of those processes.

Thanks for any pointers!

Dave

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


Re: New Functional Programming Job Opportunities

2013-11-19 Thread Dave Tenny
Fun reading!

On Monday, November 18, 2013 2:00:02 AM UTC-5, Sean Murphy wrote:

 Here are some functional programming job opportunities that were posted 
 recently: 

 Clojure Engineers Needed! at Factual 
 http://functionaljobs.com/jobs/8657-clojure-engineers-needed-at-factual 

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


(= '(java.lang.String) (list java.lang.String)) = false ?

2013-11-10 Thread Dave Tenny
I don't understand why these things aren't equal.

user= (= (list java.lang.String) (list (class abc)))
true
user= (= '(java.lang.String) (list (class abc)))
false
user= (type '(java.lang.String))
clojure.lang.PersistentList
user= (type (list java.lang.String))
clojure.lang.PersistentList

user= (list java.lang.String)
(java.lang.String)
user= '(java.lang.String)
(java.lang.String)
user= (= *1 *2)
false


What am I missing?
 

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


Re: (= '(java.lang.String) (list java.lang.String)) = false ?

2013-11-10 Thread Dave Tenny
I should know better, thanks.

On Sunday, November 10, 2013 7:06:13 AM UTC-5, Timo Mihaljov wrote:

 On 10.11.2013 14:03, Dave Tenny wrote: 
  I don't understand why these things aren't equal. 
  
  user= (= (list java.lang.String) (list (class abc))) 
  true 
  user= (= '(java.lang.String) (list (class abc))) 
  false 
  user= (type '(java.lang.String)) 
  clojure.lang.PersistentList 
  user= (type (list java.lang.String)) 
  clojure.lang.PersistentList 
  
  user= (list java.lang.String) 
  (java.lang.String) 
  user= '(java.lang.String) 
  (java.lang.String) 
  user= (= *1 *2) 
  false 
  
  
  What am I missing? 

 user= (type (first (list java.lang.String))) 
 java.lang.Class 
 user= (type (first '(java.lang.String))) 
 clojure.lang.Symbol 

 -- 
 Timo 


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


Re: abysmal multicore performance, especially on AMD processors

2013-11-06 Thread Dave Tenny
As a person who has recently been dabbling with clojure for evaluation 
purposes I wondered if anybody wanted to post some links about parallel 
clojure apps that have been clear and easy parallelism wins for the types 
of applications that clojure was designed for.  (To contrast the lengthy 
discussion and analysis of this topic that is *hopefully* the exception and 
not the rule).

Any good links here?  Any high profile stuff?



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