From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis <bugs@gnu.support> Newsgroups: gmane.emacs.help Subject: Re: How to tame compiler? Date: Sat, 1 May 2021 09:34:06 +0300 Message-ID: <YIz2Xs14+Y4tmPTX@protected.localdomain> References: <courier.0000000060818B9B.00007ACB@stw1.rcdrun.com> <875z03th9b.fsf@web.de> <jwvwnsj5d4y.fsf-monnier+emacs@gnu.org> 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="7848"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.0.6 (2021-03-06) Cc: help-gnu-emacs@gnu.org To: Stefan Monnier <monnier@iro.umontreal.ca> Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat May 01 08:39:36 2021 Return-path: <help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org> 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 <help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org>) id 1lcjHr-0001xC-PN for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 01 May 2021 08:39:35 +0200 Original-Received: from localhost ([::1]:55076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org>) id 1lcjHq-0007CE-SP for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 01 May 2021 02:39:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50608) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <bugs@gnu.support>) id 1lcjHA-0007C4-PI for help-gnu-emacs@gnu.org; Sat, 01 May 2021 02:38:52 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:36693) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <bugs@gnu.support>) id 1lcjH8-0001uN-HO for help-gnu-emacs@gnu.org; Sat, 01 May 2021 02:38:52 -0400 Original-Received: from localhost ([::ffff:154.231.162.22]) (AUTH: PLAIN securesender, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 0000000000046239.00000000608CF776.00002062; Fri, 30 Apr 2021 23:38:46 -0700 Mail-Followup-To: Stefan Monnier <monnier@iro.umontreal.ca>, help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: <jwvwnsj5d4y.fsf-monnier+emacs@gnu.org> 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 <help-gnu-emacs.gnu.org> List-Unsubscribe: <https://lists.gnu.org/mailman/options/help-gnu-emacs>, <mailto:help-gnu-emacs-request@gnu.org?subject=unsubscribe> List-Archive: <https://lists.gnu.org/archive/html/help-gnu-emacs> List-Post: <mailto:help-gnu-emacs@gnu.org> List-Help: <mailto:help-gnu-emacs-request@gnu.org?subject=help> List-Subscribe: <https://lists.gnu.org/mailman/listinfo/help-gnu-emacs>, <mailto:help-gnu-emacs-request@gnu.org?subject=subscribe> Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" <help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org> Xref: news.gmane.io gmane.emacs.help:129259 Archived-At: <http://permalink.gmane.org/gmane.emacs.help/129259> * Stefan Monnier <monnier@iro.umontreal.ca> [2021-05-01 06:50]: > > Independent from the question whether your usage of `eval' is good or > > valid - there must be some real problem here: if the compiler tells that > > the lexical variables are unused, their values will not be available in > > you `eval' call - you would have to create dynamical bindings for that. > > I know I sound like a broken clock, but I think a better answer is to > avoid `eval`: instead of taking expressions (that you'd pass to `eval`) > arrange to receive functions (which you'd pass to `funcall` or `apply`). > Then you can pass those functions the data they need (e.g. the value of > things like `unsubscribe-text`). I have to understand it in this example: The HTML template is following and it is string: <html> <head> <title>⟦ xml-escape title ⟧</title> </head> <body> <p>Today is one US dollar this many euros: ⟦ usd-eur 1 ⟧</p> </body> </html> > I know I sound like a broken clock, but I think a better answer is to > avoid `eval`: instead of taking expressions (that you'd pass to `eval`) > arrange to receive functions (which you'd pass to `funcall` or `apply`). > Then you can pass those functions the data they need (e.g. the value of > things like `unsubscribe-text`). Does that mean I should now extract maybe function `xml-escape' and use apply with rest of arguments? Maybe instead of: <title>⟦ xml-escape title ⟧</title> I should make: <title>⟦ xml-escape title ⟧</title> And then apply xml-escape with "title". Then I would convert first word into function, that somehow works, but all the remaining parts of string still need to be converted. How is program to know that things in a string are for example other variables or other Lisp functions? (let* ((lisp (buffer-substring-no-properties (1+ (match-beginning 0)) (1- (match-end 0)))) (lisp (split-string lisp)) (function (pop lisp)) (_ (message "%s" function)) (value (apply (intern function) lisp)) ;; I am stuck here (value (string-or-empty-string value))) For simplest use case like converting string to variable, or something like: ⟦ var hello-name ⟧ I think that would work, but then if I only use variables, I would not need "var" there, I could just interpolate it into variable without eval. For the case where there is even slightly complex Lisp like ⟦ (usd-eur (gold-price-kg)) ⟧ I would not know what to do there. Maybe it could look like: ⟦ usd-eur (gold-price-kg) ⟧ But then again program would receive string "(gold-price-kg)" and how would I know that string is another function? I would need to extract that string and basically make small Lisp reader, again we come to kind of eval-ing it. I want to know if there is way to do it. -- 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/