macro to avoid duplicating the proxy definition.
My question is: is there a better way to accomplish this, perhaps
using a mechanism other than proxy?
Thank you.
-David McNeil
Person.java
=
package demo;
public class Person {
private int id = 0;
private String name;
public
Stephan- Thank you, gen-class is what I needed.
-David
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your
first p
namespaces that I do not
understand and I hope that somewhere here can explain it.
Thank you.
-David McNeil
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new m
In ClojureQL I do not see how to join three or more tables using the
"join" function. Does anyone know if this is possible?
Thank you.
-David McNeil
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, s
fail. Can
anyone explain this?
Thank you.
-David McNeil
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with
Peter-
Thanks for the tip. I was aware of the stack overflow issue you
described, but your comment motivated me to switch to using "mvn
clojure:repl" instead of "mvn clojure:swank" to test the code, and
this does appear to work (modulo the REPL printing issue).
Thank you.
-D
Is there a way to destructure namespace qualified map keys?
I want to do something like this:
(let [{:keys (y)} {:y 20}])
Except with namespace qualified keys:
(let [{:keys (?)} {:x/y 20}])
Thank you.
-David McNeil
--
You received this message because you are subscribed to the Google
Groups
> (let [{x :x/y} {:x/y 20}] x)
> 20
That will work. Thank you!
-David McNeil
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moder
I did a real quick test on one of our projects. I had to upgrade to the
latest compojure (seems the old version used a version of instaparse that
wouldn't compile) but after that it seemed to work and was noticably faster.
-David
--
You received this message because you are subscribed to the G
We have used a monorepo to produce multiple artifacts with lein as
described here:
http://david-mcneil.com/post/160191443293/using-lein-to-produce-multiple-artifacts-from-a
-David
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this grou
s with gen-interface.
Does anyone know if there are long term plans to use the hints to type
the values in the interface? Or maybe I am just doing something wrong?
Thanks.
-David McNeil
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To pos
David - Thanks for the tips on definterface and the new statics
feature. I will need to look into these because I am not familiar with
either. What is the difference between gen-interface and definterface?
Thanks.
-David McNeil
--
You received this message because you are subscribed to the
Is there a disk-backed memoize available? I have an application where
I would like the cache of values to survive restarts of the app.
Thank you.
-David McNeil
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, sen
> I highly recommend using redis for this. There is even a clojure redis client.
>
> http://github.com/ragnard/redis-clojure
Thanks for the tip. It looks interesting, but in this case it is not
appropriate to add a separate process to the mix. I need to find a
good solution that is just a library.
> http://github.com/alienscience/cache-dot-clj
Thanks for the link. That is helpful.
> Would JDBC suit your needs as a storage medium?
I suppose that would work, but I am thinking that an ehcache based
plugin for cache-dot-clj might be a good solution.
-David
--
You received this message beca
The following code shows surprising behavior related to using protocol
functions in higher order functions. I sort of understand the reason
wrapped-x first fails is that calling extend-protocol in a sense
redefines the x protocol function. I can't decide if I think this is a
bug or just the way pro
> I think not a bug. If you want indirection in your wrapper, you can ask for
> it, e.g.:
>
> (defn wrap [f]
> (fn [& args]
> (apply @f args)))
>
> (def wrapped-x (wrap #'x))
Thank you!
-David
--
You received this message because you are subscribed to the Google
Groups "Clojure" group
I am puzzled by the results below. Can anyone explain the difference
in behavior?
-David
(defn mapper [f stream]
`(map ~f ~stream))
(eval (mapper #(+ 1 %) [10 11 12]))
;; -> (11 12 13)
(eval (mapper (partial + 1) [10 11 12]))
;; -> No matching ctor found for class clojure.core$partial..
Mark - Thanks. I am able to permute it to make it work. However, I
cannot explain why the original code fails.
-David
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from n
I have learned that instances of records do not eval to themselves.
This seems inconsistent to me. I am curious if this is intentional or
if it is a gap in the current record implementation in Clojure.
Thanks.
-David
(defn eval-type [x]
(class (eval x)))
;; instances of structural types
> Will this be any
> better or worse: (defn m [f s] (fn [] (map f s))) then doing (foo)
> instead of (eval foo)?
Armando - Generally I agree that the "m" function you defined is
clearly preferred over a solution based on eval. However, this is a
special case (too much to relate) where I needed a f
> I remember reading about it in the Joy of Clojure. It may be fixed in the
> future versions of Clojure.
Ivan - Thanks for the response. I checked Joy of Clojure and I see a
reference at the top of page 191 to the fact that records cannot be
printed and then eval'd. I was aware of this, however
Try removing the "*" characters from the names. E.g change *session-
manager-name* to session-manager.
-David
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new membe
> Thank you for your solution, but can you explain why it works ?
As best I recall... in Clojure 1.3 vars are no longer dynamic by
default. In the short-term, to ease the pain of this change, Clojure
1.3 will automatically make vars with earmuffs (e.g. *foo*) into
dynamic variables. But it warns y
For those who duck it in the future, there is more discussion here:
http://groups.google.com/group/clojure-dev/browse_thread/thread/f4907ebca8ef6e11
-David
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@g
For those who duck it in the future, there is more discussion here:
http://groups.google.com/group/clojure-dev/browse_thread/thread/f4907ebca8ef6e11
-David
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@g
I noticed the following behavior in Clojure 1.3 related to the new
object literal syntax [1]:
Clojure 1.3.0-master-SNAPSHOT
user=> (defrecord Foo [a b])
user.Foo
user=> (:a #user.Foo{:a 1 :b 2})
1
user=> #java.awt.Point[10 20]
#
user=> (.getX #java.awt.Point[10 20])
CompilerException java.lang.Run
A couple of aspects of records that I have found useful:
* they provide a type for dispatching. Rather than rooting around in
the map to find out what it is, a multi-method can dispatch directly
on the type of the object.
* having a central definition of the main keys contained in the
structure is
On Jun 30, 7:54 am, Stuart Sierra wrote:
> Recently the received wisdom has been: protocols are a low-level
> implementation detail. Actual APIs should be built with normal functions
> that call the protocol methods.
Stuart- I am a bit confused by this statement, and judging by this
thread others
On Jul 2, 3:07 pm, Christophe Grand wrote:
> Protocols are designed with the implementer in mind, not the user.
> Sometimes user-facing API and implementer-facing API overlap but it's
> not a given. So, from the user point of view, protocols are an
> implementation detail, they are somewhat "low-l
>From what I can see core.match does not support matching a variable length
series of values. For example, in a vector, match a series of 0-to-N values
of "1" followed by a value of "2". I am interested to know whether/how
match patterns like this would fit into core.ma
On Friday, May 18, 2012 9:59:40 AM UTC-5, David Nolen wrote:
>
> It sounds like you're describing searching for a pattern?
>
Yes, I think that sounds right. I am not sure how that fits into the
core.match picture.
Thanks.
-David McNeil
--
You received this message because you
[{:x (x :when #(= :clojure.core.match/not-found
%))}]
["match" x])
;;=> ["match" nil]
I am curious: is this by design?
Thanks.
-David McNeil
--
You received this message because you are subscribed to the Google
Groups "Clojure" group
Does this thread address your need?
https://groups.google.com/forum/?fromgroups=#!searchin/clojure/local$20repository$20/clojure/1Ne8RqiffVI/aGoCPWiiCakJ
-David
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo
I notice the following item at
http://dev.clojure.org/display/design/Library+Coding+Standards
"Be explicit and minimalist about dependencies on other packages.
(Prefer the :only option to use and require)."
The page was last edited on Mar 29, 2011 and ns usage has been discussed a
fair bit
I have not heard from anyone that
http://dev.clojure.org/display/design/Library+Coding+Standards is out of
date, so I take that to mean that the following is still the standard:
"Be explicit and minimalist about dependencies on other packages.
(Prefer the :only option to use and require)."
-Da
semantic technology experience, but this is a
great place to get it!
If you are interested, email a note and your resume to careers _at_
revelytix.com.
[1] http://revelytix.com/
Thanks.
-David McNeil
--
You received this message because you are subscribed to the Google
Groups "Clojure"
Razvan Rotaru wrote:
> Is there a way to attach metadata to defrecord ?
Is this what you are looking for?
(defrecord MyRecord [a b])
(let [r (with-meta (MyRecord. 1 2) {:extra 100})]
(meta r))
;;-> {:extra 100}
-David
--
You received this message because you are subscribed to the Google
Gro
ress it at dev time in the
blog post [1].
-David
[1] http://david-mcneil.com/post/3495351254/clojure-protocol-adapters
[2] https://github.com/david-mcneil/clojure-adapt
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group
A couple of more thoughts on this.
On Oct 28, 12:46 pm, Howard Lewis Ship wrote:
> (extend-type cascade.Asset
> ToAttributeValueString
> (to-attribute-value-string [asset] (:client-url asset)))
The reason this is probably not what you really want is that the set
of types which satisfy the As
I discuss one solution to this problem here:
http://david-mcneil.com/post/958196603/enhanced-clojure-records-part-2
-David
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts f
records more
> pleasant.
This is a snapshot of a defrecord2 implementation that I have been
using. Among other things it makes records print in an eval'able form.
https://github.com/david-mcneil/defrecord2
-David
--
You received this message because you are subscribed to the Google
Groups &quo
42 matches
Mail list logo