paulfitz / cosmicos

Sending the lambda calculus into deep space

Home Page:https://cosmicos.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem with brackets of commands in `cosh.js`

joha2 opened this issue · comments

commented

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

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?

commented

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?

commented

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

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.

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.

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.

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

commented

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