From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.devel Subject: Re: `unreadablep' Date: Wed, 15 Dec 2021 21:21:05 +0100 Message-ID: References: <87bl1imhnd.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25662"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Emacs developers To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 15 21:22:12 2021 Return-path: Envelope-to: ged-emacs-devel@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 1mxamx-0006Sr-Sp for ged-emacs-devel@m.gmane-mx.org; Wed, 15 Dec 2021 21:22:11 +0100 Original-Received: from localhost ([::1]:54178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxams-0002jo-Vb for ged-emacs-devel@m.gmane-mx.org; Wed, 15 Dec 2021 15:22:07 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:58466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxam7-0001qV-Kz for emacs-devel@gnu.org; Wed, 15 Dec 2021 15:21:19 -0500 Original-Received: from [2607:f8b0:4864:20::32c] (port=33401 helo=mail-ot1-x32c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mxam6-0003kA-8N for emacs-devel@gnu.org; Wed, 15 Dec 2021 15:21:19 -0500 Original-Received: by mail-ot1-x32c.google.com with SMTP id 35-20020a9d08a6000000b00579cd5e605eso26398656otf.0 for ; Wed, 15 Dec 2021 12:21:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HQmGG4DyvY+CxyXl+dYkqXwSPFoWXcO5yycmDNZUqdg=; b=KMLIjp3MgmDaNhaUgVlmELTB9XrqKtikocfVIvrhozzRAIekaZoCuXk+MuxExxu/bD 7N3loC7mdm+WvuRQgH/5MIu0Wq9nSStiUC6FnSelaJGkdLN5klORGnm+ps38LKtxijkp 9SbhtJ5zz35KdwllsuZf8wVNRxIH9+/U1hLIw3BPMtjChYpEJShX+UJRbIhJKCx3JsYD tbsdUzEKOCj40nEFvDyjqWga8jLx5uGZS2tWioy5sfNFXJnFbIX/u5Owm9VeIAFFSZto 49Bme8yoJZdzCV/Q/oUhc0zVrDnM8LcvdmU1Tps/psug61uITQbvNjdN3+TFybU5M/bc 9NEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HQmGG4DyvY+CxyXl+dYkqXwSPFoWXcO5yycmDNZUqdg=; b=Bp8bHlj1JDWh7Q/WpkE5FFEnUHyOkqT4+zLWd4wdJ6+7K5zVgdo8mkdrEbiZu8bHE6 Ze4dHTpIa7yBFmG0XzXgEDI+7UtzwbtseGceNl6+tpaa+MevOocsgH9GqVJ9HO1DIgQZ o8CX9EDGkXx9DrS6QCFeiGPGWo7VHVMaMjj2zFxnNZNWpS1JgxyH0wcm5CDaWovm1t4l JPpvGTGUWHQ1e5fWlpEZclIKnQUCUO0xezwk93V9+ehj3MSmBGqaEJ0GWQLxzIFysB+Z v+GYtVBUqW/+5rwbGRnS1SRNy9tjSoSFmi3Bv4io83B+s+Sa/RBsB16ROZ3oYGu3yaKl IXhg== X-Gm-Message-State: AOAM5335ph6+HBaJatMWdBLl0RPpoNMZkSSEFGNz8Kdyk61VEey0tcSc dpZCZeZ2mKfwCY4wL9+LMk/Zlrqr4kwAAiWAHwA= X-Google-Smtp-Source: ABdhPJwlKzYGha4FzdziA2rnAXAT4i770W+6ziMxr7Fcl4JFuLnzkBGpOmYnuFSsqOVG5hMX/9FlJQPGUD0Q5U4S8y8= X-Received: by 2002:a05:6830:2019:: with SMTP id e25mr10452750otp.96.1639599676434; Wed, 15 Dec 2021 12:21:16 -0800 (PST) In-Reply-To: <87bl1imhnd.fsf@gnus.org> X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::32c (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::32c; envelope-from=p.stephani2@gmail.com; helo=mail-ot1-x32c.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:282079 Archived-At: Am Mi., 15. Dez. 2021 um 09:16 Uhr schrieb Lars Ingebrigtsen : > It would be nice to have such a function (i.e., that says whether it can > be read back after printing it). Yes, this would be useful in many places where we need to serialize Lisp objects (e.g. for the sandbox stuff). > The problem is, of course, complex > structures that require recursing (and then checking for loops), etc, so > you basically have to implement it the way printing is done if you want > it to be fast, I think? It's a DFS of a DAG, not quite rocket science. The difficulty is rather in getting the details right (e.g. you can't allow symbols interned in a non-default obarray because you wouldn't get the same symbol back). > I wonder whether this could be efficiently implemented by, say, having > some kind of special value for PRINTCHARFUN for prin1, but I haven't > looked at the code yet. Maybe just introduce another C function `prin1-if-readable' or so that errors out (with a specific error symbol so that callers can catch it) if the object can't be printed in a readable way. That should also bind the print variables correctly (e.g. bind print-level to nil) so ensure that the result really represents an equivalent List object. The new function would likely reuse the existing `print' machinery, with the `escapeflag' parameter turned into a generic `flags' enum. I guess it would make sense to also forbid some "exotic" objects (circular objects, uninterned symbols) that rarely make sense to serialize.