From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: pjb@informatimago.com (Pascal J. Bourguignon) Newsgroups: gmane.emacs.help Subject: Re: Learning LISP; Scheme vs elisp. Date: Fri, 01 Aug 2008 23:51:01 +0200 Organization: Informatimago Message-ID: <8763qk8kvu.fsf@hubble.informatimago.com> References: <55dbm5-qcl.ln1@news.ducksburg.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1217630447 26466 80.91.229.12 (1 Aug 2008 22:40:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 1 Aug 2008 22:40:47 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Aug 02 00:41:36 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KP3JV-0002gH-ET for geh-help-gnu-emacs@m.gmane.org; Sat, 02 Aug 2008 00:41:33 +0200 Original-Received: from localhost ([127.0.0.1]:51136 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KP3Ia-00020a-Il for geh-help-gnu-emacs@m.gmane.org; Fri, 01 Aug 2008 18:40:36 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!newsfeed.esat.net!club-internet.fr!feedme-small.clubint.net!proxad.net!feeder1-1.proxad.net!cleanfeed1-a.proxad.net!nnrp5-1.free.fr!not-for-mail Original-Newsgroups: gnu.emacs.help Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.2 (gnu/linux) Cancel-Lock: sha1:6UA4b67h+uRNLLZQTjxp3zCaMsY= Original-Lines: 123 Original-NNTP-Posting-Date: 01 Aug 2008 23:42:48 MEST Original-NNTP-Posting-Host: 88.182.134.169 Original-X-Trace: 1217626968 news-4.free.fr 5861 88.182.134.169:38212 Original-X-Complaints-To: abuse@proxad.net Original-Xref: news.stanford.edu gnu.emacs.help:160811 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:56158 Archived-At: Adam Funk writes: > I've decided I ought to train myself in the most elegant programming > weapon --- http://xkcd.com/297/ --- so I've started working through > _The Structure and Interpretation of Computer Programs_. Notice that this is not a book about scheme, but about programming in general. It just happens that it uses scheme for its examples (but there are blogs and wikis with the sicp examples translated in other programming languages). http://codepoetics.com/wiki/index.php?title=Topics:SICP_in_other_languages http://eli.thegreenplace.net/category/programming/lisp/sicp/ To learn scheme there are easier books such as: How to Design Programs -- An Introduction to Computing and Programming http://www.htdp.org/2003-09-26/Book/ Concrete Abstractions -- An Introduction to Computer Science Using Scheme http://www.gustavus.edu/+max/concrete-abstractions.html And of course, the reference: http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs.html and documentation of the implementation, eg. http://www.drscheme.org/ A new version of scheme just came out, R6RS http://schemers.org/ so be sure to use the version of the report implemented by your scheme. Nonetheless, SICP is a very good book that you should read anyways, but it will teach you more general and very important concepts, beyond the specific knowledge of scheme details. > In the long term I hope I'll be able to customize Emacs more in its > native way instead of wrapping external Perl programs in > shell-command-on-region (as I often do now). Yuck! > Any tips on transferring knowledge between Scheme and elisp? Emacs lisp is closer to Common Lisp than scheme. The main separation line being this lisp-1 vs. lisp-2 affair. But emacs lisp is also different enough from Common Lisp (the main difference being that all emacs lisp variables are special, while all scheme variables are lexical; in Common Lisp, there are both lexical and special variables). The fundamental lisp "primitives" will be about the same in all lisp languages. You will have (eql (car (cons x y)) x) in all lisp, well (eqv? (car (cons x y)) x) in scheme. But details may be different enough that it might be difficult to write code running with the same semantics or at all on both three. For example: (let ((a 1) (b 2) (c -1)) (do ((x 0 (+ 1 x))) ((> x 10)) (print (+ c (* b (+ x (* a x))))))) will do about the same thing in emacs lisp and Common Lisp. For scheme, you will have to (define (print x) (newline) (display x)), but scheme will return #t, while Common Lisp returns NIL (and emacs lisp nil, since in emacs lisp the symbols are in lowcase by default contrarily to Common Lisp). Once you know well one of them, including their macro system, you will be able to write "portability" function like the above print function. In emacs lisp, there is the cl library (require 'cl) which exports some functions and macros found in Common Lisp and not in emacs lisp. Also, there are implementations of one in the other. For example: emacs-cl implements Common Lisp over emacs lisp. Pseudo implements scheme r4rs over Common Lisp. ( Someone could have good fun trying to make Pseudo run over emacs-cl over emacs lisp, to have a scheme in emacs ;-) ) But the main thing, with respect to emacs lisp is that if you want to learn it for emacs editing, then you will have to learn all the emacs "library" functions. Things about buffers, markers, files, windows, characters, inserting, deleting, replacing, regular expressions, etc, not mentionning all the emacs lisp libraries and applications. This is an amount of knowledge orders of magnitude superior to the mere knowledge of the programming language. (Don't be afraid, happily you don't have to learn it all at once, you can learn it piece by piece when you need it). You could learn emacs lisp from the emacs-lisp-intro tutorial, and translate the sicp examples in emacs lisp. It's already been done for Common Lisp, but not for emacs lisp. Finally, I should mention that you could skip emacs lisp altogether, learn Common Lisp, and use an emacs implemented in Common Lisp, such as Hemlock, or the more recent Climacs (but they don't benefit (yet) the same amount of contributions as emacs). > As a first observation, it seems to me that Scheme's define seems to > correspond to both defun and setq in elisp --- is that a fair > interpretation (or a stupid one)? As a first approximation, you're right. For more information see: http://groups.google.com/groups?as_q=lisp-1+lisp-2&num=100&scoring=r&as_epq=&as_oq=&as_eq=&as_ugroup=comp.lang.lisp&as_usubject=&as_uauthors=&lr=&as_drrb=q&as_qdr=&as_mind=1&as_minm=1&as_miny=1981&as_maxd=1&as_maxm=8&as_maxy=2008&safe=off -- __Pascal Bourguignon__ http://www.informatimago.com/ Until real software engineering is developed, the next best practice is to develop with a dynamic system that has extreme late binding in all aspects. The first system to really do this in an important way is Lisp. -- Alan Kay