This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-07-23
Channels
- # beginners (4)
- # boot (297)
- # cider (12)
- # cljs-dev (3)
- # clojure (49)
- # clojure-brasil (1)
- # clojure-quebec (1)
- # clojure-russia (36)
- # clojure-sg (4)
- # clojure-spec (21)
- # clojure-uk (3)
- # clojurescript (28)
- # cursive (3)
- # datascript (2)
- # datomic (3)
- # hoplon (63)
- # re-frame (1)
- # spirituality-ethics (2)
- # test-check (1)
- # testing (1)
- # yada (1)
How do you bind a value to symbol as a variable? Much like you see in datalog (def a '[?e :my/name "name”])
. By quoting the form it’s not evaluated so the symbol isn’t looked up. But what’s the next step?
@candiedcode: yeah don't follow that :)
I wrote it and it goes seriously astray
It's also not relevant - records can't extend a Java class
Looking for lib suggestion. I have a database where all the text data is in upper-case. Need to convert to proper case, specifically for peoples names. Looking for something ‘smart’ which can handle things like O’Tool, D’Arcy, McDonald, van Dyke etc. Previous app used a Perl module. Looking for either a clojure library (no need for clojurescrit support) or a java lib?
@kingoftheknoll i don't understand what you are trying to do can you give an example?
hello guys really new to clojure and i'm finding Boot to be a real challenge I'm trying to set up my repl in build.boot to bind to a specific port yet not tied to a ip but to localhost for remote purposes. I tried setting the task-options! repl { :host 0.0.0.0 :port 9000} but nrepl seems to still get bound to 127.0.0.1. What do I do to get remote repl?
@isekream: there’s a #C053K90BR channel, you might have more luck there
@val_waeselynck: to create a var you intern a symbol with a value. Basically what def
does. (def a (atom {}))
. It’s binding a value to a symbol at the global context. But with functions that take a quoted form with symbols in it to be used later as variables in local binding. A datalog query being a good example.
(d/q '[ :find ?n ?a
:where [?e :aka "Maks Otto von Stirlitz"]
[?e :name ?n]
[?e :age ?a] ]
I know the query engine is not like iteration but imagine for a moment it is. And each symbol used as a variable is bond to a value to determine if a datum matches.@kingoftheknoll so you would like a dynamic let maybe? I think code generation + eval is the only way here
yeah maybe let is a better example.
For example something like https://github.com/disalvjn/faconne does transformations on data structures using symbols to bind the intermediate values.
I’m relatively new to the clojure game and after seeing several examples of this type of symbol binding of was curious if there was a name for it. You know how it’s hard to google and learn about something if you don’t know what it’s called lol
@kingoftheknoll to me the word is pattern matching
not especially a Clojure feature
certainly
and faconne definitely works with code generation
when looking into facoone, it seems it’s building almost like an AST in it’s parser… yeah then using macros to build up the transformations.
more analogous to using symbols as map keys than a let binding
I’ll just keep digging into the source on stuff like this to learn more. Thanks @val_waeselynck
Quick question: In the docs for defn, what's that last attr-map for in the muliple arities case.
clojure.core/defn
([name doc-string? attr-map? [params*] prepost-map? body]
[name doc-string? attr-map? ([params*] prepost-map? body) + attr-map?])
Funny I just ran into that while spec'ing defn this week.
It's an additional meta map that you can supply is the multi-arity case
The thought was that meta attrs can get long and this lets you put them at the end
Never seen it in use
A question related to quote/unquote: is there a way to write a function (not a macro) that receives an expression and returns a list of the expression and its evaluation? As a constraint, this function needs not to use eval
.
A function that does the same as this macro:
(defmacro dbg [x] `(list ~x '~x))
(dbg (+ 3 4)) => (7 (+ 3 4))
The requested function should work like this:
(dbg-func '(+ 3 4)) => (7 (+ 3 4))
Any idea?
It's impossible, you need eval to evaluate an expression. Macros take code and return code to then be eval'd, so eval is still used in the macro case, just implicitly.
@viebel: what madstap said. If you used a function all it would see is 7
, so any other information is lost
I agree there is no way without eval
to have the result of a form
that's a classic example of a macro
(defmacro dbg [expr] [expr (list 'quote expr)])
viebel: ^^
oh I'm sorry I saw you were asking for not a macro
yeah functions can't access the code, that's more or less the essential difference between a function and a macro
I have an ex-info
with some data attached and I print the exception using the classic log/error
: in dev mode, not AOT, I see the data
payload in the logs...in prod mode + AOT I don't. Is it the expected behavior or I am doing something wrong myself?
sounds pretty messed up to me
I wouldn't know how 😄 So can you confirm me that I should see clojure.ExceptionInfo {:my data}
in both cases?
I don't know enough about clojure.tools.logging
one thing that comes to mind is perhaps you inadvertantly have different versions of that library running in those different environments
e.g., maybe lein deps :tree
will mention a dependency conflict