Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99193 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88364 invoked from network); 26 May 2017 08:30:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 May 2017 08:30:25 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.48 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.214.48 mail-it0-f48.google.com Received: from [209.85.214.48] ([209.85.214.48:38611] helo=mail-it0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 08/41-10292-0A7E7295 for ; Fri, 26 May 2017 04:30:25 -0400 Received: by mail-it0-f48.google.com with SMTP id r63so5224423itc.1 for ; Fri, 26 May 2017 01:30:24 -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=8dgFmBWlQz6/vSVaKtMKAMi2ydgLJsp8jFDDZb0baoM=; b=tWHcvu4a/LX5heKHV96O/f6v8C5Zm20vRxLVV6oRencUmYtOm8PLY8xNk3xdigWguU A8lU/nl77TIz0v71TvEpilo7GbfIdx4bUZtewO5DLe40nytSOFmsUxc9VgjbtZzQTS4u s2oz/hKnOblBAm5OuOfCD58kflPjhOeaXKquSmfxX7qu5afpP/xSkL7vqDO7ScyvgkKi Bmtu7VigoAXufYQIIiwjyaXJ6en2rg/liXp85SYKtgB+QQLa7DxWYIwoshIx3NgJl0mV PtOaWeyLmmRoJjY8WFJbTurVOdi6NDilx3+favLxGQ37wREaBzYVuIBzV/mrOmV5JynY 7xEg== 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=8dgFmBWlQz6/vSVaKtMKAMi2ydgLJsp8jFDDZb0baoM=; b=TAlLdnu6GVu/7gszGDT+7B2txmx6PdXiuhUxgRdQZKg0UI1ABa/GPGY5PHqw2jOySo 4P0dlV3WIICqjP9EDIZ9DTQFv/zD6b0MyMxVGD18ZSqHK/OoxI927xPbmoh1+DiGmWPR +nLai7L9EeNRMy4TGxB6QJFCv9GhXRtNZTiZMTVexFlbVCL3JzBCshOOzhQXePOWE01g /lmNjb/g6j0jVmQ2MAbznJCjQv2+ogSxImyPBI0jTKI/ODZf6iLzQXfpctUzzGVTXVXg w9KHsW2MylxT900f66AMJL9Go0n6e7Ho2g4FpUTbewu8A3p7cvQwkSO4xaulAb7uQghJ b7dQ== X-Gm-Message-State: AODbwcCgPfD7Z3ZZs83P0R/RGwyw208i9TLYr0tAseF0/2JiQ/J82XSM /IZUyJFo1fbTW6I/kzh/Npucj2/XkQ== X-Received: by 10.36.101.135 with SMTP id u129mr1599750itb.21.1495787422034; Fri, 26 May 2017 01:30:22 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.12.158 with HTTP; Fri, 26 May 2017 01:30:21 -0700 (PDT) In-Reply-To: References: Date: Fri, 26 May 2017 10:30:21 +0200 Message-ID: To: Marco Pivetta Cc: Fleshgrinder , php-internals , Ben Ramsey Content-Type: multipart/alternative; boundary="001a11460822f3316805506925d2" Subject: Re: [PHP-DEV] [RFC] [Discussion] UUID From: nikita.ppv@gmail.com (Nikita Popov) --001a11460822f3316805506925d2 Content-Type: text/plain; charset="UTF-8" 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 provide >>> > 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 general >> impression is that that's what people are usually interested in -- parsing >> 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 where > 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. Especially if it would allow us to replace a 4kloc diff with one 10loc function. Nikita --001a11460822f3316805506925d2--