Fork me on GitHub
#beginners
<
2020-04-13
>
Jacob O'Bryant02:04:58

I went for a long time in vim just using the % key to jump between matching delimiters and generally editing forms manually. (described it here: https://jacobobryant.com/post/2020/editing-sexprs/) Now I also use vim-sexp which adds some paredit-like features.

👍 4
David Pham06:04:14

What kind of tool/logging method do you use to monitor heap size consumption of your Clojure/JVM process?

pez07:04:41

At https://clojure.org/reference/java_interop, I find this: > (set! (. instance-expr instanceFieldName-symbol) expr) > (set! (. Classname-symbol staticFieldName-symbol) expr) > Assignment special form. > > When the first operand is a field member access form, the assignment is to the corresponding field. If it is an instance field, the instance expr will be evaluated, then the expr. I am not quite following the second case there...

alexmiller12:04:25

The second case is setting a static field

pez12:04:44

Thanks. I was a bit unclear with my question, though. I mean the second case in the paragraph below: > If it is an instance field, the instance expr will be evaluated, then the expr.

alexmiller12:04:30

What’s the question?

pez12:04:15

I wonder what that second sentence in the paragraph means. 😃

alexmiller12:04:04

If you’re setting an instance field, it first evaluates the instance expression, then the value expression. It’s just what it says, so doesn’t seem unclear to me.

alexmiller13:04:41

user=> (def p (java.awt.Point. 1 1))
#'user/p
user=> (set! (. p x) 10)
10
In this example, it's just saying that p will be evaluated, then 10

pez13:04:10

Thanks! So then maybe it is the first sentence I don't get. I'll reread the docs up to that sentence and see what I have missed.

alexmiller14:04:59

I think the first sentence is talking about the second case, and the second sentence is talking about the first case

alexmiller14:04:17

or maybe the first sentence is trying to distinguish from invocation which has since been split apart, not actually sure

sogaiu07:04:32

you mean the classname case?

pez07:04:01

I mean If it is an instance field, the instance expr will be evaluated, then the expr.

pez07:04:41

Not sure if it should be interpreted as referring to the classname case, even. ¯\(ツ)

sogaiu08:04:05

i find the text confusing as well. overall though i think the purpose of the doc is to explain interop. for this case, the point has to do with how one uses set! in these situations. the second sentence of the paragraph starting "When" does not make sense if applied to the class case because there is no "instance expr" that would apply. so i think it's reasonable to deduce we are talking about the first set! form there. the first sentence does seem like it could apply to either though.

sogaiu08:04:55

ime, this type of doc is sometimes a brain dump of someone who has the implementation in mind. it could be that reading Compiler.java and looking for DOT, AssignExpr, analyze, etc. might give some insight, though that may take some time.

sogaiu08:04:30

i already spent some minutes there but my stack is currently not so spacious to take it all in 🙂

Mno10:04:21

I don't seem to understand why putting it inside of a str makes it print out the lazy sequence instead of the expected "(2 1 :b :a)" . or how to get the expected result because doall doesn't seem to work either

hindol10:04:55

str delegates to Java's Object.toString() (the right overload override). It will not force the lazy sequence.

Mno10:04:43

I thought doall would fix that though? isn't it supposed to walk through the list and make it eager?

Mno10:04:54

(see 3rd example)

hindol10:04:58

Ah, you ran it with doall too. Did not expand the snippet.

jsn10:04:31

You apply doall to the result of str

jsn10:04:56

it's a no-op, of course, since the result of str is not a lazy seq

Mno10:04:11

in the 3rd example i apply it to the result of remove

Mno10:04:19

in the 4th i apply it to the whole thing just in case

hindol10:04:25

doall does not convert the lazy seq to a list.

hindol10:04:50

It is still a lazy seq. There is no overload override for .toString() in LazySeq that will print out the contents.

hindol10:04:36

But when you dump the contents of the laze seq into a real collection like list or a vector, it will work as you expect it to.

Mno10:04:54

I guess I just thought that it had a .toString implementation because it printed out into the console correctly

Mno10:04:21

gotcha! That helped thanks a lot!

hindol10:04:28

That's the Object.toString() getting hit. Prints the type followed by the memory location I believe.

hindol10:04:55

Sorry, the last part is the hashCode.

hindol10:04:11

But the hashCode() implementation of Object just returns the memory address, so I was right.

Mno10:04:44

That might be a bit too advanced for me to use anytime soon 😅

jumar11:04:24

> But the hashCode() implementation of `Object` just returns the memory address, so I was right. That's JVM implementation specific.

hindol11:04:22

Yes, I was not advocating its use. Noone should parse the output of .toString() for whatever purpose.

Mno10:04:56

apply list seems to work, although I'd still like to understand why.

hindol10:04:31

LazySeq is not the same as a list (or a vector). The last two are real collections.

Michael J Dorian13:04:35

Is there a way to check what type of record a specific record is an instance of?

Michael J Dorian13:04:00

Aha, I found it. type! I was looking at instance? to no avail

alexmiller14:04:35

you probably want class actually

alexmiller14:04:54

but type will work too

Michael J Dorian14:04:31

Ah, cool. They seem to give the same output, what's the difference?

Timur Latypoff20:04:49

If I am not mistaken, class returns an object's underlying Java class, whereas type takes into account Clojure's dynamic custom type hierarchies, if you define or use them. Take a look here: https://clojuredocs.org/clojure.core/isa_q and its "SEE ALSO" section.

include17:04:16

Hi. Just found two active Clojure forums https://ask.clojure.org (maintained by cognitect) and https://clojureverse.org (don’t know who is behind it). Question: wouldn’t our community benefit on having only one strong forum? meanwhile which one should I use? (don’t want to start a flamewar)

didibus02:04:41

ClojureVerse is more for discussions, http://ask.clojure.org is for Q/A style and reporting bugs or feature request

👍 4
include21:04:27

thanks @U0K064KQV I will try to have that in mind.

alexmiller17:04:53

People like different stuff and have created a variety of forums, such is the internet

alexmiller17:04:04

Revel in your choices

Aron18:04:20

Or use Go lang if I don't want to learn a dozen different 3 year old libraries before I can figure out which one can be used for my goals? : )

👎 16
seancorfield18:04:24

@U0VQ4N5EE That seems like unnecessary snark and is not an appropriate response.

Aron19:04:01

I am sorry, I was not handed a book about what is appropriate here, if you let me know where these rules are rest assured that I will do my best to follow them to the letter. I also do not understand what snark is, will have to look it up in the dictionary, but I did not indented to incite emotions I merely wanted to highlight the inherent blindness in this community towards the extraordinary amount of work that it requires to join it.

👎 12
include17:04:57

ok so… it’s more an “aesthetic” thing.

FiVo18:04:41

Is there a way to exclude transient dependencies from all dependencies in deps.edn?

alexmiller20:04:11

no, that's not available right now - you can supply exclusions on a per-dep basis

seancorfield18:04:29

@include http://ask.clojure.org is more of a StackOverflow kind of thing -- and it's how feature requests and bug reports can move from community submission to JIRA and action by core/Contrib maintainers. http://clojureverse.org is more of a general discussion forum, where folks announce and discuss projects or have a back and forth about process/architecture/etc.

include18:04:15

@seancorfield great. thanks for your enlightenment. I think (as newbie) I will stick with the general discussion forum for a while 🙂

Jun Yoo19:04:11

Hello all! I was trying to go through some of the clojure tutorials and got stuck here https://github.com/ClojureBridge/drawing/blob/master/curriculum/first-program.md Problem is that when I run the code with REPL, I am getting the following error. Anyone have an idea of what's going wrong with my setup? I had followed the setup up as instructed as far as I know

user=> Execution error (ClassNotFoundException) at jdk.internal.loader.BuiltinClassLoader/loadClass (BuiltinClassLoader.java:602).
com.apple.eawt.QuitHandler

phronmophobic19:04:38

are you using java 9? does it work with java 8?

Jun Yoo19:04:23

looks like i'm running java 13. I'll try downgrading!

Jun Yoo19:04:15

Okay that worked! thanks for the help!

😁 4
grierson21:04:11

Does anybody use VSCode and clojureVScode or clover plugins? Would like to output eval results back to connected REPL not the built in VSCode output window which has no colours or pretty print

andy.fingerhut22:04:06

If you do not get an answer here, there are #vscode and #calva channels that might help

seancorfield22:04:24

Recently renamed to just #calva

andy.fingerhut22:04:04

Thanks. A bit of evidence that my memory isn't fooling me all of the time 🙂

seancorfield22:04:26

(I only found they'd renamed it when I tried to type it in 🙂 )

seancorfield22:04:58

@grierson I think Calva has superceded both of those VS Code packages -- it's getting a lot of active development and there's a #calva channel for it.