I'm learning scheme and also writing little utils in elisp. But I'm having the predictable frustrations. Since lisp is a very fluid language, is it simple to write macros so that elisp "feels" like scheme? All I really want is a basic define keyword that assigns functions to both namespaces, and also have functions evaluate without funcall.
I understand that the lisp community has innate hostilities towards scheme advocacy and maybe it sounds like I'm bastardizing lisp or writing unmaintainable code. To me, it's just like converting from one kind of machine to another I know better. The irony is that maybe I'll learn enough lisp that I won't want to actually use these macros when I'm done...
* Greg Neumann wrote: > I'm learning scheme and also writing little utils in elisp. But I'm > having the predictable frustrations. Since lisp is a very fluid > language, is it simple to write macros so that elisp "feels" like > scheme? All I really want is a basic define keyword that assigns > functions to both namespaces, and also have functions evaluate without > funcall.
I think this is intractable. You can fairly easily *write* such a macro, but many of its uses are illegal (at least in CL). For instance, the obvious:
(define x 3)
would try and set the FDEFINITION of X to be 3, which isn't legal - it needs to be a function. And even if this works it only solves some of the `problems' - for instance.
(defun gribble (fn ...) ... (fn ...))
is not going to work.
The differences between a lisp1 (like scheme) and a Lisp2 (like CL or elisp) are not easily glossed over. It would probably be easier to go the other way. In Scheme you can define FUNCTION as identity:
(define (function x) x)
and then define FUNCALL:
(define (funcall f . args) (apply f args))
And now it should be possible to write code which does, say:
(funcall (function list) 1 2 3)
But this is pretty horrible, really.
If you really want to run scheme code n a lisp system what you need is some kind of much larger compatibility box like pseudoscheme. There's probably something that goes the other way although in order to emulate CL on top of a scheme you'd need a huge library...
* Greg Neumann | All I really want is a basic define keyword that assigns functions to | both namespaces, and also have functions evaluate without funcall.
Why is this a big deal to you? What is it about people who learn Scheme first that makes this so terribly hard for them to cope with?
-- Erik Naggum, Oslo, Norway
Act from reason, and failure makes you rethink and study harder. Act from faith, and failure makes you blame someone and push harder.
Tim Bradshaw <t...@cley.com> writes: > * Greg Neumann wrote:
> > I'm learning scheme and also writing little utils in elisp. But I'm > > having the predictable frustrations. Since lisp is a very fluid > > language, is it simple to write macros so that elisp "feels" like > > scheme? All I really want is a basic define keyword that assigns > > functions to both namespaces, and also have functions evaluate without > > funcall.
> I think this is intractable. You can fairly easily *write* such a > macro, but many of its uses are illegal (at least in CL). For > instance, the obvious:
> (define x 3)
> would try and set the FDEFINITION of X to be 3, which isn't legal - it > needs to be a function. And even if this works it only solves some of > the `problems' - for instance.
Well, you can do this sort of thing in elisp. For example, this:
will get you a Lisp-1 define and lambda*. So you can now write dumb-ass code like:
(define foo (lambda* (x y z) (x y z)))
(foo #'+ 1 2) => 3
It should be easy enough to write a Lisp-1 replacement for let.
Now, were you to try to write any amount of code using these you would quickly realize how different elisp is from scheme, and would probably regret having touched them.
-- /|_ .-----------------------. ,' .\ / | No to Imperialist war | ,--' _,' | Wage class war! | / / `-----------------------' ( -. | | ) | (`-. '--.) `. )----'
Erik Naggum <e...@naggum.no> wrote in message <news:3243599771779523@naggum.no>... > Why is this a big deal to you? What is it about people who learn Scheme > first that makes this so terribly hard for them to cope with?
To me, it's just like converting from one kind of machine to another I know better. The irony is that maybe I'll learn enough lisp that I won't want to actually use these macros when I'm done...
That's the cut 'n paste. :) Intuitively, I think doing this project gives me a rough sense of lisp's power and is a good tutorial. But it's not important enough to take a month and still not have anything decent.
> Well, you can do this sort of thing in elisp. For example, this:
Thanks for the demonstration-of-concept. My emacs installation calls the use of gensym a void-function error, but I can deal with that and learn a bit in the process.
> Now, were you to try to write any amount of code using these you would > quickly realize how different elisp is from scheme, and would probably > regret having touched them.
greg_new_...@yahoo.com (Greg Neumann) writes: > t...@whirlwind.OCF.Berkeley.EDU (Thomas F. Burdick) wrote in message <news:xcv65w4ke7o.fsf@whirlwind.OCF.Berkeley.EDU>... > > Well, you can do this sort of thing in elisp. For example, this:
> Thanks for the demonstration-of-concept. My emacs installation calls > the use of gensym a void-function error, but I can deal with that and > learn a bit in the process.
Er, yeah, I meant to preceed that with (require 'cl). Everyone programming in elisp should use the cl package. Maybe you do or don't want faked lexical scoping, and some of the other dubious features in it, but you *really* want to use dolist and dotimes, for example, rather than the equivalent hand-written loops using while.
> > Now, were you to try to write any amount of code using these you would > > quickly realize how different elisp is from scheme, and would probably > > regret having touched them.
> Yup I'm a masochist.
It might be amusing for a little bit, and might give you an appreciation for how different the two languages are. But I'd be wary of getting used to it. The semantics of the languages are different, one's lexically-scoped, the other dynamically-scoped with no closures; if you use lambda*, you get lisp-1 binding, but the rest of the elisp world is using lisp-2 binding; etc. I'd think the define vs defun/defvar split would be a good thing -- if your brain is in the wrong context, you'll hit syntax problems early, as opposed to semantic problems later.
-- /|_ .-----------------------. ,' .\ / | No to Imperialist war | ,--' _,' | Wage class war! | / / `-----------------------' ( -. | | ) | (`-. '--.) `. )----'
t...@apocalypse.OCF.Berkeley.EDU (Thomas F. Burdick) wrote:
> Er, yeah, I meant to preceed that with (require 'cl). Everyone > programming in elisp should use the cl package. Maybe you do or don't > want faked lexical scoping, and some of the other dubious features in > it, but you *really* want to use dolist and dotimes, for example, > rather than the equivalent hand-written loops using while.
dolist and dotimes are defined in subr.el in Emacs 21. Libraries that use cl at runtime aren't installed in the Emacs distribution, which may be a reason for people programming in elisp to avoid it.
John Paul Wallington <j...@shootybangbang.com> writes:
> t...@apocalypse.OCF.Berkeley.EDU (Thomas F. Burdick) wrote:
> > Er, yeah, I meant to preceed that with (require 'cl). Everyone > > programming in elisp should use the cl package. Maybe you do or don't > > want faked lexical scoping, and some of the other dubious features in > > it, but you *really* want to use dolist and dotimes, for example, > > rather than the equivalent hand-written loops using while.
> dolist and dotimes are defined in subr.el in Emacs 21. Libraries > that use cl at runtime aren't installed in the Emacs distribution, > which may be a reason for people programming in elisp to avoid it.
AFAIK dolist, dotimes, when, unless etc etc are a relatively new addition to Elisp. Before that they were defined only in the cl module.
I think there is a resistance to CL in the Elisp camp. Maybe it is RMS himself. I don't know.
In any case, there are no counter arguments for NOT sticking
(require 'cl)
in your .emacs file. If you want two arguments in favor:
1 - defstruct 2 - if you use ILISP you get it anyway. :)
Cheers
-- Marco Antoniotti ======================================================== NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488 715 Broadway 10th Floor fax +1 - 212 - 995 4122 New York, NY 10003, USA http://bioinformatics.cat.nyu.edu "Hello New York! We'll do what we can!" Bill Murray in `Ghostbusters'.