This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
tdantas: It's certainly a powerful mechanism you've made. Sometimes scotch is too much and a beer will do. In general highly generic, parameterized code can be hard to maintain
I kind of loathe reading code where you have to think about what the parameters, which are functions, take
That aside, I have frequently written a pipeline-esque function, like your chain
, but that handles stopping early, rather than running the whole chain. (Usually using loop/recur or reduce/reduced, stopping when the result contains an :error
key)
what you've made is a useful pattern, and seems idiomatic. Just beware over-generifying functions/over-abstracting
I’m using tools.logging and have a log4j.properties
file in src/
which writes logs to a file. However, when I run my tests (with lein test
) the logs are still written to stdout (and interleaved with the test output). How do I turn off logging when running my tests?
@ghadi: what do you mean by "I kind of loathe reading code where you have to think about what the parameters, which are functions, take" ?
@oliv: that looks an awful lot like a maybe monad. Take a look: http://clojure.github.io/algo.monads/
I would put the exception handling in m-result
to coerce it to nil
and then use the same m-bind
yeah, so my functions instead of throw exception would handle inside and returns :error in the container.
my understanding about monads ( superficial based on my university class in haskell ) is compose computational steps into multi-step computation
you are defining computational steps and you want to stop at any exception, handle it with error-handler
and leave
> you are defining computational steps and you want to stop at any exception, handle it with error-handler
and leave
exactly
> now you can do more interesting things than just (reverse fn-list)
could you exemplify ? ( if i am not bothering you too much )
if down the road you want to add a conditional between the chaining, where you might have two branches chain doesn't apply anymore
this can be awkward to write using chain
(it can, but it won't visually/syntactically reflect your intent)
>if down the road you want to add a conditional between the chaining, where you might have two branches chain doesn't apply anymore yeah, got it
my hunch is that using a monad that captures the rule you mentioned above you can write that code and get your syntax and intent aligned
hi, a question about the quasiquote. why does
args end up as
user/args`. But
args# ends up as
arg__1179__auto__` . I don’t even know what to google for to figure this out.
@shriphani: google for gensym
and
differs from
’` in behavior? This is quite unexpected (I’ve written macros in racket before).
@shriphani: as you noticed, the back-tick will namespacify your symbol - that won’t happen with apostrophe
You'll find useful info under syntax-quote in http://clojure.org/reader. The rationale for it comes the concept of "hygienic macros", and this post explains it very well: https://xivilization.net/~marek/blog/2013/09/17/clojure-and-hygienic-macros/
Extracted from that post: > the problem that Lisp macros usually have, they capture the scope of the point where they were called (think dynamic scoping), not where they were defined (think lexical scoping). Various Lisps have solved this problem in different ways, you can find a lot about this on the internet. Clojure has a somewhat unique solution: syntax-quote does not only quote things, it also adds the namespace to things