From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: How to tame compiler? Date: Sun, 2 May 2021 21:17:01 +0300 Message-ID: References: <875z03th9b.fsf@web.de> <87v981wv3f.fsf@web.de> <20210502090647.GB9577@tuxteam.de> <20210502122427.GD16372@tuxteam.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18748"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.0.6 (2021-03-06) Cc: Michael Heerdegen , help-gnu-emacs@gnu.org To: tomas@tuxteam.de Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 02 20:25:26 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ldGmT-0004mE-E3 for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 02 May 2021 20:25:25 +0200 Original-Received: from localhost ([::1]:44354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldGmS-0006h1-G7 for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 02 May 2021 14:25:24 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldGgF-0004FM-IE for help-gnu-emacs@gnu.org; Sun, 02 May 2021 14:18:59 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:41575) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldGg7-0005QE-3t for help-gnu-emacs@gnu.org; Sun, 02 May 2021 14:18:59 -0400 Original-Received: from localhost ([::ffff:154.227.44.235]) (AUTH: PLAIN securesender, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 0000000000046165.00000000608EED06.00001475; Sun, 02 May 2021 11:18:45 -0700 Mail-Followup-To: tomas@tuxteam.de, Michael Heerdegen , help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: <20210502122427.GD16372@tuxteam.de> Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:129343 Archived-At: * 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/