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

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

Re: Closures - do you understand them well?


From: tomas
Subject: Re: Closures - do you understand them well?
Date: Fri, 23 Dec 2022 07:27:38 +0100

On Thu, Dec 22, 2022 at 05:00:25AM +0100, Emanuel Berg wrote:
> tomas wrote:
> 
> > Just at macro expansion (aka compile) time
> 
> Side question, how many 'times' are there and what,
> at least conceptually, happens in each? Figure or ascii
> diagram, anyone?

It's turtles [1] all the way down! Since you have eval,
you are empowered to compile at run time and thus have
a compile time in there. Still, there are (at least) two
phases (at least whenever you have anything more than
"just" a naive interpreter), one where your "source" is
being analysed to find opportunities ("this variable is
always bound to 3 here [2] (or to the identity fun, or...)
so we can roll that constant into the compile product"),
and the run time, where that product is "run".

> > Welcome to Lisp's multiple personality :-)
> 
> Explain :-) :-(

Other languages (e.g. C) have clearly distinct sub-languages
to do things at compile time (C, again, has CPP, which is
clearly distinct from C proper). In Lisp, you can use Lisp
at compile time (the language you use to transform your
source is Lisp), but at the same time, your environment is
completely different at those two phases. Some go as far
as to say that they are different languages. Typically there
are devices to control that (in Emacs Lisp `eval-when-compile'
and `eval-and-compile', I'll let more knowledgeable folks
chime in and complete that list).

Cheers

[1] https://en.wikipedia.org/wiki/It%27s_turtles_all_the_way_down
[2] That's why lexical is easier for optimising compilers
-- 
t

Attachment: signature.asc
Description: PGP signature


reply via email to

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