Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123388 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 C3DB61A009C for ; Tue, 21 May 2024 22:30:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1716330682; bh=PhLgnUx+rMfNwiRiMJnYFVkpU6rCVyT/Pa6B7w1ujws=; h=Date:From:Subject:To:From; b=QruxjboDxdPvlcBttN8p53rt469tBQG8+BHQ127cuotwNbKG0jp7t1nhv27WzlyoX uen2NLUqFRB+CXuSdaW2A58qVMlakjL4D8+Tr9m0SmqUZgmVk4iC2MPdfpQcjHQ3sP 7nGIrkf7ls5ftMhhRWMn1kd3zQTSNuwMIAHl7rEWfPMUtCQ6UCNQLOpLAz9lY5vxFR eBwrlG31ps4LAa7NDp7wph4Y3Lrkmzrf3QFOqK8yH0+6IspztRxT7V+jndp6qRWtrf dKT1h9NddElyuzpfILgV4tdWRH7wwFxg6ZoTUX2xPFsQLRPqTy2Tqp7FzmOgCOfawE 1Npg+VPDy6Qsg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C4B60180057 for ; Tue, 21 May 2024 22:31:21 +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.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,HTML_MESSAGE,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-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 ; Tue, 21 May 2024 22:31:21 +0000 (UTC) Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-420104e5336so875655e9.1 for ; Tue, 21 May 2024 15:30:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scriptfusion-com.20230601.gappssmtp.com; s=20230601; t=1716330624; x=1716935424; darn=lists.php.net; h=to:subject:from:content-language:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=Ag+zKyuqkmMJPpNXF31erf64djY5xIlhaYrZKMypV90=; b=3AXHSnu5ZiJ5EideoOn85Tb19pJdar5BKDLol/CaS33M83kSxGJh0zlXHCjN4Oob7t B92WrPctptjTm+UstYigvTbktt+v4gVv3rRRPEeehlzOxnGUULt4LOOVPaaXIZLfu3u9 Vd1A6sYCM9pfcUJMJ58KRzK8YHNaSOm0wxNr77gcH78QVXR8xOAHIADT5VGZfXidx7cc emEF844cUpLqoNVImvS7Ml9VQT/OAm6ebidt7kSCSN88OjsE6KT4uDoMWNQTMg0cjs6N lAJFaMFRDtmnhW8rjKN1//I6O+6S9dw/zeX9zgX6qb6O5nuR8AQqOW1LZ9UL9AA9fDWr W+Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716330624; x=1716935424; h=to:subject:from:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ag+zKyuqkmMJPpNXF31erf64djY5xIlhaYrZKMypV90=; b=C7a/shYqrcco0fnNscUJhySePlEXJ48u0jOIai38fZxafwuV5ODb5UKPov78rKB4C9 zwvswuVTFvwEFiiDt2s5yp27M9KDbq3YFGBWCBdgqWrbCHGA9bfkEFlw/vfgQTEGW6+x PdHYBc8TcnRSg7Dx1l0vbk+x2JjYG4m8iH+Rkm9vhLAeT4iA5Z9ZfS8FfMM4MjPkwfYf rPHp545Dm7CK2Iz+54OP+M7k0dKxukdx85HD6Bud5gz0IJjbNBcXRTZIcySYApDz5SD4 ndeMFwOtc0RAwcUz77wYabdUkgXNy9czmCdz7HbmNREdyypylsx/qYyqopAwQuTYvIIk IaHQ== X-Gm-Message-State: AOJu0YwXDPwYB2IALcWlr4UcYdtg5ofVc8LUymOG+C49juzb/y/0QNU4 OQlXFKZAd5KYnmWvvIP+ekO+V4Z1qzlZVz7+/Ly2k57RpMkVnrQ4qpMFk3rvSpUvLa79Wut5dww e X-Google-Smtp-Source: AGHT+IEkfrLUMnO58Y7iLHDL8y6JiC3U0+40WmA9EsxPTShA5vDu+yQShnB2idbwcAzGaQIK2dKgVg== X-Received: by 2002:a05:600c:3508:b0:420:f0c3:8672 with SMTP id 5b1f17b1804b1-420fce6d67dmr3007695e9.7.1716330624641; Tue, 21 May 2024 15:30:24 -0700 (PDT) Received: from ?IPV6:2a01:4b00:bf09:5101:2587:d9b1:339a:a3e9? ([2a01:4b00:bf09:5101:2587:d9b1:339a:a3e9]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-41fccfe1532sm467613145e9.46.2024.05.21.15.30.24 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 May 2024 15:30:24 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------3VL3kuViopNqNbs8XhXPIxaV" Message-ID: Date: Tue, 21 May 2024 23:30:23 +0100 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-GB Subject: [PHP-DEV] [Discussion] To: internals@lists.php.net From: bilge@scriptfusion.com (Bilge) This is a multi-part message in MIME format. --------------3VL3kuViopNqNbs8XhXPIxaV Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Internals, I struggle to understand the benefit of "basic" enumerations and their diminished API. In particular, I often find myself wanting to use |from()/||tryFrom()| to convert a string to an enumeration. To do this, I must convert it to a "backed" enum and copy & paste each name to its value. In all other regards, I still want it to behave like a "basic" enumeration, so I won't abuse the value of the names to act like a mapping; the values will always mirror the names, and if I need to do any mappings, I'll add match() functions. My question, then, is why can't basic enumerations have these semantics by default? Or, to state it more concretely, what would be the downside to having all "basic" enumerations actually being "backed" enumerations whose values implicitly mirror their names for the purposes of converting to/from strings? Would this not make basic enumeration more useful without any particular downsides? Kind regards, Bilge --------------3VL3kuViopNqNbs8XhXPIxaV Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Hi Internals,

I struggle to understand the benefit of "basic" enumerations and their diminished API. In particular, I often find myself wanting to use from()/tryFrom() to convert a string to an enumeration. To do this, I must convert it to a "backed" enum and copy & paste each name to its value. In all other regards, I still want it to behave like a "basic" enumeration, so I won't abuse the value of the names to act like a mapping; the values will always mirror the names, and if I need to do any mappings, I'll add match() functions.

My question, then, is why can't basic enumerations have these semantics by default? Or, to state it more concretely, what would be the downside to having all "basic" enumerations actually being "backed" enumerations whose values implicitly mirror their names for the purposes of converting to/from strings? Would this not make basic enumeration more useful without any particular downsides?

Kind regards,
Bilge

--------------3VL3kuViopNqNbs8XhXPIxaV--