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

📄 cl.texinfo

📁 早期freebsd实现
💻 TEXINFO
📖 第 1 页 / 共 3 页
字号:
\input texinfo    @c -*-texinfo-*-@setfilename ../info/cl@settitle Common Lisp Extensions@iftex@finalout@end iftexCopyright (C) 1987 Cesar Quiroz@node Top, Generalities,,(DIR)@chapter Common Lisp ExtensionsThe routines described in this chapter provide some of the functionality ofCommon Lisp inside Emacs Lisp.@menu* gen: Generalities.           Things you need to know.* sym: Symbols.                Gensym, gentemp, keyword-p, @dots{}* lis: Lists.                  List*, pairlis, acons, @dots{}* seq: Sequences.              Every, any, notevery, notany, @dots{}* con: Conditionals.           When, unless, case, ecase.* ite: Iterations.             Do, do*, dolist, dotimes, @dots{}* mul: Multiple Values.        Values, values-list, @dots{}* ari: Integer Arithmetic.     Floor, ceiling, round, truncate, @dots{}* stf: Generalized Variables.  Setf and friends.* str: Structures.             Like Pascal records or C structs.* mis: Miscellanea.            Odds and ends that didn't fit elsewhere.* tod: To Do.                  Suggestions for future hackery.@end menu@node Generalities, Symbols, Top, Top@section GeneralitiesThis section tells you want you need to know about the routines in the file@file{cl.el}, so that you can use them.  The distribution also includesthis documentation and perhaps a few example files.@subsection License, Availability, MaintenanceThese files are covered by the GNU Emacs General Public License (if youdon't know its terms, try @kbd{@key{C-h} @key{C-c}}) and the statement ofno warranty (again, you can type @kbd{@key{C-h} @key{C-w}} if you don'tknow its terms) also applies to them. @refillI, Cesar Quiroz, the original author of the software described here, willappreciate hearing about bug reports (and fixes), suggestions and comments,applying both to the code and to this documentation.  I don't promise toact on those communications, but whenever they might conduce toimprovements of this software, I will make those improvements available tothe general community through the Free Software Foundation.  You can reachme at the following net addresses:@quotationquiroz@@seneca.cs.rochester.eduquiroz@@rochester.arpa@{allegra | seismo | @dots{} @} ! rochester ! quirozCSNET: Cesar Quiroz at node Rochester@end quotation@subsection Purpose and LimitationsThese routines were written with two purposes in mind:@enumerate@itemTo make programming in Emacs Lisp even more compatible with Common Lisp.Indeed, my original motivation was to have a @code{do} macro.@itemTo facilitate to novice Lisp programmers a chance to practice withfeatures commonly found only in expensive implementations of Lisp. @end enumerateIn order to satisfy these purposes, the routines were written in such a waythat it is practical to use them inside Emacs: no effort was given toimplement features that could slow down the host Emacs unnecessarily norrequire recoding of the Emacs Lisp interpreter.For instance, no support is given to floating point arithmetic.So, I have tried to implement a subset of the functionality of Common Lisp.Whatever is implemented, has syntactic and semantic properties like theequally named features of Common Lisp, but not all the relevant featureshave been implemented (@pxref{To Do}, for some suggestions).  Whendeciding what to include, I have tried to strike a balance between theseconstraints:@enumerate@itemKeep it simple, I didn't want to spend much time in this idea.@itemKeep it compatible with Common Lisp.@itemKeep it flexible, so my code doesn't oppose a better implementation (whenthis looked hard, I just didn't implement the feature).@itemKeep an eye on the intended use of Emacs Lisp: to support an advancededitor.  I don't expect that more arithmetic support will be as conduciveto this goal as having better iterations and conditionals will.@end enumerateFor background, the reference is ``Common Lisp: The Language'' by GuySteele Jr. (Digital Press, 1984).  For all the features described hereyou can assume that the intent has been to provide the syntax andsemantics of the features of like name in the book.  For the most part,this documentation will concentrate on how my routines @i{fail} toimplement Common Lisp faithfully.@subsubsection Specific LimitationsEmacs Lisp and Common Lisp differ enough to make some of the emulationdifficult, expensive or nearly impractical.  Some specific limitations arestated here:@enumerate@itemCommon Lisp is lexically scoped (mostly), while Emacs Lisp is dynamicallyscoped.  Things like @code{block}, @code{return}, @code{tagbody} are thenpractically impossible to imitate correctly (in principle, rewriting@code{eval}, @code{apply} and a couple of other functions would suffice,problem is that such rewriting amounts to  a new interpreter on topof the old.)  Things like @samp{implicit-blocks},@samp{implicit-tagbodies} and the like have not been implemented at all.Where they are needed, the most you can assume is that I tried to put@samp{implicit-progns} around places where it made sense. @refill@itemEmacs Lisp's @code{lambda} does not support all the possible argumentmarkers.  Similarly, @code{defmacro} doesn't support automaticdestructuring of the calls.  An approximation to a keyword-based callingstyle was implemented, mainly for the sake of @code{defstruct}, but isnot general enough.  @refill@itemEmacs Lisp supports arithmetic only on integers.@itemEmacs Lisp doesn't support many of the basic types of Common Lisp.  Inparticular, there are no arrays beyond vectors and strings (although theseones are compatible), characters are essentially smallintegers, etc. @refill@itemThere are no declarations in Emacs Lisp (in the sense of Common Lisp's@code{declare}, @code{proclaim}, @dots{}) nor there is a explicit latticeof types.  These limitations could be effectively overcome from Lisp code(to a extent), but I don't see them as a very pressing need, if a need atall in Emacs Lisp.  @code{defstruct} can be used to generate new typesthat can be recognized at runtime. @refill@itemThe Emacs Lisp reader is not programmable.  The syntax it accepts isalmost standard, but it preempts '?' as a dispatching macro of sorts.The @code{format} function is incompatible with Common Lisp.  Thereisn't a `quasi-constant' notation (the usual @code{backquote} of CommonLisp).  None of these differences causes any problems when writing EmacsLisp (although the lack of backquoting is felt sorely), but they opposea Common Lisp emulation. @refill@end enumerate@subsection Loading and CompilingThe file @file{cl.el} provides the @samp{cl} feature, you can use this totest whether these routines have been loaded, or to load them from yourcode (by means of @code{(require 'cl)}).  The compiled file is a littlelarger than 50K bytes.If you need to recompile the sources, make sure you load them first on theEmacs that will do the recompilation.  This is because many syntacticcharacteristics (like the special forms) have been implemented as macrosand you need to make sure that macros are known to the compiler before theyare used.These extensions work correctly when interpreted in a GNU Emacs ofversion 17.64 or beyond.  Compiling them requires a more recent bytecompiler, preferably one strictly younger than version 18.XX.@subsection On Line HelpThe routines in this file have documentation strings, so you can (andshould) consult them for the exact syntax allowed.  That information isnot repeated in this manual.  Some of the routines are also documentedexplicitly in the Common Lisp reference, their doc-strings begin with@samp{[cl]} to represent this fact.The rest (those without the @samp{[cl]} mark) are auxiliary functions ormacros used by the rest of the implementation.  They are not constrainedby any standard and are advertised only in as much as they can be usefulin other applications. @refillEach of the following sections contains a subsection called `FeaturesProvided'.  It lists briefly the user-visible features of thisimplementation.  In its entries, names by themselves refer to functions.Macros and variables are identified by a `MACRO' or a `VARIABLE' aheadof their names.@node Symbols, Lists, Generalities, Top@section SymbolsThe most important omission is that of a @var{packages} mechanism.(For a possible implementation, @pxref{To Do})  Whenever a Common Lispfunction expects a package, I have substituted an obarray.  There is ahack to have pseudo-keywords, see below. @refillThere are two other notorious omissions over which I haven't lost anysleep.  The first is the lack of a @code{remprop} function, which could beeasily provided if needed.  The second is the lack of ways to modify theprint name of a symbol.  This one would probably be good only tointroduce strange bugs, so I don't miss it. @refill@subsection Features Provided@table @code@item VARIABLE *gensym-index*@itemx VARIABLE *gensym-prefix*@itemx VARIABLE *gentemp-index*@itemx VARIABLE *gentemp-prefix*These variables are used to keep the state of the generator of new names.Better leave them alone.@item gensym@itemx gentempThese do the same as the Common Lisp names of like names.@item MACRO defkeyword @itemx keyword-of@item keywordpThese provide the pseudo-keywords implementation.@end table@subsection KeywordsThe lack of packages makes it difficult to implement keywords correctly.I have provided a macro @code{defkeyword} that takes a symbol and makessure it evaluates to itself.  (So, it is like @code{defconst}.)  If yourprograms ever need keywords, put a bunch of calls to @code{defkeyword} atthe beginning of your code, so when loaded they will be in effect. @refillThe (standard) predicate @code{keywordp} tests to see if the givensymbol's name begins with a colon and then ensures that it evaluates toitself. @refillThe function @code{keyword-of} takes a symbol and returns a keyword oflike name. @refill@example (keyword-of 'foo):foo (keyword-of ':bar):bar@end exampleThis feature was added mainly to support @code{defstruct} and the tests ofthe sequence functions.  It is fragile and easy to fool.@subsection New SymbolsA common need (especially when writing macros) is to be able to invent newnames for things.  I provide the @code{gensym} and @code{gentemp}functions.  The global state needed is kept in the variables@code{*gentemp-index*}, @code{*gentemp-prefix*}, @code{*gensym-index*} and@code{*gensym-prefix*}.  Changing them, especially the index ones, is avery bad idea.  I am not providing the Common Lisp default prefixes ('G'for @code{gensym} and 'T' for @code{gentemp}) because of debuggingparanoia.  My default prefixes are harder to come by when giving sanenames to things. @refill@node Lists, Sequences, Symbols, Top@section ListsLists (indeed, conses) are so deeply involved in Lisp that there seemsto be little need to justify improving the list handling of a Lisp.Common Lisp, however, is a rather huge Lisp.  I haven't provided all thefunctions in the chapter of lists, mainly because some of them could beimplemented correctly only if keyword arguments were supported.That explains why I haven't rushed to provide@code{subst}, @code{sublis}, etc.  Also, that explains the rathertemporary nature of the implementation of @code{member} and@code{adjoin}.  I will welcome any efforts to extendthis work. @refill@subsection Features Provided@table @code@item endp@itemx list*

⌨️ 快捷键说明

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