Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103011 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31874 invoked from network); 1 Aug 2018 19:09:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Aug 2018 19:09:09 -0000 Authentication-Results: pb1.pair.com header.from=levim@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.208.174 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.208.174 mail-lj1-f174.google.com Received: from [209.85.208.174] ([209.85.208.174:37020] helo=mail-lj1-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E9/4F-14835-355026B5 for ; Wed, 01 Aug 2018 15:09:08 -0400 Received: by mail-lj1-f174.google.com with SMTP id v9-v6so17818763ljk.4 for ; Wed, 01 Aug 2018 12:09:07 -0700 (PDT) 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=WYKxtwl+C+O3p4jDHZwJKCWzx5LNOIKaoc/vbMdxNsE=; b=AzzbkL8IABrP8zN1Pr5YM50V6aA7c6Fi070zo8tt7q8wewpuE+JVTM1hRNHpw85w9b uHbakR//IYlyu8ALFzsv9yYdB8DnEnQRsQEv2hhp418mq2EujE/geIfsXvKtgoXu6tRu 4dOp1qSeyI3AacJeWkkIQGbNEBMochLrmEjxj1+E2wYUIWbBS7/qlW2+x6XEoNpJRVBS /iOm0iuoROIDTc36kOkY23BF61Ug/0aTNKT0RXE3ZEnjxY8/gUifqZf24MMMg6ekNJTn GLlnzhxZx9oMlque2x21jOGL2/dUi023iLIM0ewL1HxvN1WfeD5rUkQqJnE1AwJVAdvk 7snQ== X-Gm-Message-State: AOUpUlGiwhu34L0yNd/GSRSKocqCtr9INSx4MMOWyw/OXnR5ClMstc2S HAcQoodZrKZT/UZ/vgB7hc+6FmkWECIaPzOc2Ro= X-Google-Smtp-Source: AAOMgpc/9gETHzFE8LteIFBrq4o2S3+WIzC18J1V/B/PeoflZkmG8uwi/ZWRg5CKOu8unnrek0nTI7HJFZQ4u+NkkCM= X-Received: by 2002:a2e:94d5:: with SMTP id r21-v6mr19913875ljh.126.1533150544024; Wed, 01 Aug 2018 12:09:04 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 1 Aug 2018 13:08:46 -0600 Message-ID: To: marcospassos.com@gmail.com Cc: internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Array max size From: levim@php.net (Levi Morrison) On Wed, Aug 1, 2018 at 12:42 PM Marcos Passos wrote: > > Whenever you look for more information about the maximum size of an array, > you find someone saying that "PHP arrays do not have a maximum size, but > the amount of memory available". However, I could not find any excerpt in > PHP documentation that supports that. > > Even if the engine imposes no hard limit on the size of an array, in fact, > there an inherent limit that is assumed by some functions, and that is what > I would like to suggest making explicit on the documentation. The lack of > this definition leads to inconsistencies and leaves several open questions, > including: > > - If no limit exists, then it's conceptually possible to have an array > with *PHP_INT_MAX + 1* elements. In that sense, what would be the return > of the *\count()*? > - The function *range* validates the size of the resulting range against > the maximum size of the hash table (defined internally as *HT_MAX_SIZE*), > and throw an error if it exceeds that value. Is that the limit? > - he function *array_fill*, in contrast, does not rely on *HT_MAX_SIZE* > for validating the size of the result. But, why? > - The documentation says that omitting the third parameter of > array_split is equivalent to \count($array). If the maximum number > representable in PHP is *PHP_INT_MAX*, is the max size the same as > *PHP_INT_MAX*? > > There are other examples, but I think these are enough to make the point. > > My understanding is that the conceptual limit is *PHP_INT_MAX*, as there is > no way to represent the size above this value. If so, the interval that > represents all possibles indexes for an array is defined as *0 <= index <= > PHP_INT_MAX -1*. That definition aligns with all functions that support > negative length as *-PHP_INT_MAX* is equivalent to the start of the array. > > Could you guys please share your thoughts on this topic?