Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105782 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 46095 invoked from network); 23 May 2019 22:11:15 -0000 Received: from unknown (HELO mail-lj1-f195.google.com) (209.85.208.195) by pb1.pair.com with SMTP; 23 May 2019 22:11:15 -0000 Received: by mail-lj1-f195.google.com with SMTP id q62so6528150ljq.7 for ; Thu, 23 May 2019 12:19:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uT9QKKxkvPmmvk+Co84RM9f/5zb5NJhiXCzpLoK3dbU=; b=teazoro4X72E31u9k24iiKMRCo8qTJSktYn45YDEWp0L2w0vXrha2toSU4doB3hnkT JzdifxgF2DzG2hLQ94xT4/90sJkNo5H3Cx4svU2+ZyYiz7zUvRfQ0VhdXS810uxuxUHb 0gP0alqbucjEkBuai4ZttGc+xi79R9dpAFyyY4/UYi/bg9Io4KZfg4bxcnODJ20A4LUC QXs0xtLDiuvZ3a/GLKjZaMaWSwPB3M+NjeNZTQTXELZBAhtwfxGc3oh1u/p+X38Md73j G4OCJYx8Id95D7Nud5ry9OhADEK9B7Jyyj7gFa75vg4cZQaggQJNSiY9HC3siYXIn12G u4rg== 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=uT9QKKxkvPmmvk+Co84RM9f/5zb5NJhiXCzpLoK3dbU=; b=WwxnUOkXxwhcT2LAU05LpF3fagz2+NPf158M/OZQD8OB8C+tpYZQkNAS0cRHGS+qey hw28k++gojZYLlJj/dyMV15eKB1I2/53nbDtMFvR3fY36mYy/tejX6hlv3JtOYQznvFO gpN9HpAFxFUmaGxOhmOtH8OL98I97QnrAnxnO1ZEGTF3miC9/kr7WOdRcvCDwjETAjiV 0MBGhavxO3SP03A6FaMRduax8exWZ7jDRQmY6v7WyA/mPHSdFVeFv7VxlYDujB6L95QX jntw+zJ1g0ODUlvd33imIvpew4dut3ecIW8B2PKMH9KdPBro8ZU1Iuw35xYde2O6IKVx M4Zg== X-Gm-Message-State: APjAAAXCpuTLOwzJE3Jwd3RPCdMd2XRm8/45U4Lcb0E1ZC7hqNVxWwnd /6LsGBzB9oIx9igXiduNXZ8fIayzcbaWr6NmwRo= X-Google-Smtp-Source: APXvYqyuiQ6S9hPYI25I/7bFyqKwhBzCasml7ZFPgHOohisQ0xH8fWMIDgQ2AK3w7NE9rwfKg60FFfzFFiA2HvivZnY= X-Received: by 2002:a2e:655b:: with SMTP id z88mr46147950ljb.108.1558639152294; Thu, 23 May 2019 12:19:12 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 23 May 2019 21:18:55 +0200 Message-ID: To: Dik Takken Cc: "G. P. B." , PHP Development Content-Type: multipart/alternative; boundary="000000000000016eb5058992f538" Subject: Re: [PHP-DEV] Calling array_merge / array_merge_recursive without arguments From: nikita.ppv@gmail.com (Nikita Popov) --000000000000016eb5058992f538 Content-Type: text/plain; charset="UTF-8" On Thu, May 23, 2019 at 9:02 PM Dik Takken wrote: > On 21-05-19 10:29, Nikita Popov wrote: > > This one makes sense in theory, because array_map(null, ...$arrays) is a > > way to perform a zip operation in PHP. Unfortunately there is an ugly > > special case if there is only a single array, which makes this not > actually > > usable in practice, unless you know that there are at least two arrays. > As > > such, accepting zero arrays wouldn't be very useful unless we also want > to > > fix that issue (PHP 8 maybe?) > > Ah, I overlooked that edge case. Indeed, array_map() would require more > fixing than I anticipated. I guess it is out of scope for the type of > fix we are discussing. > > >> array_diff() & friends > > > > array_intersect() & friends > > > > > > These look like good candidates for allowing a single arg. > > For array_intersect(), I was actually considering to allow zero > arguments. The use case I have in mind is to determine the common > elements in a set of zero or more arrays, like this: > > array_intersect(...$arrays) > > If that would just return an empty array when $arrays is empty, no > additional empty check is needed and the above would do what I > intuitively expect it to do. > Common intuition, but not mathematically sound. Assuming we're intersecting subsets of a certain universe U, then the intersection of no sets is U itself, not the empty set. (A useful intuition is that intersecting additional sets can only make the result smaller -- as such intersecting no sets at all yields the largest possible result.) Nikita --000000000000016eb5058992f538--