Fork me on GitHub
#clojure
<
2017-09-10
>
sundarj08:09:04

are there any sexp-aware repls? not looking to learn CIDER right now, but having to edit functions line-by-line is no fun

octahedrion09:09:27

@sundarj Cursive with IntelliJ is the most popular

sundarj09:09:51

@octo221 so there's no standalone one, i take it?

octahedrion09:09:03

there are a few experimental browser-based ones but none as good as Cursive - I'd go with Cursive

darwin11:09:43

@sundarj Dirac REPL[1] has parinfer enabled by default, that’s fine for small commands, but if you wanted to send there bigger sexps you are expected to drive it externally from your IDE via nREPL, e.g. with IntelliJ+Cursive[2] [1] https://github.com/binaryage/dirac [2] https://github.com/binaryage/dirac/blob/master/docs/integration.md

sundarj14:09:13

i see. thanks!

jonas13:09:24

When type a hinting let expression, which is preferred (and is there a difference?) (let [x ^SomeType (.getValue obj)] ...) vs. (let [^SomeType x (.getValue obj)] ...)

reborg15:09:57

@jonas one is type hinting the return of (.getValue obj) the other the "x" local binding. I guess your intention is on the local binding, so the second is more appropriate. As of the practical effects in this case, they are the same.

bronsa15:09:56

eh, not exactly the same actually

bronsa15:09:33

prefer type hinting on the local

bronsa15:09:39

user=> (let [^String x (do (identity ""))] (.length x))
0
user=> (let [x ^String (do (identity ""))] (.length x))
Reflection warning, NO_SOURCE_PATH:7:37 - reference to field length can't be resolved.
0

bronsa15:09:12

if you type hint the init, and the expr is a macro/special form invocation that doesn't propagate form metadata, the type hint will be lost

reborg15:09:53

thx @bronsa definitely good to know

qqq17:09:09

I have the following problem 1. svg line, in hiccup, uses :x1 :x2 :y1 :y2 2. in a geom library I designed, I use :x0 :x1 :y0 :y1 my three choices are: 1. wrap svg hiccup, seems hacky 2. change my library to use x1 x2, y1 y2 -- I prefer 0-1 3. have abug prone translation every time Igo from "my lib" to "svg line"

dominicm17:09:00

@qqq am I not wrong in saying that svg starts at 1 index?

gfredericks20:09:19

is there an existing library that wires the java.time classes up to edn readers/printers? e.g., #local-date "2017-09-10"

hmaurer21:09:32

What “kind of thing” is d when doing (require '[datomic.api :as d])?

hmaurer21:09:10

@bronsa I hope you don’t mind me pinging you here; you might have insights on this 🙂

tbaldridge18:09:11

it doesn't exist at runtime

tbaldridge18:09:47

oh, nvm you got an answer from bronsa, gotta love Slack's scrolling (or lack of it)

hmaurer21:09:38

It’s not a var from what I gather

hmaurer21:09:56

what is it (in clojure’s internals)?

hmaurer21:09:08

and how/when is it being handled?

bronsa21:09:42

it's just an alias

bronsa21:09:53

there's no reification of aliases

hmaurer21:09:02

how is it handled by the compiler? out of curiosity

bronsa21:09:03

it's just an entry in a map from alias symbol to aliased namespace

bronsa21:09:11

see ns-aliases

hmaurer21:09:21

oh, so it just looks it up when executing an expression with an alias?

hmaurer21:09:11

and those aliases are only accessible when you are within the namespace?

hmaurer21:09:27

as in, they are local to every namespace?

bronsa21:09:31

depends on your definition of accessible

bronsa21:09:41

they are local to every namespace, yes

bronsa21:09:57

but you can look into the aliases defined in other namespaces through ns-aliases

hmaurer21:09:13

I see; thank you!

hmaurer21:09:09

(I was asking after a question in #beginners; someone was wondering why he couldn’t use aliases defined in my-namespace after executing (use 'my-namespace))

ScottStackelhouse23:09:26

When I’m generating something from a spec, how can I keep the generated structure from having super long keywords, strings, etc…

lfn301:09:05

You can limit the size of something in a spec by using s/and i.e. (s/and string? #(<= (count %1) 8)). But if you're just worried about generation, use s/with-gen instead, i.e. (s/with-gen string? #(s.gen/such-that #(<= (count %1) 8)) (s/gen string?)))

ScottStackelhouse04:09:16

Hadn't thought of that for my strings. I suppose I could do something similar for keywords, in a roundabout kind of way.

lfn304:09:47

If you don't mind me asking, why do you want to have short strings/keywords?

ScottStackelhouse05:09:49

I often spec first and generate to see how things are turning out. But it’s hard to read when keywords come up with 100+ characters.

clojer23:09:24

What’s the most efficient/fastest way to pass data from a Clojure back-end to a Node/Express server?