all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: tomas@tuxteam.de
Cc: Michael Heerdegen <michael_heerdegen@web.de>, help-gnu-emacs@gnu.org
Subject: Re: How to tame compiler?
Date: Sun, 2 May 2021 21:17:01 +0300	[thread overview]
Message-ID: <YI7sndseCULWukit@protected.localdomain> (raw)
In-Reply-To: <20210502122427.GD16372@tuxteam.de>

* tomas@tuxteam.de <tomas@tuxteam.de> [2021-05-02 15:25]:
> Well, I offered a suggestion. Write your limited version of eval,
> which makes available the substitutions (values or functions)
> you intend to use in your template, for example in a dictionary
> (aka hash). That's what other templating systems do, even in
> languages which do have eval (that's why I provided examples in
> Perl and Python).

I did use that for years. The new approach seem so much simpler and
liberating, it lessens the work.

> The S-expression proposal is orthogonal to the problem at hand.
> That's why I didn't propose it (although it does have some advantages
> of its own).

As my system supports any type of markup, I can include that as
well. Again I would be reading it with `read-from-string' straight
from the database, and then using `eval'.

S-expression text has to be stored somewhere, right? It has to be
loaded from somewhere, so majority would be loading it from file I
guess, I am loading it from the database and again I have to use
`eval'. The purpose not to use `eval' defeats itself how I see it as I
have to use `eval'.

Let us say database table is named: pages, there is column pages_text,
if it contains string like "(p \"Hello there\")" -- I have to
`read-from-string` and `eval' or maybe there exists some other way?

What would you do? Would you load it from file?

I am thinking, what would be the difference of loading it from file,
or using `eval', I cannot find the difference, I wish I could.

> It's too subtle to be covered by "just one simple example", that's why
> I proposed you do some research.

I did that research years ago. Do we have any practical use of
declining to use specific function without being able to tell why?

On the other hand, thousands of people use `eval' in Org mode as a
good example, and not for Emacs Lisp only.

If we wish to remedy the situation we would need maybe to find safer
`eval' but before finding safer `eval' we have to know why exactly is
this one not safe as compared to whatever proposed replacement
methods. 

> > I understand so far:
> > 
> > - there are opposing arguments to `eval', but...
> 
> Let me put that this way: to do a good job, the compiler makes
> assumptions on things like variable bindings ("this variable can
> only be seen in this part of the code I analysed right now"). When
> an eval is in the middle of things, the compiler can't "see
> through": the code therein can change at run time. All bets are off.

I understand, compiler will not be able to see through.

> Just imagine a (let ((x 5) ...) and then an eval whithin that with
> a form (setq x 6).

Good example, thank you.

That would be `eval' within a program. My `eval' takes place within a
text. It does not necessarily change program, I do not know if it
would be possible, I can try.

(let ((variable "Gully")
      (my-value 0)
      (template "⟦ variable ⟧ ⟦ (setq my-value 1) ⟧"))
  (rcd-template-eval template)) ⇒ "Gully 1"

Now I can see that I can change program values from within `eval'
in the template. On the other hand, I can change values also
within the program. The safety is thus in the decision making of
authors, not in `eval' itself.

> > - there is no replacement for `eval' in the context of templates with
> >   programming code; or other contexts;
> 
> There is. See my examples.

Do you mean example of passing a hash?


-- 
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/
https://rms-support-letter.github.io/




  reply	other threads:[~2021-05-02 18:17 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-22 14:43 How to tame compiler? Jean Louis
2021-04-22 14:46 ` Stefan Monnier
2021-04-22 15:47   ` Jean Louis
2021-04-22 16:06   ` Jean Louis
2021-04-30 13:31   ` Jorge P. de Morais Neto
2021-04-30 19:38     ` rcd-template-eval - was " Jean Louis
2021-04-30 19:48     ` rcd-template-eval, much is in Org mode Jean Louis
2021-04-30 20:06       ` Tassilo Horn
2021-04-30 22:08       ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-04-30 23:04         ` Org mode rant Jean Louis
2021-05-01  0:46           ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-01  6:10             ` Jean Louis
2021-05-01  6:34               ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-01  9:41                 ` On markdown images Jean Louis
2021-05-01  9:59                   ` Yuri Khan
2021-05-01 10:18                     ` Jean Louis
2021-05-01 11:09                       ` Yuri Khan
2021-05-01 11:25                         ` Jean Louis
2021-05-02 19:30                         ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-03  5:43                           ` Yuri Khan
2021-05-03 17:08                             ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-03 23:22                               ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-04  2:39                   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-01  5:00           ` Org mode rant Bastien
2021-05-01  5:10             ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-01  9:16             ` Jean Louis
2021-05-01 10:06               ` Bastien
2021-05-01 10:42                 ` Jean Louis
2021-05-01 10:10               ` Bastien
2021-05-01 11:19                 ` Jean Louis
2021-05-01 13:48                 ` [External] : " Drew Adams
2021-05-01 14:05                   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-01 10:10               ` Bastien
2021-04-30 20:23     ` eval myths - Re: How to tame compiler? Jean Louis
2021-04-30 22:11       ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-04-30 23:07         ` Jean Louis
2021-05-01  0:28           ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-01  8:13       ` tomas
2021-04-30 22:06     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-04-30 22:20       ` Stefan Monnier
2021-04-30 22:31         ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-04-30 22:50           ` Stefan Monnier
2021-04-30 22:56             ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-01  0:44 ` Michael Heerdegen
2021-05-01  3:49   ` Stefan Monnier
2021-05-01  4:55     ` Michael Heerdegen
2021-05-01  6:34     ` Jean Louis
2021-05-01 13:38       ` Stefan Monnier
2021-05-01 16:19         ` Jean Louis
2021-05-02  5:41     ` Michael Heerdegen
2021-05-02  7:37       ` Jean Louis
2021-05-02  7:45       ` Jean Louis
2021-05-02  9:06         ` tomas
2021-05-02 11:18           ` Jean Louis
2021-05-02 12:24             ` tomas
2021-05-02 18:17               ` Jean Louis [this message]
2021-05-02 12:06           ` Stages of WWW development compared to Emacs Lisp development Jean Louis
2021-05-02 16:51             ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-02 18:37               ` Jean Louis
2021-05-02 16:45       ` How to tame compiler? Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-02 22:29       ` Stefan Monnier
2021-05-02 23:14         ` Jean Louis
2021-05-03  1:58           ` Eduardo Ochs
2021-05-03  6:51             ` Eval in templates - " Jean Louis
2021-05-01  4:53   ` Michael Heerdegen
2021-05-01  7:05     ` Jean Louis
2021-05-01  7:59       ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-01  6:03   ` Jean Louis
2021-05-01  6:17     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-02  5:58     ` Michael Heerdegen
2021-05-02  6:54       ` Jean Louis
2021-05-03 21:39       ` Jean Louis

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

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

  git send-email \
    --in-reply-to=YI7sndseCULWukit@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=help-gnu-emacs@gnu.org \
    --cc=michael_heerdegen@web.de \
    --cc=tomas@tuxteam.de \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.