From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on starla X-Spam-Level: X-Spam-Status: No, score=-1.2 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; unprotected) header.d=ml.ruby-lang.org header.i=@ml.ruby-lang.org header.a=rsa-sha256 header.s=mail header.b=quZ6FFGp; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=kidbBXWI; dkim-atps=neutral Received: from nue.mailmanlists.eu (nue.mailmanlists.eu [94.130.110.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id E8BE61F47D for ; Thu, 11 Sep 2025 05:23:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1757568150; bh=yfO1Fd1spFv3/p5IrWOChOaJGgPNk7NSnGkzXJut7k4=; h=Date:References:To:Reply-To:Subject:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From:Cc:From; b=quZ6FFGp23mz4zWJhSqIwJubCIHD5La5wEvZkOwaS9lwL6WGjGPGctkm1h3vkEOfc AvYQuGiJjOI8lhqOo8/ZZXN9yJjx41PxWKLieV6yA1VWAK8f3zQlKhHDe8siLZg0Mg P970aPSUYn7E6b0KuGyh3SPqDktbPe9IbpzYjk8w= Received: from nue.mailmanlists.eu (localhost [IPv6:::1]) by nue.mailmanlists.eu (Postfix) with ESMTP id 4A09E48E80 for ; Thu, 11 Sep 2025 05:22:30 +0000 (UTC) Authentication-Results: nue.mailmanlists.eu; dkim=pass (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=kidbBXWI; dkim-atps=neutral Received: from s.wfbtzhsv.outbound-mail.sendgrid.net (s.wfbtzhsv.outbound-mail.sendgrid.net [159.183.224.104]) by nue.mailmanlists.eu (Postfix) with ESMTPS id 6F09A42D4F for ; Thu, 11 Sep 2025 05:21:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ruby-lang.org; h=date:from:references:subject:mime-version:content-type: content-transfer-encoding:list-id:to:cc:content-type:date:from:subject:to; s=s1; bh=ASHzCak0n1xHSokznB39HIEPS2o6uTpma+QfWI13QOI=; b=kidbBXWIYSRzmBw/ZeoF56Bul52USKaH95+oWSRa8YyiDVBagUdED98p2Q39aUaYQWpJ JIyvOnAHHS5gHc37rFCqIdB5zShuc3jNL8P4RZ4q+GH64dpL79HWAAXclbI3gcgoPyWy+D it1fbrIYwLqRIpvP6MUZYZjyC2MDIkCI10193/CjUQIY3+3rfzcI1ImtkdOV3453+VrYFp ImuSI/pXlBkct7q1/0iDMm51ZmQOXG0WsVLmWblUBi4HeEYxsrVPPgWjsDxMl0ph4jSPyO 71u9fLNrmBHLjBCXnmZMLpaWQM+MxOxFE7J8rXpfujf2kGwefL8JVaIWXNtq9vDg== Received: by recvd-769f975875-dffpc with SMTP id recvd-769f975875-dffpc-1-68C25C5E-8 2025-09-11 05:21:34.095029747 +0000 UTC m=+713872.523885152 Received: from herokuapp.com (unknown) by geopod-ismtpd-18 (SG) with ESMTP id LPu9r9xmSrmy7v1R00RBNw for ; Thu, 11 Sep 2025 05:21:34.048 +0000 (UTC) Date: Thu, 11 Sep 2025 05:21:34 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 21555 X-Redmine-Issue-Author: shan X-Redmine-Issue-Priority: Normal X-Redmine-Sender: matz X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-Redmine-MailingListIntegration-Message-Ids: 100013 X-SG-EID: =?us-ascii?Q?u001=2Eqca74XLbbBG2T0HhbEZgBN9E1Qhb0c7bGBe1waNAWdTreSqyWPDekZUgq?= =?us-ascii?Q?NYk4+nm=2F0VIqwc8ZBTQxqk7G=2FctsRLtYG2yTl=2FP?= =?us-ascii?Q?2CaGNETxG2QQc52RpWj5FGIfVkcmVNCdrnWKlFf?= =?us-ascii?Q?fjbKcFyl2PYoANPXAFJUbwGQfkxVCAbf4TgzXWZ?= =?us-ascii?Q?kzaJAuwaejAlwc9WlHQKw1=2Fitoj7HDeCvot88Lo?= =?us-ascii?Q?2xIKrAs5d=2F4ZvxoOWfd1GhTy38eXxSTrhr6X1lL?= =?us-ascii?Q?NdU9hcXUNvqJBqtF0ugx2=2F=2F8oA=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: UMZEPBPDLJJPTIHA6XXXC3CH2GBTVF7X X-Message-ID-Hash: UMZEPBPDLJJPTIHA6XXXC3CH2GBTVF7X X-MailFrom: bounces+313651-b711-ruby-core=ml.ruby-lang.org@em5188.ruby-lang.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list Reply-To: Ruby developers Subject: [ruby-core:123215] [Ruby Feature#21555] Add support for predicate attribute reader names List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "matz (Yukihiro Matsumoto) via ruby-core" Cc: "matz (Yukihiro Matsumoto)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #21555 has been updated by matz (Yukihiro Matsumoto). Status changed from Open to Rejected I still ask you to define `def valid? = @valid` manually. It is not much worse than `attr_reader :valid?`. Matz. ---------------------------------------- Feature #21555: Add support for predicate attribute reader names https://bugs.ruby-lang.org/issues/21555#change-114545 * Author: shan (Shannon Skipper) * Status: Rejected ---------------------------------------- After manually aliasing predicate methods many times, I wanted to propose letting `attr_reader` take predicate method names that correspond to instance variables of the base name without a trailing question mark. https://github.com/ruby/ruby/pull/14391 If the base name method doesn't already exist, a predicate name defines a base name method attribute reader to alias then undefines the base name. For example, this creates an `enabled?` method that reads `@enabled`: ```ruby attr_reader :enabled? ``` This feature is only supported for `attr_reader` and `attr`, not `attr_writer` or `attr_accessor`, since setter methods cannot have question marks. Example: ```ruby class Example attr_reader :valid?, :meaning def initialize @valid = [true, false].sample @meaning = 42 end end Example.new.valid? #=> true ``` -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/