Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109766 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 43439 invoked from network); 22 Apr 2020 00:10:51 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Apr 2020 00:10:51 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2ACC71804CE for ; Tue, 21 Apr 2020 15:42:21 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-io1-f54.google.com (mail-io1-f54.google.com [209.85.166.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 21 Apr 2020 15:42:20 -0700 (PDT) Received: by mail-io1-f54.google.com with SMTP id w20so363322iob.2 for ; Tue, 21 Apr 2020 15:42:20 -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=csDoeQ3zN/7zp6pO0snvJwp5XBsrNEHHVvTV6eU8kr0=; b=sc0JUPb87gbKT2d7wqGiUQLF4Azt2+tup15i+eFFGp2gbZFBXNxL7Veocljds+aP3c m8i4/0YIjyQY/zofTzDYLDyAudeSavP02y7pzeum2GYMh32yt8VZ3Mfl7QVuy+C+DmtW 56NKtMBe2Rl1hWKhblwGQVOLpPj/f63WyMpR38of0rQQ9eIFLjR5ji3oSNzCqglzY1hV X5cyUjaLylGYNjINw8rwvz1IAx24ivnUFAXc0rxLM+sW5wFj7sPSc1I21ECwmMRFL+m8 fvQ+A9S2lnMk4UPe41zgnjTprMUQTcoPG61R8NKM7bG7C7+fDvKgQ4dIRgQyAZJrzj5y 95Jw== 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=csDoeQ3zN/7zp6pO0snvJwp5XBsrNEHHVvTV6eU8kr0=; b=LGyNU+CcFWEHWS+LdbjyJjfvtG0T4uRiXf03ptlqBA0VnpmA9aQwmcrg0bN3BwOB62 WwGRROzypusdTiy0b9Ttl1BBEyRSrrvj1TXEmwdhYf4EZUp/w+X///58l0Sydqobuljf vPAA5V0GAebkJwnfqESc8wpF7iLzOUHEWxyIR528Wk8RsV+xzhl2i9l9TO3NCWf7obuM 9h1MOG40F2Siy+tP8B1+7/DqsB+otpqE3MnuI0lQ8rdMo/zIEllnZRLgouV1hB9cYPHt nQGJpJbxcGvk/bE7ElYDGEVGuZSTdYzcePHAIqy30YjFBXYgFcR00KFmmttVQfz/yWZm X7vw== X-Gm-Message-State: AGi0PubcfWAEAVnP53aDU2AAsHIVgEXeP4y88s21b21VkVGAGNtsN87i 5NUzxe3s181Ux3XYP1s4F21spq1TAKerLImI/sg= X-Google-Smtp-Source: APiQypLwOW+2gq3wnhIqr9lrVSZ6UcjtoxQ4D/p/3cvcyGZJb5myu3zT3QDz8MLwquWyBaUC4F2v6rawPyWQsTCsOAc= X-Received: by 2002:a6b:8bd2:: with SMTP id n201mr23122196iod.131.1587508934790; Tue, 21 Apr 2020 15:42:14 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 22 Apr 2020 01:42:03 +0300 Message-ID: To: Matthew Brown Cc: Internals Content-Type: multipart/alternative; boundary="00000000000022d46b05a3d4ba3b" Subject: Re: [PHP-DEV] Any interest in a list type? From: maxsem.wiki@gmail.com (Max Semenik) --00000000000022d46b05a3d4ba3b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Apr 21, 2020 at 10:00 PM Matthew Brown wrote: > Why "list" and not "vec" or similar? "list" is also a reserved word =E2= =80=93 I'm > imagining that you'd construct a list like > > $l =3D list["a", "b", "c"]; > "List" usually means linked list, "vector" would be much clearer and consistent with many other languages > I imagine such a "list" type would be a subtype of "array" =E2=80=93 ever= ywhere > that array was accepted, a list would be also, and it would have the same > copy-on-write behaviour. > > If people are interested in having that type, there's a question of what = to > do with > > $some_list["a"] =3D 5; > > Would you convert the $some_list to an array, or throw an exception? > Converting to an array would seem the more PHP-like thing to do. > > Similarly, the behaviour of > > $some_list[$key_out_of_current_range] =3D 5 > > would be a matter of debate too =E2=80=93 would that turn $some_list into= an array, > or would it fill up any preceding entries in the array with null? > I personally would prefer as little implicit magic as possible. Just throw exceptions instead of allowing people to accidentally shoot themselves on the foot. What other questions are there? Is a "list" type even a good fit for PHP, > given most of its users seem pretty content with the current > swiss-army-knife array type? If we're to dream about some bright distant future of data structures, my dream would be to have a set of structures that make their big O behavior clear, =C3=A0 la C++ STL or many other languages' standard libraries. Some = of them are already present in SPL, but notably not what you're proposing. Additionally, it would be wonderful to have generic versions, e.g. List would not just accept only ints, but would store them internally as zend_long, avoiding the overhead of zvals. > --=20 Best regards, Max Semenik --00000000000022d46b05a3d4ba3b--