Re: clojure.core.logic.core/match usage

2011-10-05 Thread David Nolen
This should be fixed, I released 0.2.0-alpha4. Feedback appreciated.

David.

On Mon, Oct 3, 2011 at 6:27 AM, Sunil S Nandihalli <
sunil.nandiha...@gmail.com> wrote:

> Hello everybody,
>  I was playing with core.match library and I notice the following behavior
>
> let [x {:a 1 :b 2 :c 10 :d 30}]
>  (match [x]
>[({:a _ :b _ :c _ :d _} :only [:a :b :c :d])] :a-1
>[({:a _ :b 2} :only [:a :b])] :a0
>[{:a 1 :c _}] :a1
>[{:c 3 :d _ :e 4}] :a2
>:else []))
>
> returns
> :a1
> I was hoping to get
> :a-1
>
> Am I using it wrong? Have I misunderstood as to how match is supposed to
> work? It looks like match assumes either that there is always a unique match
> or it does not guarantee that it will the try matches in the order
> specified. Can somebody help?
>
> Thanks,
> Sunil.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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

Re: Reuse of generic Clojure/ClojureScript code?

2011-10-05 Thread Dave Sann
If anyone is interested, this is the strategy that I am currently using. 
It's a bit messy with linking but it saves me maintaining multiple versions 
and has worked so far. I expect that the linking could be removed with some 
work upstream. This is a workaround for me until a more standard solution 
comes out.

I have started to separate code that I believe to be generic form code that 
I believe to be platform specific. It is not always possible to tell due to 
included dependencies, so there may be some trial and error.

If I am making a project - say 'utils' that I think can be used across clj 
and cljs, I use the following structure:

I put generic code in src.
I put jvm specific code in src/utlis/x (namespace utils.x and below)
I put cljs/js specific code in src_cljs/utils/x (namespace utils.x and 
below)

Generic code is developed under src and sym-linked into src_cljs - with a 
change in extension to .cljs

