From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Joel J. Adamson " Newsgroups: gmane.emacs.help Subject: Re: Learning LISP; Scheme vs elisp. Date: Fri, 01 Aug 2008 15:16:46 -0400 Message-ID: <2790.1217618206@email.unc.edu> References: <55dbm5-qcl.ln1@news.ducksburg.com> NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1217618762 23600 80.91.229.12 (1 Aug 2008 19:26:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 1 Aug 2008 19:26:02 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Adam Funk Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Aug 01 21:26:51 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 1KP0Gl-00037X-TU for geh-help-gnu-emacs@m.gmane.org; Fri, 01 Aug 2008 21:26:32 +0200 Original-Received: from localhost ([127.0.0.1]:49368 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KP0Fq-0001Kz-Rs for geh-help-gnu-emacs@m.gmane.org; Fri, 01 Aug 2008 15:25:34 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KP0FZ-0001Kj-Kw for help-gnu-emacs@gnu.org; Fri, 01 Aug 2008 15:25:17 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KP0FY-0001KX-4K for help-gnu-emacs@gnu.org; Fri, 01 Aug 2008 15:25:16 -0400 Original-Received: from [199.232.76.173] (port=48997 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KP0FX-0001KU-Tw for help-gnu-emacs@gnu.org; Fri, 01 Aug 2008 15:25:15 -0400 Original-Received: from smtpsrv1.isis.unc.edu ([152.2.1.140]:55620 helo=smtp.unc.edu) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KP0FX-0003Lf-Kg for help-gnu-emacs@gnu.org; Fri, 01 Aug 2008 15:25:15 -0400 Original-Received: from edna.homeunix.org (cpe-066-057-101-159.nc.res.rr.com [66.57.101.159]) (authenticated bits=0) by smtp.unc.edu (8.13.4/8.13.4) with ESMTP id m71JL4JL025538 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 1 Aug 2008 15:21:08 -0400 (EDT) Original-Received: from edna.homeunix.org (localhost [127.0.0.1]) by edna.homeunix.org (8.14.2/8.14.2) with ESMTP id m71JGk4E002795; Fri, 1 Aug 2008 15:16:46 -0400 Original-Received: from email.unc.edu (joel@localhost) by edna.homeunix.org (8.14.2/8.14.2/Submit) with ESMTP id m71JGk4a002791; Fri, 1 Aug 2008 15:16:46 -0400 X-Authentication-Warning: edna.homeunix.org: joel owned process doing -bs In-reply-to: <55dbm5-qcl.ln1@news.ducksburg.com> Comments: In-reply-to Adam Funk message dated "Fri, 01 Aug 2008 13:45:57 +0100." X-Mailer: MH-E 8.0.3+cvs; nmh 1.3; GNU Emacs 23.0.60 X-detected-kernel: by monty-python.gnu.org: Solaris 9 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:56149 Archived-At: >>>>> "Adam" == Adam Funk writes: Adam> I've decided I ought to train myself in the most elegant Adam> programming weapon --- http://xkcd.com/297/ --- so I've Adam> started working through _The Structure and Interpretation of Adam> Computer Programs_. Good idea: the best computer science book ever written --- and the only one I've ever used :-P Adam> In the long term I hope I'll be able to customize Emacs more Adam> in its native way instead of wrapping external Perl programs Adam> in shell-command-on-region (as I often do now). Uh, what? Can you explain this? Can you explain why on Earth you would do it? Adam> Any tips on transferring knowledge between Scheme and elisp? There are some general qualities to Lisp that all Lisp dialects share, Scheme and Emacs Lisp among them. Both are descendants of MacLisp (though Scheme is way different from MacLisp, and Emacs Lisp is quite similar). Adam> As a first observation, it seems to me that Scheme's define Adam> seems to correspond to both defun and setq in elisp --- is Adam> that a fair interpretation (or a stupid one)? Scheme has a single namespace for variables and functions, whereas other Lisps have one for functions, one for special variables, on and on. That's why there's defun, defvar, defmacro, defkitten; this is how you can pass a function as a variable without specially tagging it in Scheme: Scheme: ,---- | Gambit v4.2.8 | | > (define lis '(1 2 3 4)) | (apply + lis) | > 10 `---- Emacs: ,---- | ELISP> (apply + '(1 2 3 4)) | *** Eval error *** Symbol's value as variable is void: + | ELISP> (apply '+ '(1 2 3 4)) | 10 `---- Common Lisp: ,---- | [5]> (defvar lis '(1 2 3 4)) | LIS | [6]> lis | (1 2 3 4) | [7]> (apply #'+ lis) | 10 | [8]> (apply + lis) | | *** - APPLY: (APPLY #'+ LIS) is not a function name; try using a symbol instead | The following restarts are available: | USE-VALUE :R1 You may input a value to be used instead. | ABORT :R2 ABORT | Break 1 [9]> `---- Read those errors carefully and they'll make sense given what I said above about namespaces. The real correspondent of setq in Scheme is set! --- destructive procedures end in exclamation points. It's up to a particular implementor of Scheme as to whether set! on an undefined variable is an error (correct me if I'm wrong about the standard, but I've had some implementations where you can set! an un'define'd variable, and others where you can't). I suggest you use Emacs for Scheme hacking, and that way you will learn the ins and outs of both. If you'd like to see an application that I developed in Emacs using Scheme (and that I'd like to add an Emacs mode for interacting), check out http://www.unc.edu/~adamsonj/software.html and scroll down to Intelligent WTF. The source code is also there for browsing. Joel -- Joel J. Adamson (303) 880-3109 Public key: http://pgp.mit.edu http://www.unc.edu/~adamsonj http://trashbird1240.blogspot.com