unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Kent M Pitman <pitman@world.std.com>
Subject: Re: Differences between Elisp and Lisp
Date: 29 Apr 2003 12:44:22 -0400	[thread overview]
Message-ID: <sfwy91tw8wp.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: vfllxtz49b.fsf@rpc71.cs.man.ac.uk

Phillip Lord <p.lord@russet.org.uk> writes:

> >>>>> "Kent" == Kent M Pitman <pitman@world.std.com> writes:
> 
>   Kent> Thomas Link <samul@web.de> writes:
> 
>   >> > I thought that CL already implemented lexical binding? At least
>   >> >within a let form (or "lexical-let").
>   >> I guess it's faking lexical binding by replacing variable names
>   >> with gensyms. This makes it pseudo-lexical but not more
>   >> efficient.
> 
>   Kent> In addition to having questionable efficiency issues, such a
>   Kent> strategy also eliminates the one primary reason that more than
>   Kent> anything justifies lexical scoping--the ability to know 'just
>   Kent> by looking' that no other uses of the variable exist and that
>   Kent> it's ok to optimize. 
> 
> Perhaps I am confusing things here, but I always assumed that the
> problem with dynamic binding is that it makes odd things happen.

You're saying the same thing as I was saying only in different words.
Both the efficiency loss and this other effect you cite (accessibility
from outside) are effects of having the name be accessible from the
outside.  In general, both a programmer and a compiler have the same
interest--to know when they see a binding or a reference or an assignment
whether the variable involved is private or public.  When you make the 
default be 'public', the problem is that lots of things get made public
that don't need to be, and this both makes it hard to optimize and 
makes it likely that errors will creep in due to unwanted assignments
or even sometimes unwanted reads.

> So take...
> 
> (defvar x 1)
> 
> (defun test()
>   (let ((x 10))
>     (test2)
>     (message "test: %s" x)))
> 
> (defun test2()
>   (setq x 20))
> 
> (test)
> 
> x
> 
> 
> Eval'ing (test) gives "test: 20", and x gives 1.
> If you change the let to lexical-let you get
> "test:10" and "20". This seems much more intuitive to me. Of course
> its useful to be able to "subvert" the setq in test2 to not work on
> the main defvar defined x, and I've used this occasionally. But in
> general its likely to result in program errors, as the test function
> needs to know that none of the functions it use a variable called x.
> 
> Optimisation might be an issue as well of course, but processors are
> fast these days! Its nice, but not essential. 

This sort of assumes a single-user machine.  Server machines can be
overloaded regardless of capacity.  Efficiency determines the 
the size of the working set, the number of processes you can give the 
illusion of running at the same time when time-slicing, etc.  Ultimately,
when a server is overloaded, you have to buy a new machine.  It's nice to
stave this off by not being gratuitously inefficient.  Further, even on
a single-user machine,  if you have other programs running in background
(whether that means trying to get some editing done in Emacs during
the half hour it takes Photoshop to start, or it means playing some 
compute-intensive video game on the same processor where you're editing),
efficiency can still matter.

You might assume emacs is not a server, but one of the good effects of
merging CL and emacs might be that emacs could do more tasks that are
often relegated to other programs and that those other programs could get
some of the services emacs usually does.  So the lines might get blurred.

  reply	other threads:[~2003-04-29 16:44 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.5343.1051607007.21513.help-gnu-emacs@gnu.org>
2003-04-29 10:22 ` Differences between Elisp and Lisp Friedrich Dominicus
2003-04-29 10:27 ` Lars Magne Ingebrigtsen
2003-04-29 10:35   ` David Kastrup
2003-04-29 11:03   ` Oliver Scholz
2003-04-29 12:23     ` Phillip Lord
2003-04-29 14:17       ` Thomas Link
2003-04-29 15:43         ` Kent M Pitman
2003-04-29 15:56           ` Phillip Lord
2003-04-29 16:44             ` Kent M Pitman [this message]
2003-04-29 17:16               ` Phillip Lord
2003-04-29 18:41                 ` Kai Großjohann
2003-04-30 12:39                   ` Phillip Lord
2003-04-30 13:12                     ` Kai Großjohann
2003-04-30 18:07                     ` Kevin Rodgers
2003-04-29 18:59             ` Oliver Scholz
2003-04-30 12:43               ` Phillip Lord
2003-04-29 17:01       ` Kai Großjohann
2003-04-30 23:02   ` Stefan Monnier
2003-05-01  5:22     ` Lars Magne Ingebrigtsen
2003-05-01  5:41       ` Friedrich Dominicus
2003-05-01  5:54         ` Lars Magne Ingebrigtsen
2003-05-01  6:37           ` [OT] " Friedrich Dominicus
     [not found] ` <yoijznm9y5yr.fsf@bilbo.dd.chalmers.se>
2003-04-29 13:45   ` Kent M Pitman
2003-04-29 15:23     ` Nicolas Neuss
2003-04-29 15:28       ` Nicolas Neuss
2003-04-29 14:23   ` Marco Antoniotti
2003-04-29 14:29     ` Phillip Lord
2003-04-29 19:06       ` Oliver Scholz
2003-04-29 16:51 ` Kaz Kylheku
2003-04-29  8:57 Daniel R. Anderson

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sfwy91tw8wp.fsf@shell01.TheWorld.com \
    --to=pitman@world.std.com \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).