From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: weber Newsgroups: gmane.emacs.help Subject: Re: Learning LISP; Scheme vs elisp. Date: Fri, 1 Aug 2008 18:06:58 -0700 (PDT) Organization: http://groups.google.com Message-ID: <55c25bc2-3831-4ec2-9c86-d1c86bf854ca@a1g2000hsb.googlegroups.com> References: <55dbm5-qcl.ln1@news.ducksburg.com> <8763qk8kvu.fsf@hubble.informatimago.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1217641249 17399 80.91.229.12 (2 Aug 2008 01:40:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 2 Aug 2008 01:40:49 +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 03:41:38 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 1KP67h-0003OH-9x for geh-help-gnu-emacs@m.gmane.org; Sat, 02 Aug 2008 03:41:33 +0200 Original-Received: from localhost ([127.0.0.1]:57283 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KP66m-00057x-Jn for geh-help-gnu-emacs@m.gmane.org; Fri, 01 Aug 2008 21:40:36 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!a1g2000hsb.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 129 Original-NNTP-Posting-Host: 189.32.111.130 Original-X-Trace: posting.google.com 1217639218 8880 127.0.0.1 (2 Aug 2008 01:06:58 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Sat, 2 Aug 2008 01:06:58 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a1g2000hsb.googlegroups.com; posting-host=189.32.111.130; posting-account=7GrjgQoAAAD6slWURausdJnhFDkmQYC8 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0,gzip(gfe),gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:160816 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:56163 Archived-At: On Aug 1, 6:51=A0pm, p...@informatimago.com (Pascal J. Bourguignon) wrote: > 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. =A0It 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=3DTopi= cs:SICP_in_other_lang...http://eli.thegreenplace.net/category/programming/l= isp/sicp/ > > To learn scheme there are easier books such as: > > =A0 =A0 =A0 =A0 =A0How to Design Programs -- An Introduction to Computing= and Programming > =A0 =A0 =A0 =A0 =A0http://www.htdp.org/2003-09-26/Book/=A0 > > =A0 =A0 =A0 =A0 =A0Concrete Abstractions -- An Introduction to Computer S= cience Using Scheme > =A0 =A0 =A0 =A0 =A0http://www.gustavus.edu/+max/concrete-abstractions.htm= l > > 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, R6RShttp://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. =A0The main separation > line being this lisp-1 vs. lisp-2 affair. =A0But 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. =A0You will have (eql (car (cons x y)) x) in all lisp, well > (eqv? (car (cons x y)) x) in scheme. =A0But 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)) > =A0 (do ((x 0 (+ 1 x))) > =A0 =A0 =A0 ((> x 10)) > =A0 =A0(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" =A0function like the above print > function. =A0In 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 =A0 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. =A0This > is an amount of knowledge orders of magnitude superior to the mere > knowledge of the programming language. =A0(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=3Dlisp-1+lisp-2&num=3D100&scoring=3D= r&... > > -- > __Pascal Bourguignon__ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0http://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 Aren't you guys exaggerating? Maybe he just need to pickup the basics to start writing his functions? Check the manual and this perhaps (http://steve-yegge.blogspot.com/ 2008/01/emergency-elisp.html). If you have any specific doubts, ask on gnu.emacs.help! Cheers, weber