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=0.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET,SPF_HELO_PASS, SPF_PASS autolearn=no 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 87D841F44D for ; Wed, 17 Apr 2024 10:25:44 +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=SNlX4idZ; 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=OHJHzfiR; dkim-atps=neutral Received: from nue.mailmanlists.eu (localhost [127.0.0.1]) by nue.mailmanlists.eu (Postfix) with ESMTP id 5FDCF843BD; Wed, 17 Apr 2024 10:25:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1713349536; bh=PkAcnJZl3++iwUZ2TgbynZHfYHGheVACL5ouDAvA0mA=; 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=SNlX4idZbXOyTXQRHgp9Zv360945nN/DgICbs5+iQEanF6dYLM1/qs4ap9Ymf3U+e gjdzOVbcf8HSwo3FN+7nbpRifwETRD/hSq909MKYJaBL20X2eumGlO+trY8v3WnmPU sbsiyxXcKkv00OOnC4jWIiLI7E8I9Ga6MrCKSHlE= 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 7D207843B7 for ; Wed, 17 Apr 2024 10:25:33 +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=OHJHzfiR; 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=KD8DwWf9tZ2V+JX1jevgMv8yeA+q8JdQB3hu0zbxgdA=; b=OHJHzfiR/l++scQWhbyCCbmmVRju2xXlJi/0MSVF+VRhhC/o1rO+0pVinLCnBxtP6oJO xytEGw34my/JLcszEefHH2HBXqWTa/Th7wN5spXRkRsxNLcocY/MdvqrVce8qHtiyBzMT+ sCxFA/+7nvCRuxRdUnHZLyA6b/irNIB2PoCGezzp1RNsk+D0z6mgu6+Wt/At03EdzHoUN3 K4ugT2R7huIHDrgnVSFot324MwKwX03Cw/To6DnGIxL+ZxzDNICjWi+vQ8tHW4+dcMXA8R jyFeC3Y+b0FBPxGwAaUePK7i4KSfrDL3VFtxu8kNECqxUdDxTOpKGH5BTodikqVA== Received: by filterdrecv-5744f46764-vmkvn with SMTP id filterdrecv-5744f46764-vmkvn-1-661FA39C-5 2024-04-17 10:25:32.472236806 +0000 UTC m=+391050.725913271 Received: from herokuapp.com (unknown) by geopod-ismtpd-7 (SG) with ESMTP id 3VMb_TiRSuq-nfDfMPAz5g for ; Wed, 17 Apr 2024 10:25:32.424 +0000 (UTC) Date: Wed, 17 Apr 2024 10:25:32 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 20335 X-Redmine-Issue-Author: byroot X-Redmine-Issue-Priority: Normal X-Redmine-Sender: Eregon 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: 94155 X-SG-EID: =?us-ascii?Q?u001=2EByjZWvxTCjdoV8K03xEuhE7KqN4thWULFLM7+oH78KY30oYB3qFthsDpL?= =?us-ascii?Q?4w4cbYa3ttBh8bAHPOnE=2FkzPba67JNu7Lnrked2?= =?us-ascii?Q?O7K9VQ=2FJax1DHvnk66C5QF86osW=2FnyK=2FL+0CXZH?= =?us-ascii?Q?f2GcuaQFIze0RMuzcESppMej6uYkGofQ+devXre?= =?us-ascii?Q?QmKU0H3W1CDZXP+ZkLbrqdHzarwFDNZlP8jgh10?= =?us-ascii?Q?bkIZ6w=2FkldRdbCw+6NmAsCyuiI9LS2E0UYfuRmg?= =?us-ascii?Q?wu4Nj7p95ZsvMnm8N6at3PLRGg=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: HEFPQYX7VC4VRKAC3GINIG4LETPW3D3O X-Message-ID-Hash: HEFPQYX7VC4VRKAC3GINIG4LETPW3D3O 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:117559] [Ruby master Feature#20335] `Thread.each_caller_location` should accept the same arguments as `caller` and `caller_locations` List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "Eregon (Benoit Daloze) via ruby-core" Cc: "Eregon (Benoit Daloze)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #20335 has been updated by Eregon (Benoit Daloze). mame (Yusuke Endoh) wrote in #note-11: > A little addition: the dicussion about length and range was considered (not ignored), but @matz said he didn't see the need to make it inconsistent with Kernel#caller and Kernel#caller_locations in this case. Thank you for the precision. I think it is likely other Ruby implementations raise ArgumentError if the Range begin or end is negative, because it makes no sense (IOW wrong usage) to use that with `Thread.each_caller_location`: it forces to walk the entire stack to count the number of frames when the point of `Thread.each_caller_location` is to not walk the entire stack but just the parts being yielded to the block. I would suggest CRuby does the same for consistency. ---------------------------------------- Feature #20335: `Thread.each_caller_location` should accept the same arguments as `caller` and `caller_locations` https://bugs.ruby-lang.org/issues/20335#change-107957 * Author: byroot (Jean Boussier) * Status: Closed ---------------------------------------- `Thread.each_caller_location` was added to Ruby 3.2 as part of [Feature #16663] and is a very useful API for emitting warnings with a proper source location and similar use cases. However in many of the cases where I used it, or seen it used, it was needed to skip the first, or a couple frames: Examples: Sorbet: https://github.com/Shopify/sorbet/blob/b27a14c247ace7cabdf0f348bfb11fdf0b7e9ab4/gems/sorbet-runtime/lib/types/private/caller_utils.rb#L6-L18 ```ruby def self.find_caller skiped_first = false Thread.each_caller_location do |loc| unless skiped_first skiped_first = true next end next if loc.path&.start_with?("= 1 frames_to_skip -= 1 next end # snipp... ``` ### Proposal I think it would be very useful if `Thread.each_caller_location` accepted the same arguments as `caller` and `caller_locations`: ```ruby #each_caller_location(start = 1, length = nil) #each_caller_location(range) ``` @jeremyevans0 what do you think? -- 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/