Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103009 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27559 invoked from network); 1 Aug 2018 18:41:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Aug 2018 18:41:43 -0000 Authentication-Results: pb1.pair.com smtp.mail=marcospassos.com@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=marcospassos.com@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.45 as permitted sender) X-PHP-List-Original-Sender: marcospassos.com@gmail.com X-Host-Fingerprint: 209.85.218.45 mail-oi0-f45.google.com Received: from [209.85.218.45] ([209.85.218.45:46908] helo=mail-oi0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A3/9E-14835-6EEF16B5 for ; Wed, 01 Aug 2018 14:41:43 -0400 Received: by mail-oi0-f45.google.com with SMTP id y207-v6so36455136oie.13 for ; Wed, 01 Aug 2018 11:41:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=NKTRVzHEPOc3KeJCHvQf3LYKK9zzNRf4GvedFnGtDzo=; b=Bk/r/XnI8sa8XxdSeAxvhXYKyg5LZlSuFheyi7as0dfLHxLCbkcfEOfE+GJcqyfGsD 1chn85ANS9lJCKNrW+xI+JvGGs9hjNMPoq1dVqi3qXVMGSF9755isMXtSySsf6iDQpSn hOpOv/6VZnooBKmhoSY790ABmYOLxMznkPYks5JERaPpZY/F3g80ZqUZefwG4vVc4Tsd QZM4FLoEOUzfn6txrkIhhEq1BmDA38M82O7lJJ6kPz9Fdr/8ezpiVHDRiXkhOfuieRG2 tu6DifmedEQykIHMvyoepe/m68GMaxhsbRZtBDoa8QcPgWeSSyUNNbwM9vdRTKbcOebu jcUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=NKTRVzHEPOc3KeJCHvQf3LYKK9zzNRf4GvedFnGtDzo=; b=i/8zus3qpTPzaQt1JiJFctGX1g7oe/1aiGcvpnH9ol1hMXTrLTX8ip2jXvlrxeRj83 bkbDjYf9L6HSX/dlLMKbciSvoDDx4HlDkGJ5glsDDIr/s6LlftS7jOCQwbYY8XxfYQgv RwMzW86KSEBP0oK1Sq2ZAq6AQ4eK58Z9qH4qZbjG6HL+oiY8E1BbzUb6J+4DxJbWJU8l 3O5tczdjb03n4OCdTQo1gHH04Em3hn0efwV1P9+WK5MflhHmZA8Pec/RpBMzfG2WDEfH ZE46ibRZAUaXFlwSy1PjOhB6FDqZONrt2czTH/mYV4d9oN2xSZ9OGpJIN6AHnk/zvdJ3 8FnQ== X-Gm-Message-State: AOUpUlHgDVxpsiiVFLuVfN5/W+z7MUzjondi6WHpBERhdtmJryifNJ3V bADFKCDFjVGrq6kKEijcvZ/PXL3GIsbcI54XxHTqqn1c X-Google-Smtp-Source: AAOMgpdpGDKN8Rx7BmFT3ssbrSaXwOpqrLAfkV67JSO2I29I+VbEsCXvoe7N6o0h4IIshFigi9zLHtnaQOR1FcigG34= X-Received: by 2002:aca:f409:: with SMTP id s9-v6mr5044456oih.102.1533148900209; Wed, 01 Aug 2018 11:41:40 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a8a:10b:0:0:0:0:0 with HTTP; Wed, 1 Aug 2018 11:41:19 -0700 (PDT) Date: Wed, 1 Aug 2018 15:41:19 -0300 Message-ID: To: internals Content-Type: multipart/alternative; boundary="00000000000095b91f0572640b60" Subject: Array max size From: marcospassos.com@gmail.com (Marcos Passos) --00000000000095b91f0572640b60 Content-Type: text/plain; charset="UTF-8" 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? --00000000000095b91f0572640b60--