Fork me on GitHub
#clojure
<
2018-09-30
>
kulminaator10:09:12

anyone running clojure on 64bit arm cpus ? (something like the latest raspberry pi , enhanced beagleboard or olimex' olinuxino A64 ? ) . there supposedly is a java 8 out for these , but would like to hear if anyone has had success on these ?

Bobbi Towers10:09:50

Works great on my Pi 3 and Zero W, but they're both 32bit OS (even though the Pi 3 is 64bit CPU)

kulminaator10:09:07

zero w having only 512mb of ram, doesn't that get a little restrictive ? and what java are you using there 🙂

Bobbi Towers10:09:30

Java 8, and yeah it struggles considerably if you ask it to do too much

Bobbi Towers10:09:06

I'd really like to use Planck on there, but couldn't get it working

lincpa11:09:02

is it a bug of Clojure 1.10.0-alpha8? (import 'java.sql.Date) (import 'java.util.Date) Exception in thread "main" Syntax error compiling at Cause: Date already refers to: class java.sql.Date (ns t (:import [java.sql JDBCType Types Date] [java.util.Date])) ;Caused by: clojure.lang.ExceptionInfo: ;Call to clojure.core/ns did not conform to spec.

Digital Baboon16:09:01

Can anyone recommend a style guide to writing Clojure? I'm having hard time keeping things consistent.

Digital Baboon16:09:03

Is that the "globally" recommended one?

jacekschae16:09:16

it's the community driven one

jacekschae16:09:42

you can also add to your editor cljfmt and don't worry about doing it manually

Digital Baboon16:09:45

Oh nice, there's a VSCode plugin. Thank you!

jacekschae17:09:05

for VS i would recommend to use calva - the main package has this build in

jacekschae17:09:15

and you can also install the formatter only

andy.fingerhut17:09:55

@im Just about any experienced Clojure programmer will disagree with one or more of the recommendations in that style guide, but likely they would agree with far more of them.

4
Digital Baboon17:09:34

Alright, as long as it's a good starting point I'm happy

Digital Baboon17:09:16

Hm. Using any of the formatting plugins and setting "format on save" to true, on saving a file I get ompilerException java.lang.IllegalAccessError: reader-error does not exist, compiling:(clojure/tools/reader/edn.clj:1:1).

andy.fingerhut17:09:18

Sounds like that "format on save" option is expecting the contents of the file to be correct EDN syntax (i.e. balanced parens, square brackets, curly braces, etc. strings end before the end of file), but your file violates what it expects.

andy.fingerhut17:09:46

or looking at the error message more carefully, the code for doing that has a version mismatch in Clojure or library versions

andy.fingerhut17:09:54

Does it give that error for any Clojure file you try to save, even a very short simple one that has no mention of a symbol called reader-error ?

hlolli18:09:23

what's up with these clauses

(defrecord A [])
(defrecord B [])
(def a (->A))
(case (type a)
  A "correct"
  B "false")

;; => IllegalArgumentException No matching clause: class ....

mfikes18:09:25

You’d probably have to use cond instead. In case those test constants are symbols.

hlolli18:09:01

yup, thought tough the symbols would be able to be compared, with = it's true.

joelsanchez18:09:52

a common idiom is condp =, or just a map

hlolli18:09:30

that's a hat trick condp =, case is strange sometimes.

hlolli18:09:36

nice thanks

mfikes18:09:26

(case 'A
 A "correct"
 B "false") 

👍 4
onetom18:09:39

is the source code available somewhere for this @ericnormand test.check talk: https://lispcast.com/testing-stateful-and-concurrent-systems-using-test-check/ ? if it's part of a course, i would be interested to get it too, because im curious about the async testing aspect. i found [test.carly](https://docs.google.com/presentation/d/1H8HqX414dhqCjHm-uxXAlq30pok_-ntPqVWvmLgdsNE/pub#slide=id.g1bce075829_0_7) which seems to carry the concept further, but i would like to see a simpler example, to understand it better/easier.

tristefigure21:09:30

Love that John McAffee kind of look aha:gun:💊

ericnormand01:10:28

I didn't keep the code for it, other than what is in the slides

ericnormand01:10:46

and I don't have a course on it yet

ericnormand01:10:58

but I'll mark you down as a vote for that one

4
ericnormand01:10:06

I would love to do a course because I love generative testing

roklenarcic20:09:06

I'm not entirely sure I understand how setting vars work

roklenarcic20:09:30

I use set! to set a dynamic var

roklenarcic20:09:07

and I get exception Caused by: java.lang.IllegalStateException: Can't change/establish root binding of: *explain-out* with set

seancorfield20:09:21

@roklenarcic See https://clojure.org/reference/vars#set -- it's to do with threads. But for *explain-out* and other, similar dynamic vars, you should use binding instead.

roklenarcic07:10:56

But I want to set *explain-out* globally, not just for my thread and I don't want to wrap every line in REPL in binding.

seancorfield20:09:49

In Clojure you pretty much never assign to a var (which is what set! is).

seancorfield20:09:25

There are some situations where you might use alter-var-root (e.g., setting up Component in a way that's REPL-friendly), but set! is pretty rare (although you'll see (set! *warn-on-reflection* true) at the top-level in source code to turn on reflection-checking in the compiler).

beta103621:09:15

does anybody know the reasoning for the following behaviour?

user> (:x {:x 1})
1
user> (:x (java.util.HashMap. {:x 1}))
1
user> (:x #{:x})
:x
user> (:x (java.util.HashSet. #{:x}))
nil

seancorfield22:09:15

@beta1036 I'd have to go look at the source to be sure but I suspect (:x coll) expects coll to be associative and have a get method of some sort -- which java.util.HashSet does not. However, you can use contains? with both a Clojure set and a Java HashSet: (contains? #{:x} :x) => true and (contains? (java.util.HashSet. #{:x} :x) => true

seancorfield22:09:11

@beta1036 Now I've looked at the code... (kw coll) ends up here https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L758-L781 if coll is not an instance of clojure.lang.ILookup (which would then call coll.valAt( kw ))

seancorfield22:09:55

So it supports instances of java.util.Map, clojure.lang.iPersistentSet, and clojure.lang.ITransientSet (or if a string or array is indexed by a number). It doesn't support java.util.Set.

beta103620:10:08

I've seen this in the code, and wanted to know the reasons for it being this way. I was surprised that keywords can take sets, and even more surprised that they can only take IPersistentSet or ITransientSet whereas java.util.Map is supported.

beta103620:10:18

Is there an idiomatic use for applying a keyword to a set?

seancorfield20:10:15

@beta1036 (Clojure) sets are associative on their keys -- like a map whose values are the same as their keys -- so you can call "get" on them. Java sets don't have that associative lookup -- only a "contains" operation. That would be my understanding of why you can lookup keywords in (Clojure) sets but not Java sets.

seancorfield20:10:40

(and arrays are associative on their indices -- so, again, it makes sense to allow lookup "get" on those)

seancorfield20:10:20

Does that make sense?

beta103620:10:15

Having get on maps, sets and arrays makes sense to me.

beta103620:10:50

It would make more sense to me if keyword application either supported java sets or not supported any sets at all. And of course supporting keyword application on vectors makes no sense at all.

beta103620:10:22

The fact that java sets don't have a get operation seems like a weak excuse for not supporting them.

beta103620:10:11

But I'm not complaining, since I don't have any use for applying keywords to sets at the moment. 🙂

seancorfield21:10:49

Clojure is based on abstractions. map, set, and vector are associative in Clojure, hence should all support get. Java's Map is associative, Java's Set is not.

seancorfield21:10:53

Re: keyword on vector -- vectors are associative on their index so, no, Clojure does not support keyword lookup on them. (kw coll) is "the same" as (coll kw) which is "the same" as (get coll kw) and for vectors (coll ix) is the shorthand.