From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: Easy to add with push but not to the end of a list Date: Fri, 09 Dec 2022 00:15:03 +0100 Message-ID: <87zgbxo5c8.fsf@web.de> References: <877czcid1d.fsf@web.de> <87a648kzov.fsf@dataswamp.org> <87cz93noqc.fsf@web.de> <87zgc76npf.fsf@dataswamp.org> <87k038npls.fsf@web.de> <87sfht8luq.fsf@dataswamp.org> <87h6y91ffg.fsf@web.de> <878rjlgvdd.fsf@dataswamp.org> <87bkoh1dix.fsf@web.de> <87wn75fdkx.fsf@dataswamp.org> <87bkog30ry.fsf@web.de> <87pmcwcghm.fsf@dataswamp.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6315"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 09 00:15:39 2022 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 1p3Q79-0001S0-0r for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 09 Dec 2022 00:15:39 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p3Q6g-00068n-Ux; Thu, 08 Dec 2022 18:15:10 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p3Q6f-00068e-GA for help-gnu-emacs@gnu.org; Thu, 08 Dec 2022 18:15:09 -0500 Original-Received: from mout.web.de ([212.227.17.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p3Q6c-00056T-FS for help-gnu-emacs@gnu.org; Thu, 08 Dec 2022 18:15:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1670541304; bh=mgVqi7jkzMhfBF//ulJOqa+5ugs8DG19Ml2vCbz/Vag=; h=X-UI-Sender-Class:From:To:Subject:In-Reply-To:References:Date; b=Vxpe3DeIj/eDxv7Jp6yFCSFqeJVKGX6G35humHkNYveqGC2ASIpxmtuusqXp00OZP sXPD4EP2j3GkQ8sor9sATJANEt2KB/WtogFI9wguNwY+iBXnC6+Ni6a+Q6+Ses5uEs y3qBWI3fBOHPJrkGCv2fTzTNbwS8w4cqEexZKk/0kicdlZhGoosdXmBMKuigKCEvOD 7Yy62LOv7a9CKLjdG0FZ+UgQZHbAqBLz3BWemjjExipyqe0+5mZcOrIJBZMdaasBAK FLbwTDSLBToVKJmdGQCq+x7QjviTOleNah12koB89WDBHXuxusdgVhpIYGFdgHe+8V oE5vkqoC6PUqA== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Original-Received: from drachen.dragon ([92.76.229.140]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MkVsa-1ofrJp4ARS-00mD1L; Fri, 09 Dec 2022 00:15:04 +0100 In-Reply-To: <87pmcwcghm.fsf@dataswamp.org> (Emanuel Berg's message of "Tue, 06 Dec 2022 23:30:29 +0100") X-Provags-ID: V03:K1:PlrY1fsM+hp4ApYNeT3jD0/1bFF+40HVTWudMb4y+CLKnT+DlFP gxAlPeArwpkIqQeE8W2//zgzHr5VweyDkZUysLcxGC9nqsevn+yLVOEuAEGHFbCrVfqKito xewL/G1MS0I6JggbyDHP3zE2nZxHSwHHKv4DoAniD3CYjJELRBJtYbM6wUHuw6m+27rmGlT hcKdZKevdL4gB8Twtacxg== UI-OutboundReport: notjunk:1;M01:P0:PG2Dj8umtEs=;UXllAdkAmyqZtdIorAetjWY7pIn EwJfCbGTMjVoevRfq6nvJ/l3WfS+FVQSraPO2SEuhVwMiPbZFqR18gc4dy04OBTe/fe0YYeWV zomQrF5jXWpa2cyx/7/hIcFTZTrHnxiyNLRJ0A9/KTU0BtVQMXK/h5+FR/BXUNYuWStTQxvIZ 9+1cxE60htuqBeNRuoiJlQrETnI9d9kt/pSPqQFFy0vC47JvzpS1OwcEYg4ZjR5y4JVsWHxFL Xcmtkxvd8/s6gx1uV6aEHJLU97UzJxF6dvDodAPoPDMWBNuQMMbSi0PgPer3EiafDavQalJRJ xBwZOgTLj0anKjKGoY6tfwoGzkCZdlENYBmXebPWPrqI/QlfPlIRyS9o1ePwh3QU7eczojMTE VHocrJRsoIYzyUQugl9s8RyxMB+YuuwplsHb0Yc8Pyzl03g/b7nbdKExmxC4ssB6TKX1aJbRd YlzG6Vt0hrjubkYq0FviL6oPY0+HZbjlcMfKHxStVHJnptTvrjq2YQVd5VT2Td//09eOwSqzE rrYkIXiGEifHQlJfFNs7Aq/Iw4g4wSmRMo/IZrNYHbj/ewjulpNfhDLvaq9GqX4Ukj6g1+4Dn tENOpen9D7U9BDBnkUg3j1h3XG1rISSFNjcXCMttHm5xGTZwDSr0JNcCvoEyFuDKeWXFQFWfb /8Q3TG9jdJPjqPVzJfY4uNeaFauDw/dMAcu8EZsKXLZ8JStBon9m3IBihXabvmKX9dvpBr+kH fGnH2OV6RQULpt0OlpCLbWcILcmx5fYAa32pEc9biIitciKpDcy7vmm4aGdn4/RV0Mc85RTJ Received-SPF: pass client-ip=212.227.17.12; envelope-from=michael_heerdegen@web.de; helo=mout.web.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=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.29 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-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:141483 Archived-At: Emanuel Berg writes: > In practice I didn't use them since these were better > suited ... > > (defun file-to-string (file) > "A string with the contents of FILE." > (interactive "Ffile: ") > (with-temp-buffer > (insert-file-contents file) > (string-trim > (buffer-substring-no-properties (point-min) (point-max)) ))) > > (defun file-to-integer (file) > (string-to-number (file-to-string file)) ) Yes, I wondered why you preferred a macro there at all. > > A second (related) problem is that FILE must be a string - > > a function call like (expand-file-name "my-file" > > "/some/path") will not behave as expected, because your > > helper functions don't expect an expression. > > Okay, but how do you check if it's an expression? That macro argument should better be evaluated (since not only strings make sense there), so it's _always_ an expression, even when it's a string (that happens to be a self-evaluating expression in this context). And you don't want to evaluate it at expansion time. That was your mistake several times. What's code normally goes into the expansion, maybe in the original or in a transformed form. Or it's dismissed. The macro is there to transform code, not to evaluate it, not even partially. Unless it's code actually needed to produce the expansion. These cases are rare. Be careful not to mix them up. > Also take a look at this, one should have a cache function and > a function to store arbitrary data and datastructures and the > corresponding to load seam-/losslessly into the same Lisp > datastructures all tho these are not the same/unaware of the ones > that was used (refered to) when saving ... What in particular is your question? You don't need to reinvent `eieio-persistent' btw because it already exists! It allows to save and restore more or less arbitrary objects and data; the implementation already supports a lot of different types. Michael.