From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleksandr Gavenko Newsgroups: gmane.emacs.help Subject: Re: "Backquote constructs" to "splice" values without "eval". Date: Mon, 07 Jan 2013 22:36:23 +0200 Organization: Oleksandr Gavenko , http://gavenkoa.users.sf.net Message-ID: <87sj6cspbs.fsf@gavenkoa.example.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1357591017 14697 80.91.229.3 (7 Jan 2013 20:36:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 7 Jan 2013 20:36:57 +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:37:14 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 1TsJRa-000056-6r for geh-help-gnu-emacs@m.gmane.org; Mon, 07 Jan 2013 21:37:14 +0100 Original-Received: from localhost ([::1]:41095 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsJRK-0003Iu-Jx for geh-help-gnu-emacs@m.gmane.org; Mon, 07 Jan 2013 15:36:58 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:54812) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsJR8-0002o4-2q for help-gnu-emacs@gnu.org; Mon, 07 Jan 2013 15:36:47 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TsJR7-0005Ez-4d for help-gnu-emacs@gnu.org; Mon, 07 Jan 2013 15:36:45 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:43909) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsJR6-0005Ev-Th for help-gnu-emacs@gnu.org; Mon, 07 Jan 2013 15:36:45 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1TsJRD-00080Q-DT for help-gnu-emacs@gnu.org; Mon, 07 Jan 2013 21:36:51 +0100 Original-Received: from 37.229.4.200 ([37.229.4.200]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 07 Jan 2013 21:36:51 +0100 Original-Received: from gavenkoa by 37.229.4.200 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 07 Jan 2013 21:36:51 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 44 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 37.229.4.200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) Cancel-Lock: sha1:jKYxuvZKzOd8XPKObg/6qQp0vww= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:88507 Archived-At: 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"? -- Best regards!