Fork me on GitHub
#clojure
<
2016-07-23
>
venantius00:07:00

Is there a way to subclass Java classes as records?

kingoftheknoll01:07:04

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?

Alex Miller (Clojure team)01:07:02

I wrote it and it goes seriously astray

Alex Miller (Clojure team)01:07:29

It's also not relevant - records can't extend a Java class

theophilusx06:07:30

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?

val_waeselynck06:07:43

@kingoftheknoll i don't understand what you are trying to do can you give an example?

isekream12:07:23

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?

anmonteiro12:07:31

@isekream: there’s a #C053K90BR channel, you might have more luck there

isekream13:07:41

sunnuva.....

kingoftheknoll15:07:41

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

val_waeselynck15:07:59

@kingoftheknoll so you would like a dynamic let maybe? I think code generation + eval is the only way here

kingoftheknoll15:07:52

yeah maybe let is a better example.

kingoftheknoll15:07:40

For example something like https://github.com/disalvjn/faconne does transformations on data structures using symbols to bind the intermediate values.

kingoftheknoll15:07:38

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

val_waeselynck15:07:40

@kingoftheknoll to me the word is pattern matching

val_waeselynck15:07:00

not especially a Clojure feature

val_waeselynck15:07:41

and faconne definitely works with code generation

kingoftheknoll15:07:58

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.

kingoftheknoll15:07:33

more analogous to using symbols as map keys than a let binding

kingoftheknoll15:07:37

I’ll just keep digging into the source on stuff like this to learn more. Thanks @val_waeselynck

madstap16:07:45

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?])

Alex Miller (Clojure team)17:07:04

Funny I just ran into that while spec'ing defn this week.

Alex Miller (Clojure team)17:07:34

It's an additional meta map that you can supply is the multi-arity case

Alex Miller (Clojure team)17:07:11

The thought was that meta attrs can get long and this lets you put them at the end

Yehonathan Sharvit19:07:58

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.

Yehonathan Sharvit19:07:54

A function that does the same as this macro:

(defmacro dbg [x]  `(list ~x '~x))

Yehonathan Sharvit19:07:46

(dbg (+ 3 4)) => (7 (+ 3 4))

Yehonathan Sharvit19:07:08

The requested function should work like this:

Yehonathan Sharvit19:07:18

(dbg-func '(+ 3 4)) => (7 (+ 3 4))

madstap20:07:00

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.

scriptor21:07:52

@viebel: what madstap said. If you used a function all it would see is 7, so any other information is lost

richiardiandrea21:07:42

I agree there is no way without eval to have the result of a form

gfredericks21:07:55

that's a classic example of a macro

gfredericks21:07:40

(defmacro dbg [expr] [expr (list 'quote expr)])

gfredericks21:07:09

oh I'm sorry I saw you were asking for not a macro

gfredericks21:07:41

yeah functions can't access the code, that's more or less the essential difference between a function and a macro

richiardiandrea23:07:36

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?

gfredericks23:07:48

sounds pretty messed up to me

richiardiandrea23:07:38

I wouldn't know how 😄 So can you confirm me that I should see clojure.ExceptionInfo {:my data} in both cases?

gfredericks23:07:39

I don't know enough about clojure.tools.logging

gfredericks23:07:01

one thing that comes to mind is perhaps you inadvertantly have different versions of that library running in those different environments

gfredericks23:07:14

e.g., maybe lein deps :tree will mention a dependency conflict