paulfitz / cosmicos

Sending the lambda calculus into deep space
https://cosmicos.github.io/
GNU General Public License v2.0
134 stars 8 forks source link

Problem with brackets of commands in `cosh.js` #18

Closed joha2 closed 8 years ago

joha2 commented 8 years ago

The following code throws an error in cosh.js

cosmicos> (< 3 4)
1
cosmicos> (< 4 3)
Problem with 0 (intro)

whereas the code without the outer brackets works:

cosmicos> < 3 4
1
cosmicos> < 4 3
0
paulfitz commented 8 years ago

Thanks for reporting this!

Is this with the current version of cosh.js? I'm seeing:

paulfitz@short:~/cvs/cosmicos/build$ ./bin/cosh.js 
[See http://cosmicos.github.io/evaluate.html for help]
cosmicos> (< 3 4)
1
cosmicos> (< 4 3)
0
cosmicos> < 3 4
Problem with 3 (=)

Not saying that's necessarily better, just checking on version.

Just in case, can you do make clean; make cli in your build directory?

joha2 commented 8 years ago

I did a completely new clone and build yesterday before reporting this bug (because my fork is modified and is still not up to date due to several modifications and tests).

At least the message is now in a correctly encoded form. Therefore the encoding bug is removed and it is newer than my fork. :-)

On which OS tools does cosh.js rely? node.js?

joha2 commented 8 years ago

Also a make clean; make cli did not help :-(

paulfitz commented 8 years ago

Still not able to replicate, here's what I get:

$ git clone git@github.com:paulfitz/cosmicos.git
Cloning into 'cosmicos'...
remote: Counting objects: 1572, done.
remote: Total 1572 (delta 0), reused 0 (delta 0), pack-reused 1572
Receiving objects: 100% (1572/1572), 2.27 MiB | 61.00 KiB/s, done.
Resolving deltas: 100% (912/912), done.
Checking connectivity... done.
paulfitz@short:~/tmp/cos$ cd cosmicos/
paulfitz@short:~/tmp/cos/cosmicos$ mkdir build && cd build && cmake .. && make cli
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found Java: /usr/bin/java (found version "1.7.0.79") 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/paulfitz/tmp/cos/cosmicos/build
Scanning dependencies of target cli
[  0%] Generating CosmicEval.js
[100%] Generating ../bin/cosh.js
[100%] Built target cli
paulfitz@short:~/tmp/cos/cosmicos/build$ ./bin/cosh.js 
[See http://cosmicos.github.io/evaluate.html for help]
cosmicos> (< 3 4)
1
cosmicos> (< 4 3)
0

Yes, cosh.js relies on node. Hmm, via node, it relies on node's repl module. I can check if I'm doing something version-sensitive with that.

paulfitz commented 8 years ago

I suspect this line to be the culprit: https://github.com/paulfitz/cosmicos/blob/master/tools/repl/repl.js#L11

I assume it is there to strip parens, but it isn't being done very carefully. If anything related to end-of-line characters has changed it could be doing damage. Will investigate.

paulfitz commented 8 years ago

Confirmed, this is a node version problem. In earlier versions, node wraps input in parens, in later versions, it doesn't. Thanks for asking about node, it was a good lead.

paulfitz commented 8 years ago

@joha2 I think this should be resolved now, please reopen if not.

joha2 commented 8 years ago

I think it's solved, thank you @paulfitz

[See http://cosmicos.github.io/evaluate.html for help]
cosmicos> (< 3 4)
1
cosmicos> (> 3 4)
0
cosmicos> < 3 4
1
cosmicos> > 3 4
0