Fork me on GitHub
#clojure
<
2015-08-17
>
nberger14:08:50

@sveri: I just opened a new PR on joplin, fixing the 2 bugs I introduced in the previous one simple_smile. I'm sure I tested it better this time, and it worked fine in my tests, but it would be great if you could check it too

nberger14:08:38

@sveri: @martintrojer has just merged the PR, so I guess you can wait until 0.2.17

nberger14:08:48

Is anyone else having "strange environment issues" on leiningen 2.5.2? I wouldn't be surprised if the change in arguments parsing in lein run affected other projects and not only joplin 0.2.x

sveri16:08:33

@nberger: kk, I test .17 when it's out

timvisher16:08:30

anyone know if it's possible to use slf4j markers with clojure.tools.logging? http://www.slf4j.org/faq.html#fatal

hlship17:08:18

@timvisher It simply isn't possible, and the c.t.logging maintainers are not open to extending support for markers, as its too specific. At Aviso, we had to fork c.t.logging to add marker support, and that was a pain.

hlship17:08:06

FYI, I'm a stickler for privacy in code, I want minimum public surface area for namespaces. That can get in the way of testing. Here's an approach I'm currently using:

hlship17:08:30

e.g. (private find-data-type-mapping sw/default-swagger-options StringBuffer) calls the private function find-data-type-mapping, almost as if it has been referred into the current namespace.

hlship17:08:59

But this makes it clear that it is a private function being invoked bypassing normal visibility.

emil0r18:08:47

what's an easy to use client for a h2 database?

niwinz19:08:35

@emil0r: as far as I know, h2 is a sql database, so any jdbc client it is fine

adebesin19:08:39

Im new to learning macros and understand to a certain degree the notion of "code is data". Im currently reading Mastering Clojure Macros by Colin Jones (excellent book) but have become confused a little everytime I see a macro that could clearly be written as a function. Take for instance Clojure's core when macro:

(defmacro -when
  [test & body]
  (list 'if test (cons 'do body)))
this could easily be written as
(defn -when-fun
  [test & args]
  (if test (do args))) 
so my question is... when would I choose to use a macro over a function?

exupero19:08:39

Macros are most useful for controlling evaluation. In your -when-fun example, args is evaluated whether or not test is true, so if you have any side effects, such as logging or saving something to a database, it'll be executed regardless of test.

bostonaholic19:08:42

have you tried your -when-fun

bostonaholic19:08:17

user=> (-when-fun true (println "hi"))
hi
(nil)
user=> (-when-fun false (println "hi"))
hi
nil
user=> (when true (println "hi"))
hi
nil
user=> (when false (println "hi"))
nil

bostonaholic19:08:23

my example shows off exactly what @exupero is talking about

adebesin19:08:46

thanks guys simple_smile easy as that

exupero19:08:49

You could wrap your arguments in a function and call it (as in (defn -when-fun [test arg] (if test (arg)))), but this quickly becomes impractical for common idioms.

bostonaholic19:08:58

macros are also great for top-level constructs

bostonaholic19:08:36

think deftest in clojure.test

adebesin19:08:13

Of course.. so they sort of allow us to extend the language. They're great.

roberto19:08:40

From the book On Lisp:

roberto19:08:50

How do we know whether a given function should really be a function, rather than a macro? Most of the time there is a clear distinction between the cases which call for macros and those which don’t. By default we should use functions: it is inelegant to use a macro where a function would do. We should use macros only where they bring us some specific advantage.

roberto19:08:12

All of chapter 8 is dedicated to the question of when should I use a macro?

emil0r19:08:24

@niwinz meant a graphical ui client simple_smile

adebesin19:08:28

You know Ive never read one of Paul Grahams books but I may have to buy On Lisp

roberto19:08:04

it is free online

adebesin19:08:31

cool im on it

arohner20:08:23

before I write this fn, does it exist yet? `"Same as memoize, but takes an extra function, memo-args. f will be memoized on the result of (memo args). Useful when you want to memoize, but one arg is not a value, e.g. a DB connection”`

hlship21:08:19

That little bit of memoization inside schema.utils/memoize-id can really drive you crazy.