Fork me on GitHub
#chlorine-clover
<
2020-08-04
>
Rowan Barnard23:08:21

Was just working through some exercise in the Olsen's book Getting Clojure in Chlorine and when I tried to submit one of the forms for evaluation nothing happened

Rowan Barnard23:08:50

Here is the code that I was working on: (def ISBN-LENGTH 13) (def OLD-ISBN-LENGTH 10) (defn valid-isbn [isbn] (or (= (count isbn) OLD-ISBN-LENGTH) (= (count isbn) ISBN-LENGTH)))

Rowan Barnard23:08:51

I then type (valid-isbn 05967) to test it out (not realizing at the time that count doesn't work on a number) and when I attempt to submit with Sean Corfield's Ctrl+;Shift+B (the Atom keymap for REBL Top Block) then nothing happens, I don't get any result, any error message or anything

Rowan Barnard23:08:50

If I type (valid-isbn "05967") and submit for evaluation it works as expected, so not sure why using a number as the argument results in nothing happening - is this some protection mechanism to prevent me entering incorrect inputs?

phronmophobic23:08:38

05967 isn't valid in clojure (number literals can't start with 0). however, valid-isbn won't work on numbers because count only works on collections and a number is not a collection

Rowan Barnard23:08:49

OK but shouldn't it still evaluate and blow up with an exception?

Rowan Barnard23:08:16

Or at least print some message as to why it won't run

Rowan Barnard23:08:30

I submit it and just nothing happens at all

phronmophobic23:08:11

unfortunately, I'm not familiar with chlorine and rebl integration

Rowan Barnard23:08:27

I thought Atom was hanging or I'd accidentally pressed something to make it switch to some other mode or something like that but when I type in other things it still submits and evaluates as normal

Rowan Barnard23:08:22

Thanks for the input anyways phronmophobic 🙂

phronmophobic23:08:39

typing 05967 is a parse error, which might be treated differently than other types of errors

phronmophobic23:08:15

maybe you'll get the same non-result if you type {(:1

Rowan Barnard23:08:17

OK yes I just tried without leading zero

Rowan Barnard23:08:39

It evaluates and throws exception for using count on a number

👍 3
Rowan Barnard23:08:23

Still I think there should be a message for using a leading zero?

Rowan Barnard23:08:48

It seems not right to do absolutely nothing so maybe a bug?

phronmophobic23:08:17

agreed. I wouldn't be surprised if the author just never noticed because they never tried to evaluate something that wouldn't parse

seancorfield23:08:09

It doesn't work with the built in eval either -- not just via my wrapped eval.

Rowan Barnard23:08:39

OK so is that a Chlorine bug then?

seancorfield23:08:36

I guess so. As @smith.adriane says, I suspect most of us have never noticed because we haven't tried to evaluate code that won't read.

seancorfield23:08:17

If you type that into a bare REPL, it can't even be read -- so it fails before evaluation.

seancorfield23:08:21

user=> 05967
Syntax error reading source at (REPL:18:0).
Invalid number: 05967

Rowan Barnard23:08:22

Ha ha yeah I guess only noobs like me find this stuff 😂

Rowan Barnard23:08:01

OK but at least you get a message in the bare REPL

seancorfield23:08:40

In particular:

user=> (no-such-function 05967)
Syntax error reading source at (REPL:18:25).
Invalid number: 05967
Syntax error reading source at (REPL:18:26).
Unmatched delimiter: )
user=> 
note that it a) doesn't complain about no-such-function not existing and b) doesn't even read the closing ).

seancorfield23:08:57

^ That's just to illustrate how early in the read-eval-print process it fails @flyingpython

mauricio.szabo23:08:14

Hi, well, there are a few tests to fail unparseable code, but maybe something escaped :D

Rowan Barnard23:08:37

OK thanks for the info, would be interesting to learn more about the different steps involved in the REPL process

mauricio.szabo23:08:46

Can you open an issue with the code that's failing? Will look at it very soon :)

Rowan Barnard23:08:20

OK cool will do! Can it wait for couple hours though? Just gotta whip out for some lunch 🙂

seancorfield23:08:11

Don't worry, the bug will still be there when you get back! 🙂

😆 6
Rowan Barnard23:08:26

Hang on, I'm entering bug now, still got some time