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=0.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET, 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=ig+U3y5M; 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=ZAhrq9hE; 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 E39A21F646 for ; Fri, 29 Aug 2025 07:17:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1756451860; bh=YLH4+bzPHUDwmn+yqu4uKp+qtWigp55WjNcCZwPisQo=; 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=ig+U3y5MDJpp7Jo9+pP2MxB43ZVVaBDIg/uI1gPkeC//uw84hCy1DNDney6FjIuNq hh16K8ukTsbMCQ5TpkKiP5k1zZI5ASbvEN7Z78lARPF4BpcrLfQQqOKG/c02lhq7Si 8uQ6QopcVq+2/vn53MQCmTIbdnAP6qS15a1SkPfs= Received: from nue.mailmanlists.eu (localhost [IPv6:::1]) by nue.mailmanlists.eu (Postfix) with ESMTP id 24A2C48DB0 for ; Fri, 29 Aug 2025 07:17:40 +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=ZAhrq9hE; dkim-atps=neutral Received: from s.wrqvtvvn.outbound-mail.sendgrid.net (s.wrqvtvvn.outbound-mail.sendgrid.net [149.72.120.130]) by nue.mailmanlists.eu (Postfix) with ESMTPS id 6DA3E48AD4 for ; Fri, 29 Aug 2025 07:16:41 +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=zBsZP5sJ6Q63w8F+p09av/zeZJMszfUQsGzH2MiTAvU=; b=ZAhrq9hEgdS9gUY62YZzWDXG07PA1oIklJLa0M8em5KkSRMyDxCSClucMp051WEtwU6j mp42jb4c5rsJ+YoMvolFku3om9ibUiPjyP90V8omVgftqip0iWbiyStWzR2OGEhoIlQzna KPKlFcIlUXRnB1Hc4lUzDOwYsNFWLWo+rQf80yADwbyzP8gJwtjJbcu+F5JKMV9enhNzKm XVp2dy1q+N/16lfvw3/ijcIPsq+FV1ZYqaocCUoBOXlX79523c5nhDf0mOCGm4/N3B21lz XS2dFfxOX4+4ktrH1QKIWK5F0XFGiI/maTmcURlAUPsIeqtgO4PaiKBhyPnOgjAQ== Received: by recvd-7748d67658-bpjps with SMTP id recvd-7748d67658-bpjps-1-68B153D8-8 2025-08-29 07:16:40.143250275 +0000 UTC m=+7396346.083992329 Received: from herokuapp.com (unknown) by geopod-ismtpd-16 (SG) with ESMTP id -KRLmnCiTTObu8Urjj7JQg for ; Fri, 29 Aug 2025 07:16:40.087 +0000 (UTC) Date: Fri, 29 Aug 2025 07:16:40 +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: byroot 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: 99924 X-SG-EID: =?us-ascii?Q?u001=2EKmNZ1u3n1vIpO8NNTdp+Q9c0ai7potxbEDLMO7SOJO=2F4KkRUz0d23466m?= =?us-ascii?Q?naiq=2F5fmA4hb60MdRMUAwHZnjIWVFu=2FrqiBOz5c?= =?us-ascii?Q?nOvkBudsSTiv5fOLU7JGBx6R2fSD2xll9jZ9MrH?= =?us-ascii?Q?3ojIrH8vZUv6HnuwIqZy5B06R75A8a=2FUBdBTVlg?= =?us-ascii?Q?z8XBfbOzXK54Z1OoNzs1QNmpruef7dnZzq=2FYsKs?= =?us-ascii?Q?hqzkQouttLAm9uZ2NdXL1LiWScQ0i7YOwuE+rr0?= =?us-ascii?Q?fAUXlQcTaqXldpUTLEdKwnas9w=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: QRIWE5RWB24XSG5RPQOB2EVIYGF6RGJQ X-Message-ID-Hash: QRIWE5RWB24XSG5RPQOB2EVIYGF6RGJQ 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:123117] [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: "byroot (Jean Boussier) via ruby-core" Cc: "byroot (Jean Boussier)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #21555 has been updated by byroot (Jean Boussier). > This feature is only supported for attr_reader and attr, not attr_writer or attr_accessor, since setter methods cannot have question marks. Using the same logic, `attr_accessor :enabled?` could generate `#enabled?` and `#enabled=` without problem. `attr_writer :enabled?` would be weird though. ---------------------------------------- Feature #21555: Add support for predicate attribute reader names https://bugs.ruby-lang.org/issues/21555#change-114435 * Author: shan (Shannon Skipper) * Status: Open ---------------------------------------- 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/