5 ms·
LIPS: Scheme based Lisp interpreter in JavaScript
- feeley 3y agoHow does it compare to https://try.gambitscheme.org https://try.gambitscheme.org ?
- jcubic 3y agoLIPS has documentation builtin into every function. You can see the docstring when you hover over the name of the symbol in the REPL. It also has auto-indent. Also if you press enter you can get back and modify previous lines of code. History doesn't repeat lines only full S-Expressions so it's easy to rerun a big chunk of code. Even though Try Gambit is a REPL it's not very user-friendly.
- feeley 3y agoThe try.gambitscheme.org web app has most of these features and more: - REPL history with up/down arrows (explained on the landing page's README) - You can use the "help" procedure to browse the full documentation - TAB key for autocompletion - In addition to the REPL there is a code editor to edit programs stored in the browser - The system supports multiple threads, one REPL per thread - There is a builtin tutorial to learn the basics of Scheme with examples executable in the REPL with a single click on a "run" button - The REPL supports single stepping the execution of code - Easy interface to JS with the SIX syntax extension, e.g. (let ((msg "hello")) \console.log(`msg, 1+2/3)) - The error messages are clear and precise giving the file and line number and highlighting in yellow the piece of code (in the REPL or file) that raised the exception. Just try this in both systems to see the difference: > (define (f x) (/ 1 (* x x))) > (f 5) > (f "hello") ;; the * procedure will raise an exception and highlight "(* x x)"
- jcubic 3y ago- in Gambit History works on lines not S-Expressions like in LIPS - With LIPS you don't need any new syntax to integrate with JavaScript you just use JavaScript directly (let ((msg "hello") (console.log msg)) SIX syntax doesn't look like Scheme. - Help popup documentation, with LIPS you have documentation directly in the REPL (when you hover over the symbol) and you can access docstring as strings and assign them to values. - You can create new syntax similar to scheme vectors and make representation the same as code - You can manipulate almost everything in the language like environments that you can modify - LIPS show stack trace not one line which gives an error that makes it easier to find where the error happens. - The Bookmarks allow to run the REPL on every page even PDF files with R7RS spec. - You can actually run the code that uses quotes (’ The apostrophe symbol) from the spec if you use syntax extension to add new syntax.
- deleted 3y ago[deleted]
- tmtvl 3y agoGambit has tail call optimisation: > (define (fib x) (let loop ((a 0) (b 1) (c 0)) (if (= c x) a (loop b (+ a b) (+ c 1))))) > (fib 10) 55 > (fib 100) 354224848179261915075 > (fib 1000) 43466557686937456435688527675040625802564660517371780402481729089536555417949051890403879840079255169295922593080322634775209689623239873322471161642996440906533187938298969649928516003704476137795166849228875
- pjmlp 3y agoLooks great, however note that it doesn't do tail calls, which are required on conforming implementations.
- jcubic 3y agoAuthor here. That's why it's not listed on the official scheme.org website as one of the implementations. I was told that to me called Scheme, you need TCO and continutations. I made one attempt to implement them some time ago but failed. The code was not working. I based my implementation on someone else code. And later turned out that the call/cc that I based my code pm was not even full continuations and failed my test case. Most Toy Scheme implementations don't have TCO and call/cc so I can't use them as a reference. But I have an implementation that is really promising that implemented them, the code is very minimal and I can base my code on that.
- tmtvl 3y agoSorry, I don't quite understand what you mean by 'doesn't do tail calls', I tried the stupid fib and it ran fine (well, okay, slowly but fine). Does it translate to JS and depend on the implementation to provide tail call optimisation/elimination?
- hajile 3y agoI suspect it does tail calls on Safari as Safari is the ONLY browser to completely implement ES6+ and implement proper tail calls (I'd note that it's not the only ES6+ compliant implementation, but most of the rest are aimed at microcontrollers or embedding).
- deleted 3y ago[deleted]
- it 3y agoI like the idea, but got this when I tried to run it on my Mac: > lips node:internal/modules/esm/resolve:853 throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), null);
- jcubic 3y agoUnfortunately, I don't have access to a Mac. I can only run Safari at BrowserStack. So I can't test it and fix it. But this is Open Source and anyone who has a Mac can test it and fix this issue. I can't.
- elwell 3y agoI like ClojureScript.
- bjoli 3y agolips> (let ((a (begin (define b 4) 5))) (+ a b)) 9 lips> b 4 I mentioned this regarding a previous version and the author said it was deliberate. I feel it breaks lexical context and is icky in general. Scheme has definition context, and loosening it is probably a good thing - but not further than "to all bodies".