LISP
From GPWiki
The wiki is now hosted by GameDev.NET at wiki.gamedev.net. All gpwiki.org content has been moved to the new server. However, the GPWiki forums are still active! Come say hello. Lisp is a peculiar language characterized by the following things:
Here's a taste of Lisp code:
(defun filter (fn lst)
(if (null lst)
()
(let ((result (funcall fn (car lst))))
(if result
(cons result (filter fn (cdr lst)))
(filter fn (cdr lst))))))
This is Common Lisp code defining a function of two arguments. It recursively applies its first argument - a function - to its second argument - a list - and returns a list of the resulting elements, leaving out those where the function returned nil (false). (This is not the most efficient implementation of such a function, as usual more efficiency can be gained by making the function less straightforward.) Before this code can be run, the Lisp environment reads it (transforms it from text to a data structure). This function only contains (nested) lists and symbols. After reading, macros are applied. In this case defun is a macro that transforms to more primitive function-defining code for example. The resulting code is compiled (almost all recent Lisp environments compile rather than interpret code) and executed - resulting in the storing of this particular function under the symbol filter. Function calls are lists starting with the name of the function, in the example null and cons are functions, and the function defined here can be called like (filter #'1+ '(1 2 3)), which will return (2 3 4). There have been a lot of different Lisp languages, but at the moment only a few of them are really relevant anymore:
Scheme and Common Lisp are well-standardized. Scheme is still evolving (The R6RS version of the specification is around the corner), while the Common Lisp spec has been stable for a decade. Both also have moderately-sized, very enthusiastic communities around them. Free implementations and libraries are abundant, but some of these (mostly libraries) require you to be a dedicated Lisp hacker to be able to understand and use them. There are minor Emacs-like editors extended through other Lisp variants (Edwin for Scheme and Hemlock with CMUCL), though none of them rivals Emacs or XEmacs in popularity. [edit] External links
|


