Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107900 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 59833 invoked from network); 6 Dec 2019 12:32:18 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 6 Dec 2019 12:32:18 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 1B8822C50E5 for ; Fri, 6 Dec 2019 02:29:26 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Fri, 6 Dec 2019 02:29:25 -0800 (PST) Received: by mail-lj1-x229.google.com with SMTP id u17so7119598lja.4 for ; Fri, 06 Dec 2019 02:29:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bCM4bZc/1kwuiAisVNxXMKYo57L3BLsWYFmcUXnj6vg=; b=m7TlI4qfbIYG7wbITAK3ih6yElUQb1HqZbIC3bfvjMoMTkpKNH1+SFTre9YRX9b/AG XpMMGnpJfKKT65FWnSN1WI+1Nb6DJhrakEcA7zMnzlV5viY52bI7Ag2xfW3qJDz2w9es WRvW8F0TCLP3S1+ridWh0KqNmjWyLplSwSmif58ApzpZQvyVv+R3327hJevLgOa+xW8Y aiBgizH+SYXSdMaoGhw+8ztlhwTVGcIEHFZEwiSnYbs4zHT26JMpDQ69c9Sda9h6suuy oHkHahNxnrOsCL6rHRSiPFl+RnG1Ivan8dfC4bvfzndf/clKwK4Ljqe+8u/MGTLFWQpd e1Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bCM4bZc/1kwuiAisVNxXMKYo57L3BLsWYFmcUXnj6vg=; b=tceeRSpuQkx3u1iN0mJar9DDqoS+BjxhJ+SrU7LKeeoZags3r5YymqShJ80hC+A/7p p772iTP+5E6Fs4fFlEhPrV0iA2WgCfhsGVSLcowQRvfIE2RA03sfgHUF/ONQscJFD8S2 YNxrjUI5/IVfb/Bx22Ed483azOQE8IYUwVk8Rda/49W9eyFKInIQRVmgu7lqV4JooIHi 7mHGUkTnY0Aqlhg1yIyFStReVjHZJl0S4CgzUkRoN+rGJ3tOfyORvWYfuVF5xJwfpAj7 jRnFMtRXyb587BYhton9pw0NBiOiYLPvzQ7yEQ9s01fgLsXxRGsEHObIWsnL9ud8jVmv Dkag== X-Gm-Message-State: APjAAAXO/hjyiGuusvIBsOn3nwK439t5QAKjt0n2UhCEBSADRtcHe6mP mRlo9Y2rDEF74Ub7OYc5eeTvb+YnZxAxlOYLIThK+hvC X-Google-Smtp-Source: APXvYqztUtr/0gnMnydinnhf6bMZ2wEzkA2KW3HoQ07FN2/iOvynOk4ej51HyZDIpq6FfztwjMGB6BLi36kLHAjUDOg= X-Received: by 2002:a2e:8606:: with SMTP id a6mr8200537lji.119.1575628163883; Fri, 06 Dec 2019 02:29:23 -0800 (PST) MIME-Version: 1.0 References: <1d2d5c23-3864-a202-92a8-34228798510d@birkholz.biz> In-Reply-To: <1d2d5c23-3864-a202-92a8-34228798510d@birkholz.biz> Date: Fri, 6 Dec 2019 11:29:07 +0100 Message-ID: To: Dennis Birkholz Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000001a9cd05990685e6" X-Envelope-From: Subject: Re: [PHP-DEV] Re: [RFC] Add WeakMap From: nikita.ppv@gmail.com (Nikita Popov) --00000000000001a9cd05990685e6 Content-Type: text/plain; charset="UTF-8" On Thu, Dec 5, 2019 at 6:09 PM Dennis Birkholz wrote: > Hi Nikita, > > Am 04.12.19 um 19:50 schrieb Nikita Popov: > >> This RFC proposes to add a native WeakMap type for PHP 8: > >> https://wiki.php.net/rfc/weak_maps > > > > Any comments on this proposal? Otherwise this could head to voting... > > thanks for this proposal, will be really helpful! > > The only caveat for me is that WeakMap is not serializable. Wouldn't it > be possible to allow serialization by just serializing it as an array > with all objects that are still valid? This would avoid serialization > errors and make using it with serialization very easy. It would not > unserialize as a WeakMap but that is not that a great problem for me. > This is not possible. Classes always have to serialize to themselves ;) > Or maybe it could extend SplObjectStorage (or implement the same [new] > interface) and could be serialized as an SplObjectStorage object instead > of an array. > Could you provide some context on why you think serialization support for WeakMap is important? As weak maps are essentially caching structures, serializing them doesn't seem particularly useful in the first place, but when combined with the quite unintuitive behavior the serialization would have, I feel that it is better to leave this to the user (same as WeakReference). Specifically what I mean by uninituitive is this: When you do a $s = serialize($weakMap), you'll get back a large payload string, but when you then try to do an unserialize($s) you'll get back an empty WeakMap (or worse: a weak map that will only become empty on the next GC), because all of those objects will get removed as soon as unserialization is finalized. That "works", but doesn't seem terribly useful and is likely doing to be a wtf moment. Nikita --00000000000001a9cd05990685e6--