help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How the backquote and the comma really work?


From: Michael Heerdegen
Subject: Re: How the backquote and the comma really work?
Date: Tue, 21 Jul 2015 23:50:06 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Marcin Borkowski <mbork@mbork.pl> writes:

> > sorry for the late reply.
>
> It's fine, I'm working slowly on this anyway.

Sorry again.  Was on vacation this time.


> > Yes, that's the right approach.  You could of course translate into the
> > symbols named "'", "`" and "," instead, like the Lisp reader does, but
> > that's a detail.  In Elisp, these aren't special forms.  They could be
> > in your interpreter, of course.
>
> And they will be;-).

FWIW, "," and ",@" are not defined in Elisp at all.  They're just
symbols used as tags that are recognized by `backquote'.


> > Dunno if your interpreter will support macros.  If not, you could
> > handle backquote directly in your interpreter.
>
> No, I don't want to support macros – too much work and little benefit,
> I guess.

Mmh, I don't think so.  Macros are an essential part of the Lisp
language.  And I don't think it would be hard, it should be quite simple
to do.  `defmacro' kind of defines a function.  The difference to real
functions is that they get expressions (code) as arguments before
evaluation; the expansion itself is just like a function call.  The
result is a new (expanded) expression to be evaluated.

So if you have `funcall' and `apply', you already have everything you
need to support macros.  Your `eval' just has to use these to expand the
macro calls before it starts with the conventional evaluation.

> >> (require 'anaphora)                        ; we'll use acase
> >
> > It would be good if you could drop this dependence.  This would spare
> > people from trying your code from installing additional stuff.
>
> Well, aif is also useful for me.

FWIW, there are now good replacements for such stuff in Emacs Lisp.  You
can use `if-let' (new in Emacs 25.1 coming soon) instead of `aif', and
`pcase' (already part of Emacs) instead of `acase'.  Learning
`pcase' will take some time, but it is worth it.

Lots of Lispers seems to hate these anaphoric macros and say they are
unlispy.  Lots of others love them.


> > I guess you already know that you have not chosen the easiest way to
> > understand backquote.  Anyway, you learn a lot of stuff with your
> > approach.  Looking forward the next version!
>
> Not the easiest, but more thorough.  I’m not satisfied with the “I kind
> of understand this... I guess” situation – if I can’t implement it,
> I don’t understand it.  (Unfortunately, the converse need not be true;
> I might be lucky and implement it without a full understanding, too...)

Actually, I think it is not unusual for Lisp programming that you invent
something, implement it, and understand it later.  The same is probably
true in some sense for Lisp itself.


Regards,

Michael.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]