> Adam Funk
ducksburg.com> 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_.
>> 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)?
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