哪里可以学习如何实际使用 Common Lisp

发布于 2024-12-01 23:55:17 字数 1539 浏览 1 评论 0 原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

辞取 2024-12-08 23:55:17

我建议阅读“实用 Common Lisp”,因为它已经回答了您的一些问题。

您可能应该阅读三到四本书

Common Lisp 参考

手册

现在您应该检查的下一件事是Lisp 实现手册。它描述了许多特定的扩展:网络、线程……

Common Lisp 实现的文档:

SLIME (基于 Emacs 的 Lisp-IDE)有一个 SLIME 用户手册

Common Lisp 库的文档:

对于库,请使用

现在看看您的一些观点:

  • 如何读取文件

请参阅 HyperSpec 中的文件和流字典。 WITH-OPEN-STREAM, READ, READ-LINE, READ-CHAR, READ-BYTE, READ-SEQUENCE, ...

  • 如何读取文件、替换文件中的单词并将结果写回文件

使用上面的内容。另请参阅:WRITE 及相关内容。

  • 迭代目录中的文件和其他文件系统内容

请参见上文。目录、路径名...

  • 与 SQL 数据库交互

例如使用 CLSQL 库。

  • 通过套接字进行通信

请参阅 Lisp 手册或使用可移植库之一。参见 Quicklisp。

  • Web 服务器之类的线程

请参阅 Lisp 手册或使用可移植库之一。参见 Quicklisp。

  • 创建 GUI

取决于。请参阅 Quicklisp 或特定于实现的库。

  • 对二进制文件执行操作

有关文件和流操作,请参阅 Hyperspec。写字节,读字节。将流作为二进制流打开。

  • 编写一个解析器(不是 Lisp 中的 Lisp 解释器,据我所知,它就像 5 行 Lisp)

使用现有的工具之一。研究现有的解析器。有许多解析器是用 Lisp 编写的,但关于这方面的书籍却很少(除了人工智能文献中描述的自然语言解析器)。

  • 与操作系统交互(即用 C 或 C++ 编写的东西)来完成 Lisp 本身无法完成的事情

取决于。请参阅 Quicklisp 或特定于实现的库。

  • 如何用 C 语言编写 Lisp 扩展(可能吗?)

取决于情况。请参阅 Quicklisp 或特定于实现的库。 -> FFI

最终建议:阅读其他作者的代码。

研究其他 Lisp 代码。那里有足够多的非常多样化的 Lisp 代码。从网络服务器到音乐创作软件。

I would propose reading 'Practical Common Lisp', since it already answers some of your questions.

There are probably three to four books you should read:

Common Lisp Reference

Manuals

Now the next thing you should check out is the manual of your Lisp implementation. It describes a lot of specific extensions: networking, threads, ...

Documentation for Common Lisp implementations:

SLIME (the Emacs-based Lisp-IDE) has a SLIME User Manual.

Documentation for Common Lisp libraries:

Libraries

For libraries use

Now looking at some of your points:

  • How to read files

See the files and streams dictionary in the HyperSpec. WITH-OPEN-STREAM, READ, READ-LINE, READ-CHAR, READ-BYTE, READ-SEQUENCE, ...

  • How to read a file, replace words in the file, and write the result back to the file

Use above. See also: WRITE and related.

  • Iterate the files in a directory and other filesystem stuff

See above. DIRECTORY, pathnames, ...

  • Interact with an SQL db

Use for example the CLSQL library.

  • Do communications over sockets

See the manual of your Lisp or use one of the portable libraries. See Quicklisp.

  • Threading for stuff like a webserver

See the manual of your Lisp or use one of the portable libraries. See Quicklisp.

  • Create GUIs

Depends. See Quicklisp or an implementation specific library.

  • Perform operations on binary files

See Hyperspec for file and stream operations. WRITE-BYTE, READ-BYTE. Open a stream as a binary stream.

  • Write a parser (not an interpreter for Lisp in Lisp, which as I understand is like 5 lines of Lisp)

Use one of the existing tools for that. Study existing parsers. There are many parsers written in Lisp, but not much in books about that (other than natural language parsers, which are described in the AI literature).

  • Interact with the operating system (i.e. stuff written in C or C++) to do stuff Lisp can't do natively

Depends. See Quicklisp or an implementation specific library.

  • How to write Lisp extensions in C (is that possible?)

Depends. See Quicklisp or an implementation specific library. -> FFI

Final advice: Read code from other authors.

Study other Lisp code. There is enough very diverse Lisp code out there. From web servers to music composition software.

泪之魂 2024-12-08 23:55:17

查看 Cliki the Common Lisp wiki 它提供了可用于 Common Lisp 的库列表,这将帮助您完成您的所有物品。

另外,您还需要查看Common Lisp Cookbook(还有更多< a href="https://lispcookbook.github.io/cl-cookbook" rel="nofollow noreferrer">更新版本)。它有一堆用于常见任务的代码,例如一次读取一行文件< /a> 和用于与用 C 编写的库交互的外部函数接口

您可以用 C 语言编写 Lisp 扩展,具体取决于您使用的实现。例如,Emacs-Lisp 允许您这样做,尽管它不是 Common Lisp。通常您想要做的是用 Common Lisp 编写代码,然后使用不同的 Lisp 编译器声明或使用外部函数接口的其他方法尽可能地对其进行优化。

线程取决于您使用哪种实现,但我认为现在大多数都有线程。

Hunchentoot 是最好的 Lisp Web 服务器之一,而且非常容易上手。您不必自己编写任何线程代码,只需编写 HTTP 请求处理程序函数即可。

有人编译了Lisp 的 GUI 选项列表

  • 的接口
  • cl-gtk2,GTK gui 库McClim
  • Garnet
  • Common Qt
  • EQL

Check out Cliki the Common Lisp wiki it provides a list of libraries available for Common Lisp which will help you accomplish all your items.

Also, you're going to want to check out the Common Lisp Cookbook (there's also a more updated version). It has a bunch of code for common tasks such as reading a file one line at a time, and Foreign Function Interfaces for interacting with libraries written in C.

You can write extensions for Lisp in C depending on which implementation you're using. Emacs-Lisp for example allows you to do that though it isn't Common Lisp. Usually what you want to do is write the code in Common Lisp and then optimize it as much as possible using different Lisp compiler declarations, or the other method where you use a foreign function interface.

Threading depends on which implementation you use, but I think most of them have threads now.

Hunchentoot is one of the best Lisp web servers and is pretty easy to get started with. You don't have to write any threading code yourself, you just have to write the HTTP request handler functions.

Someone compiled a list of GUI options for Lisp:

  • cl-gtk2, an interface to the GTK gui library
  • McClim
  • Garnet
  • Common Qt
  • EQL
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文