Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99203 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13865 invoked from network); 26 May 2017 13:26:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 May 2017 13:26:40 -0000 Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.68 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 74.125.82.68 mail-wm0-f68.google.com Received: from [74.125.82.68] ([74.125.82.68:35884] helo=mail-wm0-f68.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 83/35-10292-01D28295 for ; Fri, 26 May 2017 09:26:40 -0400 Received: by mail-wm0-f68.google.com with SMTP id k15so4016258wmh.3 for ; Fri, 26 May 2017 06:26:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=kkfWlxozVBegyj0NzypvasWIBSdpnq6Srq7U8aeCg5o=; b=YyoZqXg9ZNwB83MMySSLm7muGUKcAweAtX3PzvYLRoJf7L/sl1VF/Z8hksEDVE5vZH 39s0nYTYKENhRfuxDRlheIAV2/b2H4NsZ97XFbm3cN7mIko6YSEii0GMFBNajxWo8wLu ZHi25KthzedMKz+Olxb2yxFfCNQjE+BHtkebgiQ6hp3B4GsdHVQnoQdSvKn8f/Y++C6w FKLh4SHWs1qHtUChPxajdFRjJvAjRP/xb7E4MsBjwtwGZbW6HslYU+aM8sdC/r++x6AV JQcDJARrNJnunyeNBd1Kvtz6QCaeOduSqx6rgf1Tx5mbG7fXTY9XDplZ3eshlsMSKqH9 cu0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=kkfWlxozVBegyj0NzypvasWIBSdpnq6Srq7U8aeCg5o=; b=nuhco325lmnLEK3wI/ZTBblTgoy/Cx/ErguRbH8MnodHLeHeauDL+0XBlx43/l3DAH 3AnpAwKZEZatmfuomEgY9ozM77Kr5RMKkAopiWmQpgty9hehesbMEZlGbusR8MQrf0n0 8Zzu/zc7mRPiWaVxnLYr+gkauyS2ZH7aM1LaySDMNilre7uCHhRK8gFXEVHoc3guRXZl vuNYwF1TsRf9ndZmTSdELtO77pWCGNQOxLN8F8JkOStiU6X84oZ23y1yTiXs6uB5FZeL wqazIokNIF/nOdfSvMkEr8/5pKx2z5ITjCVaWsd5CEieH9b2MN6rHvnjECcbtsDyen8s sEsQ== X-Gm-Message-State: AODbwcBcypDfNiJHmWsHvsJex1cs/PpI+aX5P2xVZwAZHIgNUtXCKahm qlUnksAmLl9FC8JHvI7EBmT+q8H1/Q== X-Received: by 10.28.63.9 with SMTP id m9mr2283326wma.87.1495805197462; Fri, 26 May 2017 06:26:37 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.161.147 with HTTP; Fri, 26 May 2017 06:26:35 -0700 (PDT) Received: by 10.223.161.147 with HTTP; Fri, 26 May 2017 06:26:35 -0700 (PDT) In-Reply-To: References: Date: Fri, 26 May 2017 15:26:35 +0200 Message-ID: To: Nikita Popov Cc: Ben Ramsey , Fleshgrinder , php-internals Content-Type: multipart/alternative; boundary="001a114b700e72b64905506d497d" Subject: Re: [PHP-DEV] [RFC] [Discussion] UUID From: ocramius@gmail.com (Marco Pivetta) --001a114b700e72b64905506d497d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On 26 May 2017 10:30 a.m., "Nikita Popov" wrote: On Thu, May 25, 2017 at 5:48 PM, Marco Pivetta wrote: > Hey Nikita, > > On Thu, May 25, 2017 at 12:14 PM, Nikita Popov > wrote: > >> On Thu, May 25, 2017 at 12:05 PM, Fleshgrinder >> wrote: >> >>> On 5/24/2017 10:12 PM, Ben Ramsey wrote: >>> > I'll take a look at the patch soon. If this is accepted to the core, >>> > I'll probably add an adapter to ramsey/uuid that wraps this >>> > implementation. The point of the "over engineering" there is to provi= de >>> > choice. Some users want to generate bytes from sources other than >>> > random_bytes() (i.e., libsodium) or encode UUIDs in different ways >>> > (i.e., ordered time). A UUID generator in the core will only help to >>> > improve ramsey/uuid, providing more choice and better performance. >>> > >>> > I may split out the less-used adapters and codecs into separate >>> > components in version 4 or 5 of ramsey/uuid, though, since most users >>> > don't need anything other than the default. >>> > >>> > -Ben >>> > >>> >>> Yes, exactly. >>> >>> The provided implementation does not have any of the options your >>> library offers. There are no special formatters, no accessors for e.g. >>> time (not applicable to v3, v4, and v5), no RNG choices, no mutability, >>> ... well ... nothing. It is just a straight UUID implementation. >>> >>> I also hope that this implementation will help to get rid of uniqid at >>> some point. >>> >>> -- >>> Richard "Fleshgrinder" Fussenegger >>> >> >> I'm wondering if just adding a uuid_v4_create() function (directly >> returning a UUID string) might not cover the 95% use case here. My gener= al >> impression is that that's what people are usually interested in -- parsi= ng >> UUIDs etc. seems to be a rather niche concern. >> >> Nikita >> > > > I'd say that a good example of how this would change things is the > `DateTime` object. > How many times do you see people passing around `DateTime` objects, and > how many times do you see *valid* (not wordpress) use-case scenarios wher= e > a datetime string is thrown around? > > That's the kind of change that a built-in type may trigger here. > > I had issues about this due to the squishy behavior of the reflection API > with internal classes, but Richard covered every rough edge, as per > discussion above. > A big difference between DateTime and UUID, is that DateTime has useful behavior. Apart from unusual cases, there is no need to inspect or modify the interior of a UUID, while DateTime operations are common and very hard to implement if not provided by core. Introducing a UUID class in PHP core as *just* a type safety wrapper feels akin to adding an EmailAddress class to core. It's certainly not an unreasonable way to handle things, but imho also not something that should be in core. We should be providing the primitives based on which people can implement whichever abstractions they prefer, in a simpler and more flexible manner than we can achieve in extension code. Very true, but we're also talking about standardised values that everyone in userland keep doing wrong in some way. If EmailAddress does ever make it into core, that's just added value. Types over string checks all the way =F0=9F=91=8C Especially if it would allow us to replace a 4kloc diff with one 10loc function. Agreed: this would be much simpler if the class definition didn't have all the possible quirks of manually- and C-level defined classes. The fact that Richard had to test stuff like order of parameters, reflection, etc is, frankly, frustrating. Any hope for having the same stubbing of internal classes that HHVM had? Sara? =F0=9F=98=8B --001a114b700e72b64905506d497d--