Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123687 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id A15DA1A009C for ; Wed, 19 Jun 2024 19:14:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1718824561; bh=bM6xx5EFGOFicHOPFZHSC3+IrDAyNZUbpG2gcKrE++Y=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=mH0ENPFRs7JR+WyN9IvhWljtNzKoqv9YzCvJwCT+0Mr/hnMKjiYyyofhKLxYTO0Ok H2BFFQn9ds3g+4g59C/8gfuzuEeIiO14rKIVYK4OpeMuGsrkLezoGGkxA2jPmur15y qAUNv32U/zBwi76e3GkscTNEWEFntnWqTJghvUHK+FLKaaJASVRSVdOTxH8TSpiVXz vuT7hfI3QDNluSUrnFCoOdy2gW+3q2o8JXbwnfnyygfz4FBzuQFQZk4SPbEPFcErjN 9adyh7eEZcIRwcaKXJv0Z2JTrwAu06md6EnxZMT5WkKwBnes6JEg77ZmYuu62oFyI/ aR4OpuM56Hgrw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E9BDF1807E9 for ; Wed, 19 Jun 2024 19:16:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 19 Jun 2024 19:16:00 +0000 (UTC) Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-361785bfa71so92509f8f.2 for ; Wed, 19 Jun 2024 12:14:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718824486; x=1719429286; darn=lists.php.net; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=/uwpM22cNBAKYqeZtbVBCVilAJRvDnJ+1/gWYueg26I=; b=elHFbojf/r6oKQDbmbp5YGnuuYAeq25nkCh/e6dj+HKNywx/ZGJNciOA8ssjGl8GwM mMojMQFCzAtUNLXexJanEjfumIgjbKoc9P4DbIs6bGyzGwiER29hqv0/K6OPcBo0JRQy T3KU/+qYJMq/NBh62LObZmKe4wffkKu5uOOqJvIXtT3tJz6j6r6mPqrubuCoDm88HOB1 6Bj/NLaL0Ww3lfJyMYl8pVvW93K2tG1OhFrmiRjgvP1uihcOzq4gVCW5D/KPfivV1VBP 8Cfv4bYhZobdsTUHLJVignrzsoNOzBjPlI06tI7DCqgD2bNkVY9/0TuPjXB+6eQOcvpg Ed2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718824486; x=1719429286; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/uwpM22cNBAKYqeZtbVBCVilAJRvDnJ+1/gWYueg26I=; b=D32YTQcgr5XaVcG5J2ecsH0aOeLpfhmX8o5fNenMioCejtnMRkDk/fsryQzG+4y04v FSKi7N2dEjq+Qt5ePoGT+C6cgMUEQpbFrS+hVzTYWp8nRWkNmwKMrI7MbCzAniseEO7Q /AmefLrV9enaeAE0S4d++bbH3OqCBNc4pQcV42Xay3n1X1ob36V4b9FYCK6hfo+75tvt HeTU3VzLfJpjD+DH2cL6ELBMlEpM9gT/yUGGWOZ7+GIy1bS90GlcYFCbUBgdWq2W/xeN kodpTfxliMERB1Q3NTFaAxNzHlPVQvwT1O984DwlImdIL1fbhVubZYZSiAXBRGZk+wqb Frvw== X-Forwarded-Encrypted: i=1; AJvYcCWGLJQcEdq8DctN+WBYc2914QSouPBnJgtmdzRlnaFB8b/mBeM+QFT7O+mwy/9HUEStgWfTtCvRuAcVskXKjFCIFlpXS8MMJQ== X-Gm-Message-State: AOJu0Yxbcy0+cP2Ei0aWfmoD2K9w9dwQU9MJpt6Ps1hXQo4z+Sos+vNN E1WZ5pyyfwHW0KtyAQxVSN5XixlX5C4qOEDbm2b3n9wjkKtYThzfBHkk/fvw X-Google-Smtp-Source: AGHT+IHTQNa/mYvvZrcuZJn8k2wsNs4oVmQUvQipoPE0fPEMgcus+3b+e0oZ+87N+u+95mn5rzPGTw== X-Received: by 2002:a5d:6a89:0:b0:362:e1a9:34d4 with SMTP id ffacd0b85a97d-36317b7d4ecmr2379825f8f.40.1718824485762; Wed, 19 Jun 2024 12:14:45 -0700 (PDT) Received: from smtpclient.apple ([89.249.45.14]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-362ba0b9b3esm4169889f8f.74.2024.06.19.12.14.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jun 2024 12:14:45 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: [PHP-DEV] [RFC] [discussion] Correctly name the rounding mode and make it an Enum In-Reply-To: <67d37d56-625f-4f80-805d-a5db2d3807bb@bastelstu.be> Date: Wed, 19 Jun 2024 21:14:33 +0200 Cc: "Gina P. Banyard" , Saki Takamachi , Jorg Sowa , php internals Content-Transfer-Encoding: quoted-printable Message-ID: <0A9642EC-0FCC-4BC3-82C2-C6C968CD8D1C@gmail.com> References: <9zUVZKaEYixjCLLhviQPYFQtSAEhsRMWL6xbKeogzAGsH-STebN9JqJxITAPVfdKTNu7gEs_m77OkIcOzaiscoajx8Hp8VWRKkhTTCPkGko=@gpb.moe> <6E690732-8BED-4A01-8385-648E7CEDFD9F@sakiot.com> <70f63dd2e0ba7959a9e3bb7fa68ce14a@bastelstu.be> <67d37d56-625f-4f80-805d-a5db2d3807bb@bastelstu.be> To: =?utf-8?Q?Tim_D=C3=BCsterhus?= X-Mailer: Apple Mail (2.3774.600.62) From: claude.pache@gmail.com (Claude Pache) Hi,=20 Naming is hard, for sure. Here is my review. I find the names mostly = reasonable, except Round::PositiveInfinity and Round::NegativeInfinity. = I will discuss Round::PositiveInfinity. First: > I've discussed this with Saki. In that case the `HalfEven` and = `HalfOdd` modes would also need to be renamed to `HalfTowardsEven` and = `HalfTowardsOdd` For me, the implied preposition in `HalfEven` is =E2=80=9Cto=E2=80=9D, = not =E2=80=9Ctowards=E2=80=9D. In other words, in the HalfEven mode, a = half-number is replaced with the nearest even integer; it is not = replaced with a integer *in the direction of* (or: *towards*) an even = integer. So, `Round::HalfEven` is fine; but `Round::PositiveInfinity` = does not make much sense to me, as the number is not rounded to +=E2=88=9E= , but towards +=E2=88=9E. ------- Second, =E2=80=9CTowardsPositiveInfinity=E2=80=9D is just a mouthful = synonym for =E2=80=9CUp=E2=80=9D. You could just name it: Round::Up At this point, you may invoke either Hamming or Levenshtein and compare = it negatively with `Round::HalfUp`. Yes there is a risk a confusion (and = I do think that such a name is suboptimal for this reason), but the = confusion is not just caused by the short Levenshtein distance. That = brings to the most important part of my review.=20 ------- In my opinion, the most important criterion for a good name is: The name must be clear for itself, not just when comparing it with other = ones. The problem with `Round::Up` (or `Round::[Towards]PositiveInfinity`), = when you first encounter it, is that it is relatively easy to = mistakingly assume that it is a =E2=80=9Chalf-*=E2=80=9D mode, and to = erroneously interpret it as `Round::HalfUp` (or, its synonym = `Round::HalfTowardsPositiveInfinity`). But that the converse is false: it is impossible to interpret = `Round::HalfUp` as if it were `Round::Up` (or = `Round::TowardsPositiveInfinity`), because of the distinctive =E2=80=9CHal= f=E2=80=9D token that immediately indicate the right interpretation. So, the best way to disambiguate `Round::Up` from `Round::HalfUp`, is = not to replace =E2=80=9CUp=E2=80=9D with some creative synonym, but to = add a distinctive token that plays the role of =E2=80=94 and contrasts = with =E2=80=94 =E2=80=9CHalf=E2=80=9D. I don=E2=80=99t know if the = following suggestion makes sense for you, but it is the one I have = found: Round::FullUp --------- That said, I think that there is an even better option. I know you will = not like it, but bear with me. I sincerely think that the best name is = just: Round::Ceiling It is short, distinctive, and standard across the computing industry. Yes, this name is idiosyncratic to English and not used in several other = (natural) languages, and if you don=E2=80=99t know English, you will not = grasp the metaphor and have to just learn it. However, whatever other = name you invent, you *have* to learn =E2=80=9Cceil=E2=80=9D anyway, = because you *will* encounter it sooner or later. Many common = (programming) languages, including JavaScript, C++, Java, Python, have a = `ceil` function. Even if you manage not to learn any of those and to = code in PHP only, you are at risk to stumble on its built-in `ceil(...)` = function, or its newly-introduced `bcceil(...)` variant. Therefore, unless we find a name that is *really* good, I suggest to not = fall into the NIH syndrome, and not to force users to learn another name = *in addition to* =E2=80=9Cceiling=E2=80=9D. --------- For the same reason, `Round::TowardsZero` (suboptimal, because = confusable with `Round::HalfTowardsZero`) could be replaced with: = `Round::Truncate`. =E2=80=94Claude