From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: "Backquote constructs" to "splice" values without "eval". Date: Mon, 07 Jan 2013 15:51:26 -0500 Organization: A noiseless patient Spider Message-ID: References: NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1357592111 26379 80.91.229.3 (7 Jan 2013 20:55:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 7 Jan 2013 20:55:11 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jan 07 21:55:28 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TsJjE-0007xu-C2 for geh-help-gnu-emacs@m.gmane.org; Mon, 07 Jan 2013 21:55:28 +0100 Original-Received: from localhost ([::1]:57647 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsJiy-00049O-U5 for geh-help-gnu-emacs@m.gmane.org; Mon, 07 Jan 2013 15:55:12 -0500 Original-Path: usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-2.dfn.de!news.dfn.de!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 55 Injection-Info: barmar.motzarella.org; posting-host="78fb7125a45724f15e21604c94a7d968"; logging-data="9216"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18luE47ZY3jHsK3W4wIhCMJ" User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Cancel-Lock: sha1:Svkag9R4XaCT65dvlFH3ROufLu8= Original-Xref: usenet.stanford.edu gnu.emacs.help:196205 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:88508 Archived-At: In article , Oleksandr Gavenko wrote: > On 2013-01-07, Barry Margolin wrote: > > >> I construct TLV (table-len-val) structs in string. > >> > >> Is it possible to omit "eval" from second line by using some sugar code: > >> > >> (setq binstr-len 4) > >> (setq binstr (eval `(unibyte-string ?s binstr-len ,@(make-list binstr-len > >> ?x)))) > >> (assert (eq (+ 2 binstr-len) (length binstr))) > >> > >> Another solution: > >> > >> (setq binstr (concat (unibyte-string ?s binstr-len) (make-list binstr-len > >> ?x))) > >> > >> Or "apply" stands for this purpose(??): > >> > >> (setq binstr (apply 'unibyte-string ?s binstr-len (make-list binstr-len > >> ?x))) > > > > The "apply" solution is usually the correct way to do it. > > I also start thinking about "apply" with several list inside it: > > (apply '+ 1 '(2) '(3 4)) > > But above expression fail (only last arg expanded as list of args). To resolve > this issue I use expression: > > (apply '+ 1 (append '(2) '(3 4))) > > But how about expression with atoms between (??): > > '(1) 2 '(3 4) > > I write non-linear code: > > (apply '+ (append '(1) (cons 2 '(3 4)))) > > How to avoid call to "cons"? Now you can go back to using backquote to construct the list: (apply #'+ `(,@'(1) 2 ,@'(3 4))) But you still don't need to use eval. -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me ***