Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105470 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 67814 invoked from network); 27 Apr 2019 21:25:38 -0000 Received: from unknown (HELO mail-pf1-f177.google.com) (209.85.210.177) by pb1.pair.com with SMTP; 27 Apr 2019 21:25:38 -0000 Received: by mail-pf1-f177.google.com with SMTP id e67so3267571pfe.10 for ; Sat, 27 Apr 2019 11:27:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=basereality-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Zd/XGYfdSQPaOz0Xfk/4iFRAVguKM4Wxn7FHGK8WxUQ=; b=KTzA9cV1sYKOawFCfGEink9QJqGEd7cmSeRhW2Hy0ijDxg0+kbue7OryL9ah+dWL+8 NrL2opIzIjglppLkCkKGGiw0V7qWjjMODSpaj+hL0Lkbn+iwxGk6fnLOPvuPVvEyhHdy 29O5rdrsaUpggRPkN4fauNnwQZfwFRVwYedD4skwTs26QTOYYjYAfB6YoXj9NnjkRpVM 2NZhW/V83GgaR0X/u4k8Xv7WQLPh3Z6aWOVB/JKbP9lEtRdp+FoB+Mx9gO30GCr+Jg9Q mT2zWSred/VNUOyCSuc4GwFvlL8xj3NFzK0yVYoBF3fuW7ZjTO2O8lRVzoZpY+IvUYNP wF/w== 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=Zd/XGYfdSQPaOz0Xfk/4iFRAVguKM4Wxn7FHGK8WxUQ=; b=US2b7R5k1W6tru5HUPbEr4SxeNr5FduOZUYeiZGUO2UQl6ArIw29oq2vi902JZqJLQ EgjvNKBPIo3fZBkiOChoX3HjbDrOvfUr80JoEDHh9gJAKd0toLWQ6MDY7bIQTvxWioka JP1GzXuUZgh/Uoxzbh0gNwSESvRaYk/sZsjtbHacLXgoWVPbdMrrEWdg3zSTLpDwyuNb Q7O0ZMl0zP4+ecaz/6ug5SIzypUfw7nMmfJwodMmdwWWvqRViqUiDDv4QbhyVPtOPwGY BSnZ6aQbkCQXilvSxTML40gxhsFSXFCzLMn950CggOglT4vvLRJ4SGPd4g0+vL6dw/K6 ak5w== X-Gm-Message-State: APjAAAWjBfbphKJJgetIuCtQ5DC2Itxlkd/rUnlGveescJtPua7sEpo1 p93Hmef+I9sk5bYx26ES11I0m6z4NW0Jaa8icJXpHw== X-Google-Smtp-Source: APXvYqzDovcFU9t6HKGz+HRTwfGzvTKcdpaPla2RtjzJLqxzl5hEDnUg0wCMDOisF1gz5LOFnnt7RqkLc3ADMW10Apo= X-Received: by 2002:a63:4a45:: with SMTP id j5mr51278542pgl.426.1556389624583; Sat, 27 Apr 2019 11:27:04 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 27 Apr 2019 19:26:53 +0100 Message-ID: To: azjezz Cc: PHP Internals , Nikita Popov Content-Type: text/plain; charset="UTF-8" Subject: Re: [discussion] arraykey type From: Danack@basereality.com (Dan Ackroyd) On Sat, 27 Apr 2019 at 00:13, azjezz wrote: > > What do you think about adding the `arraykey` type to PHP. I don't think we should be adding anything to PHP core unless: * there is a strong case for it being needed. * we're sure it's not going to cause problems in the future. * it's clearly the correct thing to implement. * there's good reasons not to implement it in userland. I'm pretty sure this idea fails all of those tests, except the last one. Without generics, it seems the need for an general arraykey type is low, for me at least. For the vast majority of the arrays I use, I don't mix key types. All of the entries in an array will be either 0-based incrementing integer keys, string based keys. I think the Union Types RFC https://wiki.php.net/rfc/union_types has a high chance of being revisited in the future. As Nikic mentioned in the PR we would need to make sure that arraykey would be compatible with it. That is very hard to get right without having the Union Types RFC already implemented, as the behaviour around casting is going to be tricky. Or, more simply, there are some parts of PHP that can be made better by adding small bits at a time. I don't think the type system is one of those parts, and it's better to get the big pieces in place first, so that the smaller bits will fit accordingly with those. If you wanted to proceed with it, I think you'd need to find a really strong reason for why it should be added, rather than just it could be added. cheers Dan