unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: help-gnu-emacs@gnu.org
Subject: Re: Easy to add with push but not to the end of a list
Date: Fri, 09 Dec 2022 00:15:03 +0100	[thread overview]
Message-ID: <87zgbxo5c8.fsf@web.de> (raw)
In-Reply-To: <87pmcwcghm.fsf@dataswamp.org> (Emanuel Berg's message of "Tue, 06 Dec 2022 23:30:29 +0100")

Emanuel Berg <incal@dataswamp.org> 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.



  reply	other threads:[~2022-12-08 23:15 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-28  2:26 Easy to add with push but not to the end of a list Heime
2022-11-28  2:43 ` [External] : " Drew Adams
2022-11-28  3:45   ` Heime
2022-11-28  6:11     ` Drew Adams
2022-11-28 20:00   ` Emanuel Berg
2022-11-28  5:18 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-11-28 20:19   ` Emanuel Berg
2022-11-28 21:56     ` [External] : " Drew Adams
2022-11-28 22:45       ` Emanuel Berg
2022-11-28 22:01     ` Heime
2022-11-28 22:24       ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-11-28 22:58         ` Emanuel Berg
2022-11-30 14:10           ` tomas
2022-11-30 16:12             ` Emanuel Berg
2022-11-28 22:46       ` Emanuel Berg
2022-11-28 22:50       ` Emanuel Berg
2022-11-29  5:23       ` tomas
2022-11-29  5:32         ` Emanuel Berg
2022-11-29  7:56         ` Heime
2022-11-29  8:33           ` Marcin Borkowski
2022-11-29 10:00             ` Emanuel Berg
2022-11-29 10:05               ` Emanuel Berg
2022-11-29 10:15             ` Heime
2022-11-29  8:38           ` tomas
2022-11-29  9:54           ` Emanuel Berg
2022-11-29  8:17         ` Marcin Borkowski
2022-11-29  8:44           ` tomas
2022-11-29 12:08             ` Dr Rainer Woitok
2022-11-29 19:54               ` Of cars and mice [was: Easy to add with push but not to the end of a list] tomas
2022-11-30  1:17                 ` Emanuel Berg
2022-11-30  1:13               ` Easy to add with push but not to the end of a list Emanuel Berg
2022-11-28 19:59 ` Emanuel Berg
2022-11-28 21:56   ` [External] : " Drew Adams
2022-11-28 22:18     ` Heime
2022-11-28 22:41       ` Drew Adams
2022-11-29 11:17   ` Dr Rainer Woitok
2022-11-30 17:10 ` Michael Heerdegen
2022-11-30 18:17   ` [External] : " Drew Adams
2022-11-30 19:30   ` Emanuel Berg
2022-12-01 15:11     ` Michael Heerdegen
2022-12-01 17:25       ` Emanuel Berg
2022-12-03 21:29         ` Michael Heerdegen
2022-12-05 23:35           ` Emanuel Berg
2022-12-06  1:36             ` Michael Heerdegen
2022-12-06  1:43               ` Emanuel Berg
2022-12-06  2:17                 ` Michael Heerdegen
2022-12-06  2:40                   ` Emanuel Berg
2022-12-06 13:56                     ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-06 14:45                     ` Michael Heerdegen
2022-12-06  2:52                   ` Emanuel Berg
2022-12-06 17:22                     ` Michael Heerdegen
2022-12-06 22:30                       ` Emanuel Berg
2022-12-08 23:15                         ` Michael Heerdegen [this message]
2022-12-28 23:52                           ` Emanuel Berg
2022-12-31 16:57                             ` Michael Heerdegen
2022-12-31 22:09                               ` Emanuel Berg
2023-01-01 12:16                                 ` Michael Heerdegen
2023-01-08  4:40                                   ` Emanuel Berg
2023-01-09  6:32                                     ` Emanuel Berg
2023-01-14 12:05                                       ` Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zgbxo5c8.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).