- /dev/head
- Введение в Common Lisp: Установка и первый запуск
- Установка
- Ubuntu
- Windows
- Первый запуск
- Ubuntu
- Windows
- Install common lisp windows
- Setup your environment
- Read about Lisp
- Start a new project
- Libraries
- Resources
- Информационный портал по безопасности
- (to-customize (to-install Common-Lisp-IDE))
- Выбор реализации Common Lisp
- Подготовительные работы
- MS Windows
- GNU/Linux
- Настройка Emacs
- Установка и настройка quicklisp
- Install common lisp windows
- 1. how to install CLISP and SBCL on MS Windows
- 1.1. Installing CLISP
- 1.2. checking if installation was successful
- 1.3. Installing SBCL
- 1.4. checking if installation was successful
- 2. Lisp modes on Emacs
- 3. how to install SLIME
- 4. some minimal SLIME customization
- 5. troubleshooting SLIME customization gone wrong
- 6. first things to know about using SLIME
- 7. looking up Common Lisp documentation
- 8. downloading Common Lisp HyperSpec (CLHS) for use in SLIME
- 9. further customization how
- 10. why the unusual way of customization
- 11. how to visually distinguish common lisp buffers from emacs lisp buffers.
- 12. further reading
- 13. some differences between CLISP and SBCL
/dev/head
Введение в Common Lisp: Установка и первый запуск
Около года назад, я заинтересовался языком программирования Lisp, по ряду причин, одна из самых веских это эффективное использование GNU Emacs. Представляю вашему вниманию ряд статей, которые будут писаться в зависиости от моего свободного времени. Почему Common Lisp, а не Emacs Lisp? Я посчитал, что лучше дать более общее представление о Лиспе, чем более узкое. Common Lisp — диалект языка Лисп, стандартизированный ANSI. Разработанный с целью привести к общему знаменателю множество существовавших на тот момент диалектов Лиспа, является скорее стандартом языка, нежели отдельной реализацией. Доступно несколько реализаций Common Lisp, как коммерческих, так и свободно распространяемых.Common Lisp включает в себя CLOS; систему Lisp макросов, позволяющую вводить в язык новые синтаксические конструкции, использовать техники метапрограммирования и обобщённого программирования.
Установка
Ubuntu
Мы будем использовать GNU Common Lisp(GCL), для того, чтобы его установить воспользуемся Центр приложений Ubuntu.
или выполнив команду в терминале:
Windows
Версию для Windows можно скачать по этому адресу
Первый запуск
Ubuntu
Приложения —> Стандартные—>Терминал В открытом окне пишем:
Получаем окно с приглашением Lisp:
Windows
Нажимаем «Пуск» и выбираем «Все программы», далее как на скриншоте.
Нажимаем на GNU Common Lisp и увидите окно с приглашение Lisp:
Install common lisp windows
If you are a newbie or you want to get started as fast as possible, then Portacle is probably your best option. Portacle is a multiplatform, complete IDE for Common Lisp. It includes Emacs, SBCL, Git, Quicklisp, all configured and ready to use.
Otherwise, Common Lisp comes in many different flavors, or implementations.
Two popular open source ones are Steel Bank Common Lisp (SBCL) and Clozure Common Lisp (CCL):
Look here for other Common Lisp compilers, including powerful commercial implementations.
You can also try Common Lisp online:
Try Lisp Online
This is a JSCL Lisp REPL running on the Web. Note that it is not a complete Common Lisp implementation, but enough to have a taste of it:
Setup your environment
A Lisp setup consists of three parts: a running Lisp instance, a text editor connected to that running Lisp instance, and project setup and libraries.
The most common way is to use Emacs and SLIME as text editor/IDE and ASDF + Quicklisp for project setup and libraries.
SLIME is an extension to the Emacs text editor that connects the editor to the running Lisp image (called *inferior-lisp*) and interacts with it. It provides lisp code evaluation, compilation, and macroexpansion, online documentation, code navigation, objects inspection, debugger, and much much more.
ASDF is the Lisp version of Make. It is used to define projects (called systems), its dependencies, and load and compile the project.
Quicklisp is a library manager for Common Lisp. Use it to download, install, and load any of over 1,500 libraries with a few simple commands.
For an introduction on how to set them all up, you can have a look at this guide.
You can also watch this video tutorial:
Watch an introductory video
Read about Lisp
A good way to learn Lisp is to go through Practical Common Lisp book.
Read our documentation for more options.
Start a new project
You may want check out the Common Lisp Cookbook for getting started on Common Lisp ecosystem.
Watch an introductory video
Libraries
Check out this list of Lisp libraries.
The easiest way to download and load libraries is via Quicklisp. Follow these instructions to get started.
Resources
«Programs must be written for people to read, and only incidentally for machines to execute.»
— Abelson & Sussman, SICP, preface to the first edition
«That language is an instrument of human reason, and not merely a medium for the expression of thought, is a truth generally admitted.»
— George Boole, quoted in Iverson’s Turing Award Lecture
«One of the most important and fascinating of all computer languages is Lisp (standing for «List Processing»), which was invented by John McCarthy around the time Algol was invented.»
— Douglas Hofstadter, Godel, Escher, Bach
«Lisp is a programmable programming language.»
— John Foderaro, CACM, September 1991
«Lisp isn’t a language, it’s a building material.»
«Any sufficiently complicated C or Fortran program contains an ad hoc informally-specified bug-ridden slow implementation of half of Common Lisp.»
— Philip Greenspun (Greenspun’s Tenth Rule of Programming)
«Lisp is worth learning for the profound enlightenment experience you will have when you finally get it; that experience will make you a better programmer for the rest of your days, even if you never actually use Lisp itself a lot.»
— Eric Raymond, «How to Become a Hacker»
«Lisp is a programmer amplifier.»
«Common Lisp, a happy amalgam of the features of previous Lisps.»
— Winston & Horn, Lisp
«Lisp doesn’t look any deader than usual to me.»
«SQL, Lisp, and Haskell are the only programming languages that I’ve seen where one spends more time thinking than typing.»
«Don’t worry about what anybody else is going to do. The best way to predict the future is to invent it.»
«The greatest single programming language ever designed.»
— Alan Kay, on Lisp
«I object to doing things that computers can do.»
«Lisp is a language for doing what you’ve been told is impossible.»
«Lisp is the red pill.»
«Within a couple weeks of learning Lisp I found programming in any other language unbearably constraining.»
«Programming in Lisp is like playing with the primordial forces of the universe. It feels like lightning between your fingertips. No other language even feels close.»
«A Lisp programmer knows the value of everything, but the cost of nothing.»
«Lisp is the most sophisticated programming language I know. It is literally decades ahead of the competition . it is not possible (as far as I know) to actually use Lisp seriously before reaching the point of no return.»
— Christian Lynbech, Road to Lisp
«[Lisp] has assisted a number of our most gifted fellow humans in thinking previously impossible thoughts.»
— Edsger Dijkstra, CACM, 15:10
«The limits of my language are the limits of my world.»
— Ludwig Wittgenstein, Tractatus Logico-Philosophicus 5.6, 1918
Информационный портал по безопасности
(to-customize (to-install Common-Lisp-IDE))
Автор: admin от 7-06-2015, 18:22, посмотрело: 1 215
Доброго времени суток, уважаемый читатель!
Перед каждым новичком в мире языка программирования Common Lisp
возникает проблема выбора среды разработки — Integrated Development Environment (далее, IDE).
Существует большое количество IDE для Common Lisp. Перечислим некоторые, самые распространенные, из них:
- LispWorks IDE (commercial, crossplatform)
- Allegro Common Lisp (commercial, crossplatform)
- LispIDE (open source, Windows 2K/XP/Vista/7)
- Lispbox (open source, crossplatform)
- Emacs + Slime (open source, crossplatform)
В данной статье я подробно расскажу как установить и настроить кроссплатформенную среду разработки для Common Lisp, как скачивать и устанавливать дополнительные библиотеки при помощи quicklisp — менеджера пакетов Common Lisp. Будет много полезных ссылок на ресурсы и материалы по языку.
Речь пойдет о связке GNU Emacs & Slime.
Если Вас интересует Common Lisp, Вам нужна кроссплатформенная, мощная, интерактивная Common Lisp IDE с блэкджеком и дамами дебаггером и дизассемблером (внезапно!), то, прошу под кат…
Выбор реализации Common Lisp
Подготовительные работы
MS Windows
GNU/Linux
/
Создаем пустую директорию
/.quicklisp/
Скачиваем файл quicklisp.lisp и размещаем его в директорию
Настройка Emacs
Откроем для редактирования файл .emacs. Поехали!
- Дадим возможность Emacs определять опреационную систему, на которой он запущен:
- Создадим переменные, содержащие путь до исполняемых файлов SBCL:
- Настроим пакетный менеджер Emacs:
Теперь, когда Вы запустите Emacs снова, то начнется автоматическая загрузка и установка пакетов:
- Slime
- Projectile
- Auto Complete
Сохраняем файл .emacs и перезапускаем Emacs.
Emacs загрузит и установит Slime, Projectile и Auto Complete автоматически в директорию
C:Users%username%.emacs.d для MS Windows и в директорию
Рано праздновать, нужно еще настроить quicklisp — пакетный менеджер Common Lisp.
Установка и настройка quicklisp
Quicklisp — пакетный менеджер языка Common Lisp.
- В запущенном Emacs выполняем команду M-x slime (Alt-x slime);
запустится среда разработки Common Lisp — Slime - Выполним:
Для примера, установим пару библиотек для Common Lisp при помощи quicklisp:
- библиотека создания графического интерфейса на основе Tk/Tcl:
- движок для регулярных выражений:
- работа с CSV форматом:
- работа с OpenGL:
- работа с БД PostgreSQL:
- Web-сервер:
- реализация метода конечных элементов (FEM):
- работа с матрицами:
- обновление установленных библиотек и самого quicklisp:
Для Common Lisp написано большое количество качественных библиотек на все случаи жизни.
При помощи quicklisp их легко установить и начать использовать.
Собственно, у Вас теперь есть все необходимое для того, чтобы с головой окунуться в мир Common Lisp!
Поздравляю!
Install common lisp windows
Goal of this article is to show that it is now easy to install these stuff on MS Windows (or at least on Windows 7 & 8). Like boiling rice, it turns out to be easy. To be fair, maybe it wasn’t easy in old days.
Readers are assumed to be long time Emacs users who are at least familiar with Emacs key notation and are assumed to be Common Lisp beginners. I will also assume you are using the latest stable version of GNU Emacs.
1. how to install CLISP and SBCL on MS Windows
CLISP and SBCL are two Common Lisp implementations. Let’s install both because choosing between jajangmyeon and jjamppong is hard.
SBCL stands for Steel Bank Common Lisp. I don’t know what CLISP stands for but you need to know that it does NOT stand for Common Lisp. (Elisp still stands for Emacs Lisp, unofficially.)
1.1. Installing CLISP
How I installed it is I downloaded the installer from
http://sourceforge.net/projects/clisp/files/latest/download
and I chose “Typical” during installation.
1.2. checking if installation was successful
Open Command Prompt and type clisp and enter. It will show CLISP REPL. Now you can type (+ 1 1) and press enter to see that it evaluates to 2.
1.3. Installing SBCL
How I installed it is I downloaded an installer from https://github.com/akovalenko/sbcl-win32-threads/wiki and ran it. There are many installers on that page and “MSI package for 32-bit Windows” is probably what you want.
( Update: the other day, I installed using an installer from the official SBCL page, and it works.)
1.4. checking if installation was successful
You may have to reboot your computer. Then open Command Prompt and type sbcl and enter, and so on.
2. Lisp modes on Emacs
Before we start, let’s get familiar with some Lisp mode names in Emacs. Vanilla Emacs provides at least three Lisp major modes:
- emacs-lisp-mode (major mode just for Emacs Lisp)
- lisp-mode (major mode for other lisp dialects)
- lisp-interaction-mode (major mode derived from emacs-lisp-mode for the scratch buffer.)
Paredit and SLIME are Lisp minor modes and they are not shipped with Emacs.
3. how to install SLIME
Update: You can also use quicklisp to install SLIME but I have not tested that way of installation. The rest of this article is tested only for SLIME installed from MELPA.
4. some minimal SLIME customization
SLIME doesn’t work out of the box.
Your Emacs init file probably has these two lines somewhere:
Now you need to put the following code somewhere after those two lines:
Then restart Emacs and create a new lisp file in Emacs. (the file name should be something like blahblah.lisp ) SLIME mode should be automatically enabled on that buffer and you should see the word Slime in the mode line. Now write the following Common Lisp code in that buffer:
Try to evaluate that form by using either C-M-x which is bound to slime-eval-defun (for evaluating a top level form), or C-x C-e which is bound to slime-eval-last-expression (for evaluating the last expression before cursor), or C-c C-r which is bound to slime-eval-region (for evaluating the selected region). Wait enough and the result of evaluation will be displayed in the echo area. Not so different from evaluating Emacs Lisp forms. When you evaluate a Common Lisp form for the first time, SLIME spends some time starting up a Common Lisp process and setting up a connection to it, and when it’s the first time starting up such a process, SLIME spend some more extra time doing some stuff. It may take a long time.
5. troubleshooting SLIME customization gone wrong
When you start changing the main structure of my example SLIME customization code, things may go wrong but don’t worry, this section might help you.
When you manually do M-x slime (which you don’t have to with my customization example) and it results in this message:
it may mean that your Emacs init file did not make sure slime-setup to be called, or that the value of inferior-lisp-program is lisp .
When you press C-M-x on a Common Lisp buffer and it says:
it may mean that SLIME mode is off for some reason or that the value of inferior-lisp-program is lisp .
When you press C-M-x on a Common Lisp buffer and it says:
it may mean that your Emacs init file did not make sure slime-setup to be called or that you forgot to do M-x slime .
6. first things to know about using SLIME
A bit of diversion first. Let’s check the four must features of Lisp editors:
- indentation
- selecting a form
- clipboard management
- inserting the closing paren automatically for you.
You indent your Common Lisp code using TAB or C-M-\ the same as usual. Selecting forms can be done by pressing C-M-SPC multiple times (after maybe moving up using C-M-u multiple times), again the same as you already do with Emacs Lisp code. For clipboard management, you are already either using Emacs’s kill ring feature or an external clipboard manager. Now the fourth thing: automatic insertion of a closing parenthesis upon your insertion of an open parenthesis. You are probably already using something for that, ParEdit or SmartParens or AutoPair or electric pair mode. If not, time to choose. I have an article on how to install AutoPair. AutoPair is stable and is a team player. ParEdit is also stable, is only for Lisp modes, and it bans you from making unmatched parens, and that’s a good thing, but some may not like that. SmartParens and electric pair mode are the new kids. If you want me to choose one for you, I choose ParEdit if you can live with three keys , , doing odd things, or if you know how to unbind those keys. End of diversion.
The key C-M-i is bound to slime-complete-symbol which is for completion of function names and so on. That is again just like when you are editing Emacs Lisp code.
Now try writing the following Common Lisp code but this time using C-M-i to help you complete dolist and print (pretend that you forgot the spelling for dolist )
Now evaluate that using C-M-x . The eval result 10 will be shown. Where’s the output from print ? The output is in the *inferior-lisp* buffer. You have to switch to it to see the output. OK, this one was a bit different from evaluating Emacs Lisp code involving print , but even in Emacs Lisp buffers, when you evaluate a form that prints a long output, you switch to the *Messages* buffer to see it. If you don’t like switching to the *inferior-lisp* buffer, you may want to try these commands: slime-pprint-eval-last-expression and slime-pprint-eval-region .
You might have noticed something happening in the echo area when you were writing the dolist form. That’s the command slime-space (bound to SPC ) showing argument lists of Common Lisp functions for you. Just like the ElDoc minor mode that you probably use with Emacs Lisp buffers. This feature only starts working after SLIME starts a Lisp connection, but you know that is guaranteed to happen when you evaluate a form or use C-M-i to complete a function name.
Try evaluating the following Common Lisp code:
Just as you expected, an error is signaled and you are now in debugger. How do you get out then? How to quit this debugger? You should see a new submenu in the menu bar: SLDB. That stands for SLime DeBugger mode. From that submenu, you can find a way to quit the debugger. Or if you have time, you can press C-h m to start learning how to use SLDB.
7. looking up Common Lisp documentation
When you invoke the command slime-documentation-lookup (bound to C-c C-d h and a menu item), it will look up the documentation for symbol at point and open the web page for it.
8. downloading Common Lisp HyperSpec (CLHS) for use in SLIME
You don’t have to download it to look things up, but if you want offline access, you can download it from LispWorks Downloadable Documentation.
To connect your downloaded documentation to SLIME, extract the downloaded archive and you will get a folder with name Hyperspec , and then you move that folder to the Emacs bin directory, or its parent directory, or its grandparent directory, Put the following code in Emacs init file.
and add my-hyperspec-setup to my-slime-setup like this:
and restart Emacs.
Now when you invoke slime-documentation-lookup it will open the local web page instead.
9. further customization how
When you see this from others code
the right way to replicate that in your own Emacs would be to add the relevant part to my-slime-setup like this:
10. why the unusual way of customization
The reason for the odd way of invoking my-slime-setup in my code is so that my-slime-setup gets called when you open a Common Lisp file the first time and not during Emacs startup. This is so that my code does not slow down Emacs startup.
11. how to visually distinguish common lisp buffers from emacs lisp buffers.
You can put this in your init file to make parenthesis of Common Lisp code (and Scheme and Clojure) to be a bit red to distinguish Common Lisp buffers from Emacs Lisp buffers.
Or you may want to do the other way around.
12. further reading
13. some differences between CLISP and SBCL
Doubly nested backquote forms are handled in different but still CLHS-compatible ways. See CLHS “innermost backquoted form should be expanded first” meaning – Stack Overflow to see how two seemingly different ways may be equivalent in a way after all.