All platform dependent code is in or under the namespace utils.x (I use x 
because it's short and easy to see). This is not crosslinked (obviously).

I do not use 'cljs' or 'jvm' as the name space for platform specific code. 
Using the same prefix 'x' allows generic code to freely use platform 
specific code provided that it is explicitly implemented to the same API in 
both clj and cljs. This may not always be a reasonable thing to do, but 
where it is it seems effective.

Nothing special is required beyond this. I use cljs-watch to compile the 
clojurescript by pointing it at the src_cljs directory.

Cheers

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

Re: Leiningen Local Repositories

2011-10-05 Thread Dave Sann
Hi Phil, I agree - I am not looking for 'builds on my machine' in 
particular.

I want to separate the distinction of my use of a local 
repository/cache/proxy to serve globally available jars from the project.clj 
so that it is portable.

This enables me to have local build and a continuous integration build 
without repeatedly downloading the entire dependency chain. And, at the same 
time, not make the project.clj specific to me.

I see this a slightly different question from 'builds on my machine' which 
is determined by the presence of dependencies in globally available 
repositories. If I were to distribute a project.clj with dependencies that 
were not available, that would definitely be a pain.

Anyway, it is not a major issue for me. Thanks for your input.

Cheers

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

Re: Leiningen Local Repositories

2011-10-05 Thread Phil Hagelberg
On Wed, Oct 5, 2011 at 3:03 PM, Rob Wolfe  wrote:
> Dave Sann  writes:
>
>> Hey Rob, Thanks for your reply,
>>
>> I will try that for my projects
>>
>> My use case is slightly different though. I want to be able to build other
>> peoples projects from source (e.g. from github) without editing any of the
>> project.clj files - but still overriding to use my local repository.
>>
>> Any ideas?
>
> Quick and dirty hack is adding to init.clj something like this:

This should work, but as you've noticed it's pretty ugly. This
functionality is excluded from Leiningen on purpose because it would
encourage projects that can't build from project.clj alone. There are
a few places where you legitimately need to exclude necessary info
from project.clj (deploy credentials mostly), but in general we want
to avoid Works on My Machine scenarios.

-Phil

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


Re: ClojureScript for CouchDB

2011-10-05 Thread Chas Emerick
Not a lot, it turns out.  I have ClojureScript views working locally,
and am in the process of working out how to best integrate them into
clutch.  The stuff works, and should extend with little effort to
_changes filters, etc. etc.

There are some issues in ClojureScript that are relevant, but I can't
imagine them being insurmountable.  I'll be describing those problems
on the dev list soon, once I have fully understood what's needed.

I'm hoping to get this functionality into clutch ASAP, so hopefully
the wait will not be too long.

In any case, I'm speaking at the Bay Area Clojure Meetup group
tomorrow night on this exact topic:

http://www.meetup.com/The-Bay-Area-Clojure-User-Group/events/19783251/

Cheers,

- Chas

On Sep 13, 6:06 am, Pepijn de Vos  wrote:
> What needs to be done?
>
> Pepijn
>
> On Sep 13, 2011, at 2:30 PM, Stuart Sierra wrote:
>
>
>
>
>
>
>
> > Just an idea at the moment. We need more people with knowledge of CouchDB 
> > to work on it.
>
> > -Stuart Sierra
> > clojure.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 post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Leiningen Local Repositories

2011-10-05 Thread Rob Wolfe
Dave Sann  writes:

> Hey Rob, Thanks for your reply,
>
> I will try that for my projects
>
> My use case is slightly different though. I want to be able to build other 
> peoples projects from source (e.g. from github) without editing any of the 
> project.clj files - but still overriding to use my local repository.
>
> Any ideas?

Quick and dirty hack is adding to init.clj something like this:

;;; ~/.lein/init.clj ;;;

(defn customize
  "Customize default repos"
  [new-repos]
  (alter-var-root #'leiningen.core/default-repos
  (fn [p] (leiningen.core/repositories-for
   {:omit-default-repositories true
:repositories new-repos}

(customize {"releases"
"http://artifactory/artifactory/libs-release";
"snapshots" 
"http://artifactory/artifactory/libs-snapshot";
"local-release" 
"http://artifactory/artifactory/libs-release-local"})
;

I haven't really thought all consequences of this hack through,
so use it on your own risk. ;-)

HTH,
Rob

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


goog.net.cookies with clojurescript?

2011-10-05 Thread Eric Harris-Braun
Has anybody successfully used cookies in clojurescript with
goog.net.cookies?

I keep getting this error: 'this.isValidName' [undefined] is not a
function" (Safari) or "Uncaught TypeError: Object [object DOMWindow]
has no method 'isValidName'" (Chrome) when I try to set a cookie via
goog.net.cookies.set.

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


Re: defprotocol problem in 1.3?

2011-10-05 Thread Armando Blancas
I'd recommend that you file a bug; surely that's a regression.

As you pointed out, this fails:
user=> (defprotocol xyz)
CompilerException java.lang.UnsupportedOperationException: Unknown
Collection type, compiling:(NO_SOURCE_PATH:1)

But the expansion works if you evaluate it directly, which might be
useful for a workaround:

Clojure 1.3.0
user=> (do
  (clojure.core/defonce xyz {})
  (clojure.core/gen-interface :name user.xyz :methods ())
  (clojure.core/alter-meta! (var xyz) clojure.core/assoc :doc nil)
  ((var clojure.core/assert-same-protocol) (var xyz) (quote ()))
  (clojure.core/alter-var-root (var xyz)
   clojure.core/merge
   (clojure.core/assoc {:on (quote user.xyz),
:on-interface user.xyz}
:sigs (quote {})
:var (var xyz)
:method-map {}
:method-builders {}))
  (clojure.core/-reset-methods xyz)
  (quote xyz))
xyz
user=> (deftype sometype [] xyz)
user.sometype

On Oct 5, 12:36 pm, hgreen  wrote:
> Um, this is all going down a path that I don't propose to follow. I am
> manifestly aware that there are loads of alternatives already in Clojure
> (and Java, for that matter), and many reasons both theoretical and practical
> for doing or not doing all manner of things. But, a couple of remarks:
>
> @Alan: Mostly I agree, but I think you're busily belaboring a strawman
> here---you're reading way more into my idiot Java-analogy than is actually
> there. I do need be clear on one point, however: I am not asking,
> suggesting, promoting, recommending, or otherwise requesting in any way,
> shape, or form, that any of the sort of stuff you're describing to be
> implemented in Clojure... and what I do in the confines of my
> implementations is my business.
>
> @Meikel: been there, done that, and it *is* clumsy... and that's exactly the
> point I arrived at. The more little pieces involved in defining a data type,
> the worse off for the implementer. For that matter, even the requirement
> that one has to specify a protocol and then a record is a tedious exercise
> if there's never going to be more than a single implementation.
>
> But, so what? Heh... it's so nice to be able to say that! And I can say that
> because Clojure provides me with a marvelous arsenal of weapons for dealing
> with this kind of issue. As I have done, to my considerable satisfaction. My
> solution just happened to have evolved in a particular direction that didn't
> involve extend-type; in another incarnation, maybe it will.
>
> Bottom line is that I have a mechanism long since implemented that solves my
> particular set of problems in my particular environment. I have no
> intentions of altering it if I can avoid doing so, and even fewer intentions
> of foisting it on the rest of the world. Clojure 1.3 broke it by altering
> the behavior of a special case of a low-level functionality---something I'd
> view as a basic building block. Question is, is it likely to be repaired,
> and if so, in what sort of timeframe? Or do I need to change my stuff? I'm
> good with the decision, either way... though I surely have preferences as to
> who I'd like to have doing the work... :-)
>
> 'Nuff said...
>
> -- Howard

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


Re: defprotocol problem in 1.3?

2011-10-05 Thread David Nolen
Clojure uses marker interfaces. ClojureScript supports marker protocols.

I don't see why Clojure shouldn't support this.

David

On Wed, Oct 5, 2011 at 3:36 PM, hgreen  wrote:

> Um, this is all going down a path that I don't propose to follow. I am
> manifestly aware that there are loads of alternatives already in Clojure
> (and Java, for that matter), and many reasons both theoretical and practical
> for doing or not doing all manner of things. But, a couple of remarks:
>
> @Alan: Mostly I agree, but I think you're busily belaboring a strawman
> here---you're reading way more into my idiot Java-analogy than is actually
> there. I do need be clear on one point, however: I am not asking,
> suggesting, promoting, recommending, or otherwise requesting in any way,
> shape, or form, that any of the sort of stuff you're describing to be
> implemented in Clojure... and what I do in the confines of my
> implementations is my business.
>
> @Meikel: been there, done that, and it *is* clumsy... and that's exactly
> the point I arrived at. The more little pieces involved in defining a data
> type, the worse off for the implementer. For that matter, even the
> requirement that one has to specify a protocol and then a record is a
> tedious exercise if there's never going to be more than a single
> implementation.
>
> But, so what? Heh... it's so nice to be able to say that! And I can say
> that because Clojure provides me with a marvelous arsenal of weapons for
> dealing with this kind of issue. As I have done, to my considerable
> satisfaction. My solution just happened to have evolved in a particular
> direction that didn't involve extend-type; in another incarnation, maybe it
> will.
>
> Bottom line is that I have a mechanism long since implemented that solves
> my particular set of problems in my particular environment. I have no
> intentions of altering it if I can avoid doing so, and even fewer intentions
> of foisting it on the rest of the world. Clojure 1.3 broke it by altering
> the behavior of a special case of a low-level functionality---something I'd
> view as a basic building block. Question is, is it likely to be repaired,
> and if so, in what sort of timeframe? Or do I need to change my stuff? I'm
> good with the decision, either way... though I surely have preferences as to
> who I'd like to have doing the work... :-)
>
> 'Nuff said...
>
> -- Howard
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

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

Re: Reference a function dynamically in a macro?

2011-10-05 Thread Alan Malloy
This fix has some bugs - you let finder but never use it. Adjusted
below:

(defmacro unique?
  [name value msg]
  (let [finder (symbol (str "by-" (clojure.core/name name)))])
  `(let [value# ~value]
 (when-not (str/blank? value#)
   (when-let [existing# (~finder value#)]
 (duplicate existing# ~msg value#)

On Oct 5, 6:52 am, "Meikel Brandmeyer (kotarak)" 
wrote:
> Hi,
>
> you have the conversion to the "by-name" function in the wrong level of
> quoting in the macro.
>
> (defmacro unique?
>   [name value msg]
>   `(let [value#  ~value]
>      (when-not (str/blank? value#)
>        (let [finder# ~(symbol (str "by-" (clojure.core/name name)))]
>          (when-let [existing# (existing value#)]
>            (duplicate existing# ~msg value#))
>
> Sincerely
> Meikel

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


Re: defprotocol problem in 1.3?

2011-10-05 Thread hgreen
Um, this is all going down a path that I don't propose to follow. I am 
manifestly aware that there are loads of alternatives already in Clojure 
(and Java, for that matter), and many reasons both theoretical and practical 
for doing or not doing all manner of things. But, a couple of remarks:

@Alan: Mostly I agree, but I think you're busily belaboring a strawman 
here---you're reading way more into my idiot Java-analogy than is actually 
there. I do need be clear on one point, however: I am not asking, 
suggesting, promoting, recommending, or otherwise requesting in any way, 
shape, or form, that any of the sort of stuff you're describing to be 
implemented in Clojure... and what I do in the confines of my 
implementations is my business. 

@Meikel: been there, done that, and it *is* clumsy... and that's exactly the 
point I arrived at. The more little pieces involved in defining a data type, 
the worse off for the implementer. For that matter, even the requirement 
that one has to specify a protocol and then a record is a tedious exercise 
if there's never going to be more than a single implementation.

But, so what? Heh... it's so nice to be able to say that! And I can say that 
because Clojure provides me with a marvelous arsenal of weapons for dealing 
with this kind of issue. As I have done, to my considerable satisfaction. My 
solution just happened to have evolved in a particular direction that didn't 
involve extend-type; in another incarnation, maybe it will.

Bottom line is that I have a mechanism long since implemented that solves my 
particular set of problems in my particular environment. I have no 
intentions of altering it if I can avoid doing so, and even fewer intentions 
of foisting it on the rest of the world. Clojure 1.3 broke it by altering 
the behavior of a special case of a low-level functionality---something I'd 
view as a basic building block. Question is, is it likely to be repaired, 
and if so, in what sort of timeframe? Or do I need to change my stuff? I'm 
good with the decision, either way... though I surely have preferences as to 
who I'd like to have doing the work... :-)

'Nuff said...

-- Howard

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

Re: Macro tutorials?

2011-10-05 Thread Michał Marczyk
On 5 October 2011 11:38, Michael Jaaka  wrote:
> In fact I still don't know the macros works, I don't know when
> and how is evaluated and how symbols are evaluated.

Macros are just functions manipulating list structure (the data
structures produced by the reader when reading in Clojure code).

E.g. say we want to write our own 'and macro (which differs from
clojure.core/and in that it returns true if all xs evaluate to truthy
values at run time (rather than the last x)):

(defmacro my-and [& xs]
  (if (seq xs)
`(let [x# ~(first xs)]
   (if x# (my-and ~@(next xs)) x#))
true))

Actually, to make it clearer what's happening, we could also write it like so:

(defmacro my-and [& xs]
  (let [xsym (gensym "x")]
(if (seq xs)
  (list `let [xsym (first xs)]
(list `if xsym (list* `my-and (next xs)) xsym))
  true)))

Now if you write (my-and 1 2 false 3) in your code, the compiler will
notice that this is a list whose first symbol names a macro function
and call the macro function:

(apply #'my-and nil nil '(1 2 false 3))
; => (clojure.core/let [x12 1] (if x12 (user/my-and 2 false 3) x12))

(Don't worry about the nils -- they're needed because macro functions
in Clojure expect to receive extra magic arguments beyond those
explicitly named in their signatures. These are very useful
occasionally, but for the sake of simplicity, let's just forget about
them -- they're not used by my-and anyway.)

The return value is just another list; as it happens, clojure.core/let
is a macro too, so it too gets expanded. Only when the result of macro
expansion is no longer itself a macro call is JVM bytecode actually
emitted by the compiler.

Now for a more complex example:

(def x false)

(my-and 1 2 x 3)

We would expect this to return false at run time, and indeed it does,
but the macro function itself doesn't care about that -- it just
returns something like

(let [x1 1] (if x1 (my-and 2 x 3) x1))

Eventually the inner call gets expanded, so the code looks like

(let [x1 1] (if x1 (let [x2 2] (if x2 (my-and x 3) x2)) x1))

Ultimately we obtain

(let [x1 1]
  (if x1
(let [x2 2]
  (if x2
(let [x3 x] ; <- notice the x
  (if x3
(let [x4 3]
  (if x4
true
x4))
x3))
x2))
 x1))

The 'x here is still just a symbol; the value of the Var it names only
becomes relevant at run time.

In fact, evaluation of arguments passed to macros only ever happens at
run time (well, there's the possibility of calling eval from inside a
macro to force a "recursive compilation" followed by evaluation of a
form; this is likely to be useful only in fairly esoteric cases). If
you want to prevent if from happening even then, you can wrap the
arguments in a 'quote form in the expansion:

(defmacro list-of-unevaled [& xs]
  (list* `list (map #(list 'quote %) xs)))

(list-of-unevaled (+ 1 2) (/ 5 0))
; => ((+ 1 2) (/ 5 0))

Hope this helps,
Michał

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


Re: Reference a function dynamically in a macro?

2011-10-05 Thread Meikel Brandmeyer (kotarak)
Hi,

you have the conversion to the "by-name" function in the wrong level of 
quoting in the macro.

(defmacro unique?
  [name value msg]
  `(let [value#  ~value]
 (when-not (str/blank? value#)
   (let [finder# ~(symbol (str "by-" (clojure.core/name name)))]
 (when-let [existing# (existing value#)]
   (duplicate existing# ~msg value#))

Sincerely
Meikel

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

Re: Reference a function dynamically in a macro?

2011-10-05 Thread Baishampayan Ghose
On Wed, Oct 5, 2011 at 5:02 AM, Sean Bowman  wrote:
> Here's my first attempt (obviously it doesn't work, but might help
> clarify what I'm getting at):
>
>    (defmacro unique?
>      "Is the given value unique to the record?"
>      [name value message]
>      `(if-not (str/blank? ~value)
>         (let [finder# (symbol (str "by-" (name ~name)))
>               existing# (finder# ~value)]
>           (if existing# (duplicate existing# ~message ~value)
>
> (The "duplicate" function raises the exception.)

What is the exception? Does namespace qualifying `duplicate` help?

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.com

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


Re: Shameless self promotion - JavaOne

2011-10-05 Thread Boris Mühmer
Thanks for the slides! The presentation is very interesting.

Was there a recording of Your talk?


  - boris


2011/10/5 Dennis :
> Here is a link to my presentation.
>
> http://dl.dropbox.com/u/5831287/JavaOne%202011%20-%20Monitoring%20a%20Large-Scale%20Infrastructure%20with%20Clojure%20FINAL.pptx
>
> Sorry about the file format :)
>
> Let me know if the link doesn't work.
>
> -- Dennis
>
> On Tue, Oct 4, 2011 at 10:17 AM, C. Arel  wrote:
>> Hi Dennis and Chas,
>> I'd also like the slides if possible. Maybe if you could post them
>> here in the group more people can get them.
>>
>> Thanks,
>> Can
>>
>> On 27 Sep, 17:50, Dennis  wrote:
>>> Hey guys,
>>>
>>> I will be giving a talk at JavaOne (it is Clojure related).  Here is
>>> the information.
>>>
>>> Title:          Monitoring a Large-Scale Infrastructure with Clojure
>>> Time             Tuesday, 07:30 PM, Parc 55 - Embarcadero
>>> Length          45 Minutes
>>> Abstract:               Monitoring a large infrastructure brings unique 
>>> challenges
>>> that require blending development and operations concepts. This
>>> session discusses how Dell Inc. used Clojure to develop a
>>> data-flow-based monitoring system that stores, evaluates, and acts on
>>> hundreds of thousands of metrics.
>>>
>>> It covers
>>> • Real-world applications of Clojure's parallel programming constructs
>>> to take advantage of multiple cores available in today's systems
>>> • Using Clojure's homoiconic nature to create DSLs
>>> • Taking advantage of Clojure running on the JVM to use the Java ecosystem
>>> • How DevOps takes advantage of the JVM dynamic languages to develop
>>> new monitoring tools
>>> Track           Emerging Languages, Tools, and Techniques
>>> Optional Track          The Java Frontier
>>>
>>> -- Dennis
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with your 
>> first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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


Reference a function dynamically in a macro?

2011-10-05 Thread Sean Bowman
I like to build DSLs when I code, so that at a high level, much of the
logic is readable and consistent.  I'm trying to create a macro that
will verify the uniqueness of a record based on various fields in the
record.  For example, if I have a function that looks up a record by
its name:

(defn by-name [name] (...some code to look up the record by
name...))

In its create routine, I want to call a macro "unique?" and have the
record check that the name doesn't already exist:

(defn create
[name]
(unique? :name name "The name \"%s\" already exists.")
no exception, we can create the record...
)

That "unique?" macro would convert :name into a call to the "by-name"
function, pass in the value, check for a result, and if it already
exists, throw an exception with the given message.

I'm having a heck of a time converting that :name to the "by-name"
reference, and I'm trying to avoid eval because I understand it's a
performance hit.  Is there a way to accomplish this in the "unique?"
macro?

Here's my first attempt (obviously it doesn't work, but might help
clarify what I'm getting at):

(defmacro unique?
  "Is the given value unique to the record?"
  [name value message]
  `(if-not (str/blank? ~value)
 (let [finder# (symbol (str "by-" (name ~name)))
   existing# (finder# ~value)]
   (if existing# (duplicate existing# ~message ~value)

(The "duplicate" function raises the exception.)

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


Re: Doc & Testing update needed

2011-10-05 Thread Daniel
> Your code does not follow a path but instead you always search from same
> node for every type in the list.

Yeah - that's kind of what I thought the intended behavior was, but
now I understand.  Thanks for the explanation.


On Oct 5, 1:51 am, Jozef Wagner  wrote:
> Borneos walk is a convenient wrapper
> forhttp://api.neo4j.org/current/org/neo4j/graphdb/Node.html#getSingleRel...,
> org.neo4j.graphdb.Direction)
>
> It returns exactly one node. It should be used in situations where you want
> to walk from some node by following given list of relationship types. It
> cannot be used in situations where node has multiple relationships of same
> type.
>
> Your code does not follow a path but instead you always search from same
> node for every type in the list.
>
> Jozef

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


Re: Macro tutorials?

2011-10-05 Thread Baishampayan Ghose
On Wed, Oct 5, 2011 at 4:16 PM, Meikel Brandmeyer (kotarak)  
wrote:
> And just for fun some more:
>
> (defmacro map-fn
>   [& fns]
>   (into {} (map (fn [[n & tail]] [(keyword n) `(fn ~@tail)]) fns)))

That one looks very cool, Meikel :-)

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.com

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


Re: Macro tutorials?

2011-10-05 Thread Meikel Brandmeyer (kotarak)
And just for fun some more:

(defmacro map-fn
  [& fns]
  (into {} (map (fn [[n & tail]] [(keyword n) `(fn ~@tail)]) fns)))

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

Re: Macro tutorials?

2011-10-05 Thread Baishampayan Ghose
Hi,

> I wrote few apps with clojure. I have used many times macro to expand
> expressions and change some control flows. I thought that I know
> macros, but now I know that doing some programming by analogy is not
> enough. In fact I still don't know the macros works, I don't know when
> and how is evaluated and how symbols are evaluated. Problem below is
> something which I'm not able to solve with my current "knowledge".
>
> Let say that I wrote macro map-fnc
>
> and I want to use it like
>
> (map-fnc (function1 [] "hello")
>        (function2 [a] (println a)) )
>
> The result is map in which keys are names of methods as strings and
> body is a function with proper arity.
> So I can evalutate this:
>
>
> ((get (map-fnc (function1 [] "hello")
>                (function2 [a] (println a)) ) "function1"))
>
> or this
>
>
> ((get (map-fnc (function1 [] "hello")
>                (function2 [a] (println a)) ) "function2") "hello world")
>
> Any help?! I belive that solving this problem might give me more
> insight on how macro works.

I might write it like this -

(defmacro map-fnc
  [& fn-specs]
  (let [fn-names (map (comp str first) fn-specs)
fn-decls (map #(cons 'fn (rest %)) fn-specs)
fn-map (zipmap fn-names fn-decls)]
`~fn-map))

See if that works for you.

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.com

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


Re: Macro tutorials?

2011-10-05 Thread Michael Jaaka
I have manage to write something like this. But nothing more, all my
ideas are wrong, because bad knowledge about evaluation and namespace
expansion time.


(defmacro map-fnc [ & methods ]
`(reduce (fn[ acc# m# ] (assoc acc# (str (first m#)) (list 'fn (rest
m#))  )) {} '~methods ))

(map-fnc (function1 [] "hello")
(function2 [a] (println a)))

On Oct 5, 11:38 am, Michael Jaaka 
wrote:
> Hi!
>
> I wrote few apps with clojure. I have used many times macro to expand
> expressions and change some control flows. I thought that I know
> macros, but now I know that doing some programming by analogy is not
> enough. In fact I still don't know the macros works, I don't know when
> and how is evaluated and how symbols are evaluated. Problem below is
> something which I'm not able to solve with my current "knowledge".
>
> Let say that I wrote macro map-fnc
>
> and I want to use it like
>
> (map-fnc (function1 [] "hello")
>         (function2 [a] (println a)) )
>
> The result is map in which keys are names of methods as strings and
> body is a function with proper arity.
> So I can evalutate this:
>
> ((get (map-fnc (function1 [] "hello")
>                 (function2 [a] (println a)) ) "function1"))
>
> or this
>
> ((get (map-fnc (function1 [] "hello")
>                 (function2 [a] (println a)) ) "function2") "hello world")
>
> Any help?! I belive that solving this problem might give me more
> insight on how macro works.
>
> Thanks in advance!

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


Macro tutorials?

2011-10-05 Thread Michael Jaaka
Hi!

I wrote few apps with clojure. I have used many times macro to expand
expressions and change some control flows. I thought that I know
macros, but now I know that doing some programming by analogy is not
enough. In fact I still don't know the macros works, I don't know when
and how is evaluated and how symbols are evaluated. Problem below is
something which I'm not able to solve with my current "knowledge".

Let say that I wrote macro map-fnc

and I want to use it like

(map-fnc (function1 [] "hello")
(function2 [a] (println a)) )

The result is map in which keys are names of methods as strings and
body is a function with proper arity.
So I can evalutate this:


((get (map-fnc (function1 [] "hello")
(function2 [a] (println a)) ) "function1"))

or this


((get (map-fnc (function1 [] "hello")
(function2 [a] (println a)) ) "function2") "hello world")

Any help?! I belive that solving this problem might give me more
insight on how macro works.

Thanks in advance!

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


Re: Shameless self promotion - JavaOne

2011-10-05 Thread Chas Emerick
I will blog a summary of the talk along with the slides shortly.  I have quite 
the backlog of drafts to polish up, but they're coming. :-)

- Chas

On Oct 4, 2011, at 8:17 AM, C. Arel wrote:

> Hi Dennis and Chas,
> I'd also like the slides if possible. Maybe if you could post them
> here in the group more people can get them.
> 
> Thanks,
> Can
> 
> On 27 Sep, 17:50, Dennis  wrote:
>> Hey guys,
>> 
>> I will be giving a talk at JavaOne (it is Clojure related).  Here is
>> the information.
>> 
>> Title:  Monitoring a Large-Scale Infrastructure with Clojure
>> Time Tuesday, 07:30 PM, Parc 55 - Embarcadero
>> Length  45 Minutes
>> Abstract:   Monitoring a large infrastructure brings unique 
>> challenges
>> that require blending development and operations concepts. This
>> session discusses how Dell Inc. used Clojure to develop a
>> data-flow-based monitoring system that stores, evaluates, and acts on
>> hundreds of thousands of metrics.
>> 
>> It covers
>> • Real-world applications of Clojure's parallel programming constructs
>> to take advantage of multiple cores available in today's systems
>> • Using Clojure's homoiconic nature to create DSLs
>> • Taking advantage of Clojure running on the JVM to use the Java ecosystem
>> • How DevOps takes advantage of the JVM dynamic languages to develop
>> new monitoring tools
>> Track   Emerging Languages, Tools, and Techniques
>> Optional Track  The Java Frontier
>> 
>> -- Dennis
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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


Re: Shameless self promotion - JavaOne

2011-10-05 Thread Colin Yates
Also, I have to ask - why didn't you use one of the many "industry-standard" 
toolsuites?  (I am particularly partial to Zabbix myself but I don't have 
thousands of machines to monitor, only < 100).
Excerpts from Dennis's message of 2011-10-05 05:55:01 +0100:
> Here is a link to my presentation.
> 
> http://dl.dropbox.com/u/5831287/JavaOne%202011%20-%20Monitoring%20a%20Large-Scale%20Infrastructure%20with%20Clojure%20FINAL.pptx
> 
> Sorry about the file format :)
> 
> Let me know if the link doesn't work.
> 
> -- Dennis
> 
> On Tue, Oct 4, 2011 at 10:17 AM, C. Arel  wrote:
> > Hi Dennis and Chas,
> > I'd also like the slides if possible. Maybe if you could post them
> > here in the group more people can get them.
> >
> > Thanks,
> > Can
> >
> > On 27 Sep, 17:50, Dennis  wrote:
> >> Hey guys,
> >>
> >> I will be giving a talk at JavaOne (it is Clojure related).  Here is
> >> the information.
> >>
> >> Title:          Monitoring a Large-Scale Infrastructure with Clojure
> >> Time             Tuesday, 07:30 PM, Parc 55 - Embarcadero
> >> Length          45 Minutes
> >> Abstract:               Monitoring a large infrastructure brings unique 
> >> challenges
> >> that require blending development and operations concepts. This
> >> session discusses how Dell Inc. used Clojure to develop a
> >> data-flow-based monitoring system that stores, evaluates, and acts on
> >> hundreds of thousands of metrics.
> >>
> >> It covers
> >> • Real-world applications of Clojure's parallel programming constructs
> >> to take advantage of multiple cores available in today's systems
> >> • Using Clojure's homoiconic nature to create DSLs
> >> • Taking advantage of Clojure running on the JVM to use the Java ecosystem
> >> • How DevOps takes advantage of the JVM dynamic languages to develop
> >> new monitoring tools
> >> Track           Emerging Languages, Tools, and Techniques
> >> Optional Track          The Java Frontier
> >>
> >> -- Dennis
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with 
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> > http://groups.google.com/group/clojure?hl=en
> 

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