Using MIT/GNU Scheme - scheme

I have downloaded the MIT/GNU Scheme implementation of LISP in order to understand Structure and Interpretation of Computer Programs. However, I am a bit confused about what I am dealing with when I launch the program. When the program is launched, I get two windows: the "MIT/GNU Scheme" window, and the "Edwin: *scheme*" window.
What are these two windows used for? Is the "MIT/GNU Scheme" one some sort of command-line interpreter? While the other is where code can be written and saved?
Further questions: If the MIT/GNU Scheme is a command-line interpreter, how can I get the "1 ]=>" prompt to show. And if the other is where I write programs, how do I test and save the programs?

MIT/GNU Scheme should start off as minimized. It is just a background console window that starts the editor. You need not pay attention to it (nor can you interact with it).
Edwin: *scheme* is the Edwin text editor, which looks to me like some sort of Emacs derivative. It allows you to not only write Scheme scripts but also evaluate Scheme expressions interactively. However, to do this you will need to learn the appropriate keybindings and commands, and some familiarity with Emacs would certainly help here too. Therefore I suggest reading the documentation.

Related

How do I run a scheme script from notepad++/cmd/powershell?

In python, I add python and the path of the file, and my script will run.
In haskell, I invoke the GHC compiler on my file to make an executable, or I load GHCi and load the path of the file to use functions, and my script is running.
In Scheme, neither type of approach works for me. Everywhere I search, I only hear about emacs and SLIME. I am not interested in either. I just want to write scripts in notepad++ or any other simple text editor, and either run them through a scheme interpreter, or compile it into an exe, for the purpose of testing code from the MIT SICP book.
I installed MIT/GNU Scheme for learning purposes. I am not interested in Racket because of how different it is from Scheme now (I don't want to confuse myself further, I just want to learn the basics.)
One thing that is contributing to my confusion is the following. When I open mit-scheme through the start menu shortcut, it opens the edwin editor (its tutorial (C-h t command) is apparently "corrupted" so I can't use that instead of notepad++ nor would I want to at this point (just too frustrated with it)). The file location for the edwin editor is in the bin folder. The bin folder though, only has 2 files: mit-scheme.exe and dibutils.dll. If I double-click on mit-scheme.exe it just gives me an error, but apparently using the shortcut opens the edwin editor (that is supposed to be located in the same folder as mit-scheme.exe (it isn't)).
Why is all of this so convoluted? Isn't there a simple way to get my scheme scripts running? I just want to run things like:
(define hello-world
(lambda ()
(begin
(write ‘Hello-World)
(newline)
(hello-world))))
Searching for solutions online was futile for me, I've already wasted many hours- so hopefully I can finally get an answer here.
Thank you.
EDIT: I am on windows 7 and *nix operating systems isn't an option.
mit-scheme has the --load switch. thus
mit-scheme --load path/to/script.scm scrip2.scm -- args ...
I think you also can use Racket to run standard r6rs like this:
plt-r6rs script.scm
For r5rs there is plt-r5rs. Racket can also make executables that run faster with raco exe script.scm.
EDIT
BTW: plt-r6rs is for running programs using the standard R6RS scehem report. plt-r5rs is for running programs using the standadr R5RS scheme report. I have no idea what you mean by "different it is from Scheme". Racket has it's own language, which is the default, which is it's own incompatible dialect of Scheme, but it is not a reason for not using the software. It's like not using gcc because it supports a non standard C++ language and ignoring that you can get ot to behave standard with switches.
There is only one R7RS-small implementation, the reference implementation chibi scheme. Every imlpementation is waiting for the full R7RS report I guess so it's R6RS which is the current standard.
The lists in R5RS and R6RS are mutable (but in R6RS you need to import (rnrs mutable-pairs), but thats a part of the standard. Try not import racket libraries from the standard schemes unless you have no other choice. Check the SRFIs first.
There are not so many Scheme versions and scheme implementations. For every popular programming language that has been for at least 10 years there are more than 3 implementations and several incompatible versions of the standard. If you think there are few implementations of the languages you mentioned you are quite wrong. Python has many implementations and incompatible standard versions. Haskell also has many implementations and versions of their standard. Scheme is from the 70s so it's been around for 40 years so it's only natural that there are more versions of Scheme than Haskell and Python.
This is how I was able to run scheme code from notepad++,
I put to notepad++ run configuration:
"C:\Program Files (x86)\MIT-GNU Scheme\bin\mit-scheme.exe" --heap 512 --library "C:\Program Files (x86)\MIT-GNU Scheme\lib" --load "$(FULL_CURRENT_PATH)"
and then I was able to run. However, I had to save file first, otherwise it is not running. Also notice that (+ 2 2) is not printing as a result, But If I call procedures it is working fine.
sample

REPL with features of modern shell

I am creating a script (in Lisp, though this can apply to any language with a REPL) which users interface with using the language's REPL. But this does not include even basic interactive features like remembering history. I am wondering if it is possible to tell a terminal emulator to interpret commands using an arbitrary language, instead of the built-in language.
Thanks!
OK, follwoing the advice of user2864740, I looked at GNU Readline, which is the library the provides much of the functionality that I'm looking for. I'm going to switch to Guile Scheme instead of Common Lisp since Guile supports Readline out of the box. However, it looks like it can work in Common Lisp as well: http://www.cliki.net/sb-readline
Yet another approach might be to start the editor emacs, run
M-x shell
and in this shell run your Lisp REPL. You get a lot of feature for free, like command history.

Does Mac OS X come with a Lisp environment built in with Emacs?

I have been trying to find an environment that does not involve installing anything else on my mac for Lisp, as I will not be using it after I get the homework done (who know if I continue using it). I have tried to look but I can't find anything. Anybody know if it does have it, and how to use it within Emacs?
You have a few options for one-click Lisp environments.
If you prefer an Emacs-based environment, check out LispBox. This actually installs a separate instance of Emacs, afaik, so you probably won't have your existing Emacs settings with it.
If you want to use your existing Emacs, SLIME is available both through quicklisp (which you really should be using) or through ELPA.
If you're ok with not having an Emacs environment, and you're not going to be using the language for long, look into LispWorks personal, which has a one-click environment installer in OS X.
If you were actually asking about Scheme (or could go for either Scheme or Common Lisp), take a look at Racket (not technically a Scheme, it actually has a lot of additional features, but they do support R5RS and have a fairly short list of unsupported R6RS features).
Emacs Lisp is rather different from regular Lisp, so it's probably not directly useful for classes or self-study if your target is something like Scheme or Common Lisp. But yes, Emacs has its own Lisp interpreter (or rather, is its own Lisp interpreter). You might want to read up on the differences between Emacs elisp and other dialects / variants to determine whether it might suit your needs.
Clozure CL is a available for free from the Mac App Store
http://itunes.apple.com/us/app/clozure-cl/id489900618?ls=1&mt=12
Have you checked Ready Lisp ?
Also have a look at here.

compile/run Common LIsp from the Mac Terminal

Is there a way to do this? I've been using Slime to learn Lisp, and I would like to start building larger projects which means (I think) that I would have to start writing some .lisp files.
I think your best bets for Mac Common LISP are the LispWorks Personal Edition or SBCL.
Assuming you've got SBCL installed, you can create a .lisp file using a text editor (emacs would be the traditional choice):
(defun test ()
"Hi!")
Then you can run a lisp interpreter in a shell:
bash% sbcl
This is SBCL 1.0.29, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
* (load "test.lisp")
T
* (test)
"Hi!"
*
The shell could either be a mac terminal window or an inferior lisp interpreter running in emacs.
Slime is designed to support writing Lisp files, including definition finding, online documentation, name completion, compilation, and more. Perhaps you should take a look at the manual, chapter 3 (using slime-mode).
I think it is a bit hard to tell what you are really asking for.
You can compile and load a whole Lisp file in Slime by using C-c C-k in the buffer, and then use it from within the Slime REPL, so you don't even have to run LOAD in the REPL.
Then, there are solutions for shebang lines known from unices that will work in the OS X shell, if you want to run your Lisp programs as scripts from the command line, but those differ from implementation to implementation.
A possibility for building executables, which then can be run from the command line, is loading the relevant code into your Lisp image, then saving that image with the loaded code. Those images may be made executable, executing a given function on startup (think main). This possibility also differs for implementations, so without mentioning your implementation of choice, you will have to look it up in its documentation.
Now, since you are asking about "building larger projects" specifically, my advice would be to get acquainted with a system definition facility. A lisp system basically is a kind of "project", a few files with code, package definitions, and a system definition. I will give you a little example for ASDF, which is (as far as I can tell) the most popular one in the open source world.
(defsystem my-system
:name "my-system"
:version "0.0.1"
:author "hedgehogrider"
:license "BSD"
:description "bla bla bla"
:serial t
:components ((:file "packages")
(:file "code")))
Now, you would put this in an asd file, say my-system.asd, put your package definitions in packages.lisp, your functionality in code.lisp, and then, given you set up ASDF properly, you would be able to compile and load your system in the Slime REPL by pressing ,l my-system. Alternatively, you could enter (asdf:oos 'load-op 'my-system) (or, for more recent versions of ASDF: (asdf:load-system 'my-system)) at the REPL.
In order to make this work, you will have to install ASDF for your Lisp implementation, if it is not shipped with it, and the directory containing your asdf-files will have to be put in asdf:*central-registry*. One easy solution is to symlink your asdf-files to one central directory, but there are other possibilities. Check the ASDF documentation or other tutorials to learn more about ASDF.
Yes, you will want to write your own Lisp files instead of relying on images.
I recommend CLISP for OSX for an out-of-the-box experience. It has a nice REPL experience.
Professional development done with F/OSS today generally uses SBCL or CCL.

What other OCaml top level programs exist? (Vista)

I'm using OCamlWinPlus v1.9RC4. It sucks pretty hardcore. It's constantly crashing, and lacks basic features. What other toplevel OCaml programs can be recommended for Windows Vista?
You can use a Windows version of Emacs and use the customization files (*.el) provided with OCaml's source archive to turn Emacs in a powerful, if idiosyncratic, toplevel.
You'll find the instructions in ocaml-3.11.1/emacs/README. Specifically:
Once you have started caml by M-x run-caml:
M-C-x send phrase to inferior caml process
C-c C-r send region to inferior caml process
C-c C-s show inferior caml process
C-c` goto error in expression sent by M-C-x
I used ocaml from cmd. Editing with history is there..
Can you elaborate on ocamlwinplus crashes? Did you try to debug it?
I use Notepad++ to write code then I compile it from cmd, simply there is no simple way to do it with OCAML!

Resources