Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120540 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 14736 invoked from network); 8 Jun 2023 11:16:32 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Jun 2023 11:16:32 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E97881804C9 for ; Thu, 8 Jun 2023 04:16:30 -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_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 8 Jun 2023 04:16:30 -0700 (PDT) Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-517ab9a4a13so286332a12.1 for ; Thu, 08 Jun 2023 04:16:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686222989; x=1688814989; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=6qQeRTdYeh5Z1fyD5IHXXvAtfDvqvm5g3DMpLh1u3dY=; b=ZpGQzAHsgk4jJkVaewB8lkSrfmKA5FRWDM2HBidSsfUeShF4Zrh4Hi6nT1LbfdgFUt kjnaLQXiIMy/XV2A6wMidnS6UcBfjkO+Qig7ks2NsU1ql3RyhTl8hetXRSJ8sUdUzVZL IDYPjtehQBCcGYOFSabJpp6MG02UdFkUdkrxMOD0BSSfKSToOyCdpclR+vuv9CG3k08i dJabrsOgwVLrHzViSNjsV/uCKFKn8H3i5KyhFcde1zZDRVi7B3gzRqIre+T2l1jaKXET A74o3kpxBQfPHOFc2MpbvpKVi54JtasmAw8N/kPQFjD1H1LXjbQW4A0oGwUVFzvuIRUI glUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686222989; x=1688814989; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6qQeRTdYeh5Z1fyD5IHXXvAtfDvqvm5g3DMpLh1u3dY=; b=XRZcmbyIZEVO/HxXq1AEqEAAxVkWMKI92U8HmD32v7EJczdKG9ogxc5Ewq5pWEk0Xd 4FioJZN6tpG/p/L3X0yWAnlPQqrDWpd5O7TeIgzEE7J87ldoyKHvQ+/jwH+V72fjUyuR 922loRRMZHVgdIbW7fM/Vib/SEkEGdwR3fcc7vPNtmnzHtw1F+uMEU7tR7AayXG+0pc0 Qkhv5DiqVILv9Xe9ig10G0EYqYjXh9nSOBxNHalampGxKqSdZPtiZpf7Yzu9b+oRP5Hn jsrywcU67JikXoD87F072OtYAZX6WpNcNWG4zXpnDL5L/72gJhXKa1NXI9Bdm8GW5smc qVPQ== X-Gm-Message-State: AC+VfDw86bqaw5GlfoOxbCaL+pXh/QBk/4kZJmE1LlRKRGrINpCTNe8/ mwM6e79/u5agd6IYANkKAY6kNr1ZVHarafW3RFluNtCzqnM= X-Google-Smtp-Source: ACHHUZ6OQ3Nr9y65mveBxWbwUvJ6f/Qh3Z4eDSK/NEkGrJj10KmjYegYpFjp6AYsAJUaCNESJ227ZWssvCtTvxUWdRs= X-Received: by 2002:a17:902:ced0:b0:1b0:7739:657c with SMTP id d16-20020a170902ced000b001b07739657cmr9705445plg.55.1686222989377; Thu, 08 Jun 2023 04:16:29 -0700 (PDT) MIME-Version: 1.0 References: <5b37626b-1157-e453-d434-4a68916dafc8@mabe.berlin> In-Reply-To: <5b37626b-1157-e453-d434-4a68916dafc8@mabe.berlin> Date: Thu, 8 Jun 2023 12:16:18 +0100 Message-ID: To: Marc Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000004b47dd05fd9c62d7" Subject: Re: [PHP-DEV] [RFC] [VOTE] Define proper semantics for range() function From: george.banyard@gmail.com ("G. P. B.") --0000000000004b47dd05fd9c62d7 Content-Type: text/plain; charset="UTF-8" On Thu, 8 Jun 2023 at 07:35, Marc wrote: > sorry for speaking up so late but I think the following change is a > mistake and unexpected: > > > Calls to range() that have integer boundaries but a float step that > is compatible as an integer will now return an array of integers instead > of an array of floats: > > var_dump( range(1, 5, 2.0) ); > /* New Behaviour */ > array(3) { > [0]=> > int(1) > [1]=> > int(3) > [2]=> > int(5) > } > /* Current Behaviour */ > array(3) { > [0]=> > float(1) > [1]=> > float(3) > [2]=> > float(5) > } > > The problem I see with this is that the return type changes from float > to int "magically" based on the value of the step. > range(1, 5, 2.0) // list range(1, 5, 2.1) // list > > In my opinion, no matter, if start, end or step is a float the result > should be a list. > A list is compatible and interpretable as a list so this only I slight change in output and has effectively no BC break when using the values generated by range(). Moreover, this change is needed to make calls such as range("a", "z", 3.0) work as intended. I.e. generating a list of characters instead of generating the list [0.0] by attempting to cast the strings to floats. Moreover, considering the return type is already pretty magical, supporting this specific case would add even more complexity to the implementation, and this has effectively no BC break, I will not change this detail. More so that the RFC is currently in voting and cannot be amended. Best regards, George P. Banyard --0000000000004b47dd05fd9c62d7--