From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from nue.mailmanlists.eu (nue.mailmanlists.eu [IPv6:2a01:4f8:1c0c:6b10::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id E1D8A1F44D for ; Mon, 15 Apr 2024 22:32:33 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; secure) header.d=ml.ruby-lang.org header.i=@ml.ruby-lang.org header.a=rsa-sha256 header.s=mail header.b=jj2LUnCU; 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=c1kRBsil; dkim-atps=neutral Received: from nue.mailmanlists.eu (localhost [127.0.0.1]) by nue.mailmanlists.eu (Postfix) with ESMTP id 77F628137B; Mon, 15 Apr 2024 22:32:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1713220346; bh=NaISpfE37LMdKwIA5J5yYU4WW+q93+0d8GSKGBBnhpg=; 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=jj2LUnCUotlSBzrUY74LMhifHHZM1FgqEii3tv06fH3b4WLkOra3SFmlF11IQstcy 0AJhKz4Nt6MO00lzFte1wGm8BQA1C8MHkp6TXuJSle2oxLhKgJBsEf5MT6KpoMEroi rxvzeSulTje3tUp8Zlbaa+eMqAorGhdF4RfEhExE= Received: from s.wfbtzhsw.outbound-mail.sendgrid.net (s.wfbtzhsw.outbound-mail.sendgrid.net [159.183.224.105]) by nue.mailmanlists.eu (Postfix) with ESMTPS id F339981362 for ; Mon, 15 Apr 2024 22:32:22 +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=c1kRBsil; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ruby-lang.org; h=from:references:subject:mime-version:content-type: content-transfer-encoding:list-id:to:cc:content-type:from:subject:to; s=s1; bh=Wc+8BP6mQg5heaCmuoeSgSi9Ps5x4wFk/WTuliRtXh8=; b=c1kRBsilNJH732qBWSGp75B3UejWYFp3m5F7mQLh4Lk2uI1QYbljut9WH0tKbiEHEjXY DoRwaN03GkIYJd2SvUinD6uVoEQemnKDPw7KZ9WKadw9AQ3by1fU3zoysPuSJbioz0bR/E w/uYOocnRNZMixGtAuH93skNU5A8AhF6LADEua01Zu2HJalDjgU9I/lJVm1NflcplgKzBG +WbmqF9serSH/WsIttVuky5RtbKQGz76LutN1/NvFdVWLMrq4cvcsFIeh4724GqLHmqqJr vIHWioWCcUEtPSgRodzwHL6EmzpE8mZndq6Ynph/lJXCXxRPGg8vCsYpAbqcplyA== Received: by filterdrecv-54566fd897-mbxsc with SMTP id filterdrecv-54566fd897-mbxsc-1-661DAAF6-1 2024-04-15 22:32:22.066439957 +0000 UTC m=+261855.659819839 Received: from herokuapp.com (unknown) by geopod-ismtpd-16 (SG) with ESMTP id M-t7olEZRC6oawzSDsfnoQ for ; Mon, 15 Apr 2024 22:32:22.005 +0000 (UTC) Date: Mon, 15 Apr 2024 22:32:22 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 20428 X-Redmine-Issue-Author: harrisonb X-Redmine-Issue-Priority: Normal X-Redmine-Sender: harrisonb 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: 94114 X-SG-EID: =?us-ascii?Q?u001=2Er2ewSmNTycYPxTs88codaOUpzVDov4lbiJgLBHXWqbCvzOymkUxudwpBo?= =?us-ascii?Q?Vd3buKjkewv84edO98UIWkYMbLtWEdYjT67wOez?= =?us-ascii?Q?nGTeB+zyyYuPW6yJIpr=2F0XgHT1lKpUa7GLBvMIj?= =?us-ascii?Q?4QMTATiU=2FmvaJ7N81mmyl29Myi9yFuNz5EgNeJ6?= =?us-ascii?Q?sVAKF848UY3+H2SA7s=2F6AjtPLC4u4dfaYvZEuRw?= =?us-ascii?Q?I1fhA+Tgl8Wm2qTRi541PWsdgeXMa0mbLGwLJp3?= =?us-ascii?Q?O+yTi6J3wZFNhK+Cw90omMyyeg=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: ZX25QDOHN4ANXMZZBAHPVNYYZQ5GTMSH X-Message-ID-Hash: ZX25QDOHN4ANXMZZBAHPVNYYZQ5GTMSH X-MailFrom: bounces+313651-b711-ruby-core=ml.ruby-lang.org@em5188.ruby-lang.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list Reply-To: Ruby developers Subject: [ruby-core:117519] [Ruby master Feature#20428] Ability to reference current class/module in lexical scope List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "harrisonb (Hazel Bachrach) via ruby-core" Cc: "harrisonb (Hazel Bachrach)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #20428 has been updated by harrisonb (Hazel Bachrach). ufuk (Ufuk Kayserilioglu) wrote in #note-1: > I think you should be able to use `Module.nesting.first` to get the closest lexical nesting to the executing code. There might be edge-cases where this doesn't work the way you might want it to work, but it definitely works for your example: > ```ruby > module Foo > module Bar > def blah > puts "executing from #{Module.nesting.first}" > end > end > end > > class Baz > include Foo::Bar > > def blah > super > > puts "executing from #{self.class.name}" > end > end > > Baz.new.blah > ``` > outputs > ``` > executing from Foo::Bar > executing from Baz > ``` It absolutely does--apologies for using up your time informing me of an existing API! Thank you! ---------------------------------------- Feature #20428: Ability to reference current class/module in lexical scope https://bugs.ruby-lang.org/issues/20428#change-107908 * Author: harrisonb (Hazel Bachrach) * Status: Open ---------------------------------------- Hello! As far as I know, there is no way to reference the current `Class` or `Module` one is inside of lexically in Ruby. Would it make sense to add a syntax/keyword for this? ``` ruby module Foo module Bar def blah puts "executing from #{magic_new_keyword}" end end end class Baz include Foo::Bar def blah super puts "executing from #{self.class.name}" end end Baz.new.blah ``` What I'm hoping for is ``` executing from Foo::Bar executing from Baz ``` -- 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/postorius/lists/ruby-core.ml.ruby-lang.org/