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 B38711F44D for ; Wed, 17 Apr 2024 17:15:28 +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=RhNITTYZ; 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=PLcL7Ya0; dkim-atps=neutral Received: from nue.mailmanlists.eu (localhost [127.0.0.1]) by nue.mailmanlists.eu (Postfix) with ESMTP id A953084417; Wed, 17 Apr 2024 17:15:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1713374120; bh=+y87F4FPCXXDLU/hWLy7q1ECFk4YjUBMmz8OjvlwMGI=; 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=RhNITTYZMIj3xZgkhw6/vYOJHMv88eh5h9IRAxn/oBkHTyMdNDsnNZqBWM/CVmast 5WsH3LUHC2h7olVnsdOaOI89/GFMtVYv210XzTiVdWAGVIv7kDyASr5yBmb67RhgPu rhzAxpyfruStyw6NFAp6P57wp7Kneb1+wYh8Et/Y= Received: from s.wrqvtzvf.outbound-mail.sendgrid.net (s.wrqvtzvf.outbound-mail.sendgrid.net [149.72.126.143]) by nue.mailmanlists.eu (Postfix) with ESMTPS id CBC4E84415 for ; Wed, 17 Apr 2024 17:15:17 +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=PLcL7Ya0; 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=POs37eyoy/SHGVNHvMOdUCCVv23dw1P9M7HDj8cDDWA=; b=PLcL7Ya0vaRnBy2rsadc1VId/ZRLHL+/PCl0EwguPfzAM1pc/r8mE3RuFqPpJgVx2V/a Y93wYjL0Kjn8l2LAk7wLyHJ8kqslLRGSnbqgSHOofW97VlTg/1hfcE/EptgGiThs7KqjW1 GgwB185s4NHFxcJbYtF98tKeuqTRFrD40ui28wbEm3roCTqS2fcMb5AUC3cwbLgY8r8wGN rQugjYGCB1Ts2vGVRJ4ewXNUTZUKoMlt3jHDIRp7ySMC0VOis3d47JsWl6ISebsgRGwpnI fF/65DGLnHHtluT6dL4iZLoEZ7BxfqnSE+6RT8exzaZTnzNPGU6tlYs2Nppnhujg== Received: by recvd-6b888cd74b-77v27 with SMTP id recvd-6b888cd74b-77v27-1-662003A4-38 2024-04-17 17:15:16.639938781 +0000 UTC m=+414829.913650775 Received: from herokuapp.com (unknown) by geopod-ismtpd-3 (SG) with ESMTP id kplxqgHUTZqU-viTbQlfIg for ; Wed, 17 Apr 2024 17:15:16.598 +0000 (UTC) Date: Wed, 17 Apr 2024 17:15:16 +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: 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: 94167 X-SG-EID: =?us-ascii?Q?u001=2EKmNZ1u3n1vIpO8NNTdp+Q9c0ai7potxbEDLMO7SOJO=2F4KkRUz0d23466m?= =?us-ascii?Q?naiq=2F5fmA4hb60MdRMUAwHZnjIWVFu=2FrqiBOz5c?= =?us-ascii?Q?nOvkBudsSThdNwH9u60ec5iYAF1JnlXLfasI76H?= =?us-ascii?Q?IURgUswyk9Qw34+RSvLX=2Fa=2FJ1pqexGBDrfqspY2?= =?us-ascii?Q?LDhN3ZZH1UzrgAn4wWhIJ7VdMOdSvifqObYhaRO?= =?us-ascii?Q?TzpKGUl+Qy0Q9W+=2F7P9LO89hCvJR2FDAKg8Ovjq?= =?us-ascii?Q?wuutiWjJuhbE+Ca2rimFmHvN1g=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: PQ3YDHZOEBSEWXL36R6ZNXQCG6IDHVQE X-Message-ID-Hash: PQ3YDHZOEBSEWXL36R6ZNXQCG6IDHVQE 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:117571] [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: "byroot (Jean Boussier) via ruby-core" Cc: "byroot (Jean Boussier)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #20335 has been updated by byroot (Jean Boussier). > the point of Thread.each_caller_location is to not walk the entire stack Is it to not walk the entire stack, or simply not to generate the `Backtrace::Location` objects for the entire stack? My guess is that the later is most of the overhead, and the walking, while unfortunate, isn't that bad. But I haven't measured. ---------------------------------------- Feature #20335: `Thread.each_caller_location` should accept the same arguments as `caller` and `caller_locations` https://bugs.ruby-lang.org/issues/20335#change-107968 * 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/