Fork me on GitHub
#beginners
<
2019-06-30
>
paulgureghian00:06:55

Clojure's typing discipline is Dynamic / Strong. I thought Dynamic is Weak, and Static is Strong.

chepprey00:06:51

Static/dynamic refers to when type checking is performed: compile time (static) vs. run time (dynamic). This is a completely separate notion from "strength". With weak typing, the language is not terribly strict about how it interprets things, while strongly typed languages are quite strict about enforcing the typing rules.

samcferrell00:06:16

in general should i be worried about repeatedly calling swap! on an atom that most of the time isn't actually changing? i suppose it probably does this check on its own without needing me to wrap the call again?

alexmiller00:06:05

Prob not worth worrying about

paulgureghian01:06:28

Is 'user=>' ever used in a .clj file ? or only in a terminal ?

seancorfield01:06:24

It's just the default prompt in the basic REPL. It shows the namespace you are in.

seancorfield01:06:19

[email protected]:~/clojure$ clj
Clojure 1.10.0
user=> (ns foo.bar)
nil
foo.bar=> *ns*
#object[clojure.lang.Namespace 0x1f38957 "foo.bar"]
foo.bar=> (in-ns 'user)
#object[clojure.lang.Namespace 0x518cf84a "user"]
user=> *ns*
#object[clojure.lang.Namespace 0x518cf84a "user"]
user=>  

paulgureghian01:06:31

Is this right ?

seancorfield01:06:02

In Clojure we use kebab-case for identifiers, not snake_case, so my-square would be more idiomatic.

seancorfield01:06:22

Each file should contain a ns declaration at the top -- (ns clojure-demo.square) should be added in this case.

seancorfield01:06:11

It's good practice to put exploratory code (such as the actual call to the square function) in a (comment ,,,) form so it won't be evaluated when the namespace is loaded (we generally avoid top-level expressions outside def / defn).

seancorfield01:06:29

If you had

(comment
  (my-square 2))
then you can put you cursor at the start of the function call and use the "evaluate block" command to send it to the REPL -- and then you'll see the result inline in the editor (as well as in the REPL panel).

seancorfield01:06:53

If you have set up the keymap, you should be able to press ctl-, b for evaluate block.

paulgureghian02:06:23

Not sure why the second function call faulted. I can pass in whatever arguments I want ?

seancorfield02:06:03

You evaluated the whole comment form instead of just the expression inside it.

seancorfield02:06:18

(comment ,,,) evaluates to nil (it didn't "fault").

paulgureghian02:06:42

I dont know. looks good to me

rick_slack03:06:07

Now, line 11 has a misplaced right paren and also needs an extra right paren.

seancorfield03:06:23

Should be

(= (rem n 2) 1) "odd")
-- move the ) to the right of the "odd"

m373h4n15:06:19

hi when I try to have new javascript object like this I got an error>

m373h4n15:06:08

in js it looks like this->

m373h4n15:06:18

isn't it same (def xxx (js/myobject)) and let xxx = new myobject

vincent.cantin16:06:33

I guess the problem is the new

vincent.cantin16:06:15

try something like (js/PIXI.Application. #js {}) to call the constructor.

vincent.cantin16:06:25

notice the . at the end

vincent.cantin16:06:21

@m373h4n also, you may use a let inside a lambda instead of a def

m373h4n16:06:03

thank you Vincent it fixed the problem. now I am now watching the video ^^

daniel.maksymow19:06:40

I have started learning Clojure 🙂

info90220:06:48

Hi 👋:skin-tone-3: