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

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

Re: [External] : Supplying DOC string in a `defun' using `defvar'


From: Jean Louis
Subject: Re: [External] : Supplying DOC string in a `defun' using `defvar'
Date: Thu, 3 Jun 2021 12:19:32 +0300
User-agent: Mutt/2.0.7+183 (3d24855) (2021-05-28)

* Eduardo Ochs <eduardoochs@gmail.com> [2021-06-03 10:24]:
> On Thu, 3 Jun 2021 at 03:52, Jean Louis <bugs@gnu.support> wrote:
> >
> > And I have a package as RCD Template Interpolation System for Emacs
> > https://hyperscope.link/3/7/1/3/3/RCD-Template-Interpolation-System-for-Emacs.html
> >
> > that is separate package because I keep it dynamically not lexically,
> > with intention. It is used in business to personalize emails and
> > communication, like yesterday 756 times. There is no lexical bindings
> > involved and currently I don't know how would I implement it with
> > lexical bindings involved. I hope dynamic bindings will never go.
> 
> 
> Me too.
> 
> I use - zillions of times a day - a template function that is
> intrinsically incompatible with lexical binding - this one:
> 
>   http://angg.twu.net/eev-current/eev-template0.el.html
> 
> and I believe that dynamic binding is much easier to understand and to
> explain than lexical binding... also, I interact with beginners a lot,
> and currently what I say to them is: "learn dynamic binding first,
> even though it is being sort of deprecated, and don't try to use
> lexical binding until you have at least one week of experience with
> Emacs Lisp... after that you'll be able to compare the two and lexical
> binding will make much more sense".
> 
> I really hope that people realize the dynamic binding is great as an
> educational tool, and that they will keep it available forever, with
> all the adequate warnings and caveats - "for the sake of the
> secretaries"... see:
> 
>   https://www.gnu.org/software/emacs/emacs-paper.html#SEC29

>From same document:
https://www.gnu.org/software/emacs/emacs-paper.html#SEC17

It is not necessary for dynamic scope to be the only scope rule
provided, just useful for it to be available.

(defun foo1 (x) (foo2))
(defun foo2 () (+ x 5))
(foo1 1) ⇒ 6
(foo2)

More information from the same document:

Formal Parameters Cannot Replace Dynamic Scope

Some language designers believe that dynamic binding should be
avoided, and explicit argument passing should be used instead. Imagine
that function A binds the variable FOO, and calls the function B,
which calls the function C, and C uses the value of FOO. Supposedly A
should pass the value as an argument to B, which should pass it as an
argument to C.

This cannot be done in an extensible system, however, because the
author of the system cannot know what all the parameters will
be. Imagine that the functions A and C are part of a user extension,
while B is part of the standard system. The variable FOO does not
exist in the standard system; it is part of the extension. To use
explicit argument passing would require adding a new argument to B,
which means rewriting B and everything that calls B. In the most
common case, B is the editor command dispatcher loop, which is called
from an awful number of places.

What's worse, C must also be passed an additional argument. B doesn't
refer to C by name (C did not exist when B was written). It probably
finds a pointer to C in the command dispatch table. This means that
the same call which sometimes calls C might equally well call any
editor command definition. So all the editing commands must be
rewritten to accept and ignore the additional argument. By now, none
of the original system is left!

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

Sign an open letter in support of Richard M. Stallman
https://stallmansupport.org/



reply via email to

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