From: "Joel J. Adamson " <adamsonj@email.unc.edu>
To: Adam Funk <a24061@ducksburg.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Learning LISP; Scheme vs elisp.
Date: Fri, 01 Aug 2008 15:16:46 -0400 [thread overview]
Message-ID: <2790.1217618206@email.unc.edu> (raw)
In-Reply-To: <55dbm5-qcl.ln1@news.ducksburg.com>
>>>>> "Adam" == Adam Funk <a24061@ducksburg.com> 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
next prev parent reply other threads:[~2008-08-01 19:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-01 12:45 Learning LISP; Scheme vs elisp Adam Funk
2008-08-01 13:06 ` Joost Kremers
2008-08-01 20:26 ` Adam Funk
2008-08-01 14:09 ` Thien-Thi Nguyen
2008-08-01 19:16 ` Joel J. Adamson [this message]
[not found] ` <mailman.15727.1217618719.18990.help-gnu-emacs@gnu.org>
2008-08-01 20:18 ` David Kastrup
2008-08-04 2:31 ` Joel J. Adamson
2008-08-01 20:30 ` Adam Funk
2008-08-01 22:10 ` Pascal J. Bourguignon
2008-08-01 21:51 ` Pascal J. Bourguignon
2008-08-02 1:06 ` weber
2008-08-02 12:33 ` Xah
2008-08-02 13:51 ` Xah
[not found] ` <mailman.15710.1217599959.18990.help-gnu-emacs@gnu.org>
2008-08-06 19:38 ` Adam Funk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2790.1217618206@email.unc.edu \
--to=adamsonj@email.unc.edu \
--cc=a24061@ducksburg.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.