⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme

📁 A very small LISP implementation with several packages and demo programs.
💻
字号:
Porting Pico Lisp to CygwinA few months back, I was looking at Lisp programming languageofferings for the MS Windows environment. I want an interpreterthat is fast and powerful, yet small. I want it to work well inthe Cygwin/Win32 environment.Enter Pico Lisp. http://software-lab.de/down.htmlAccording to the Pico Lisp FAQ, "Pico Lisp is for programmerswho want to control their programming environment, at alllevels, from the application domain down to the bare metal."Yes! That's part of what I want a Lisp for. Especially a Lisp Imight embed in other applications. I want control. Pico Lisplooked promising.Pico Lisp is designed with a philosophy of "succinctness",according to the literature on the site. Although there areeven smaller Lisp interpreters available, Pico Lisp seemed tostrike a balance between terseness and functionality.Pico Lisp is written using standard C, and the author(Alexander Burger) distributes it as C source code under theGNU General Public License. That means if you want to use PicoLisp, you'll need to compile it yourself, or otherwise obtainthe executables. Pico Lisp comes in two flavours: picolisp, andan even smaller version: mini picolisp. (More about minipicolisp in a bit.)When you do build Pico Lisp for yourself, you'll get apowerhouse of a Lisp including APIs for building web servers,gui web application servers (for browser clients running javaand/or javascript) integrated relational databases, prolog dbaccess, and much more. Pico Lisp even comes with two exampleversions of a flight simulator: one which runs under X-Windows,the other which uses a client's browser/java for the display.There's a chess game written in Pico Lisp and Prolog.Lest one think that Pico Lisp is a mere toy, consider this. In2006, Pico Lisp won second prize in the German-language C'tMagazine database contest, beating entries written using DB2and Oracle. Industrial-strength databases with tightlyintegrated web applications have been crafted with Pico Lisp.http://tinyurl.com/y9wu39Pico Lisp has some drawbacks and limitations. As the FAQ warns,Pico Lisp "does not pretend to be easy to learn." It is not aCommon Lisp flavor. It is not "some standard, 'safe' black-box,which may be easier to learn."  Also, for my purposes, I wantsoftware that runs not only on Linux, but also on PCs with theMS-Windows operating systems. And there was the rub: Pico Lispisn't distributed with binaries or Windows exe files.Even worse (for Windows users), Pico Lisp wasn't ported toCygwin. I have a growing list of portable apps that will run ona flash drive, many of them I compiled from source from usingCygwin tools like make, gcc, etc.Cygwin provides a POSIX emulation layer in the form ofcygwin1.dll and other libraries. This lets a PC running Windowslook like much like a Linux or UNIX box to programs which havebeen compiled for Cygwin.  I'd compiled hundreds of programsfor Cygwin and here was Pico Lisp which I wanted to haverunning on all my PCs, Linux ones as well as the MS-WindowsPCs, too.So this was beginning to look like a challenge. I'd just take alittle peek at porting Pico Lisp to Cygwin, and see how itwould go. I'd ported everything from sox to busybox to fluxboxto Cygwin, so I felt ready for porting Pico Lisp.Pico Lisp comes in two flavors. Mini picolisp and fullpicolisp.Mini Pico Lisp is a kind of a "pure" Pico Lisp withoutsystem-dependent functions like databases, UTF-8, bignums, IPC,and networking. This seemed like a good place to start my PicoLisp porting adventures. I first tried a straight Cygwin/gccbuild, and that worked fine, no hitches.Then I remembered the -mno-cygwin compiler flag for Cygwin'sgcc. When you compile with -mno-cygwin, gcc causes theresulting executable to be built without Cygwin dll librarydependances. For C code that relies heavily upon the POSIXemulation aspects of Cygwin, this might not work. But why nottry building mini picolisp with the -mno-cygwin option?The C code for mini picolisp is free from Linux/POSIX systemcalls, and it compiled with no problems using -mno-cygwin. Itproduced a mini picolisp exe file of about 73K, which is notdependant upon any Cygwin DLLs.Porting the full Pico Lisp interpreter proved to be more of achallenge. Whereas the mini picolisp was careful to avoid Linuxsystem calls, Pico Lisp takes the opposite approach and usesLinux (UNIX/POSIX) system functions where needed.Additionally, Pico Lisp has the ability to dynamically loadshared libraries for various extensions.Since we need to use shared libraries anyway, I wanted for allof picolisp to go into a single DLL.  Then the picolisp exewould be a just small stub that uses that the shared library,picolisp.dll. Pico Lisp applications often use fork, so thisshould also be more efficient when forking.Splitting up Pico Lisp this way (a DLL and an exe stub) wouldallow the picolisp.dll to be used as a Lisp library. As ashared library, it would then be possible for otherapplications to treat Pico Lisp as an embedded interpreter,somewhat like librep, but much smaller and more portable.Wanting to see how much I could squeeze down the size of theexecutables and libraries under Cygwin, I used gcc's -Osoption, which requests that gcc optimize by making the smallestpossible code. Doing this resulted in a picolisp dll of just150K, and a picolisp exe stub of only 2K.Of course, if you want this full Pico Lisp to run on a WindowsPC which does not already have Cygwin installed, you'll need toobtain a few Cygwin DLLs which provide the POSIX emulationlayer for Pico Lisp.For the most part, the port to Win32/Cygwin went smoothly.There were just a few differences between Linux and Cygwin thatwere handled with macro ifdef statements in the C code thatallow something to be done differently for the Cygwincompilation.In the end it turned out that the biggest problem was the fcntlsystem function that does file and record locking. This wasespecially frustrating, as time and time again, I thought I'dfound a solution or a work-around to the differences insemantics of the fcntl call between Linux and Cygwin, only tohave the my "solution" fail with more rigorous testing.The locking problem was finally just circumvented for Windowsby simply not using fcntl locking. So, there is no file orrecord locking for Pico Lisp running under Windows. (See thelocking notes in http://www.sqlite.org/lockingv3.html foranother perspective on locking system functions in Windows.)However, all the example applications run fine, running in aspecial (Solo) mode in Pico Lisp, in the few places it evenmatters. This avoids depending on buggy or non-existent recordlocking functionality with the various Windows versions andfile system types.So, what do we have at this point? Pico Lisp is running on thePC. A working, industrial-strength Lisp interpreter is PicoLisp, ready for writing applications that are succinct yetpowerful. Pico Lisp comes with a Prolog interpreter andrelational databases and flight simulators and chess games andweb servers and chat servers and sendmail and much more.And Pico Lisp itself is written in highly portable C, runningon Linux and Windows. Pico Lisp is readily embedable, and willbe useful to add scripting languages (Lisp, Prolog) to otherapplications, either statically linked, or as a shared library(DLL).Pico Lisp is a little dynamo. It even has the ability to usein-line C code which is compiled on-the-fly into a sharedlibrary. This in-line C ability uses gcc. (And it works withtcc, the Tiny C Compiler, too.)With the tremendous number of PCs out there now able to runPico Lisp, watch out! Pico Lisp may be small, but sometimesvery powerful things come in small packages.Doug Snead, Jan. 2007

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -