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 [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 83F621F44D for ; Wed, 24 Apr 2024 11:00:24 +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=xP8UAJWP; 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=C8SJbexb; dkim-atps=neutral Received: from nue.mailmanlists.eu (localhost [127.0.0.1]) by nue.mailmanlists.eu (Postfix) with ESMTP id DACD9844BD; Wed, 24 Apr 2024 11:00:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1713956415; bh=iebVlttYg3zXKFWe9SIAUFURoPVYqDQ4yV737hdsI1w=; 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=xP8UAJWPDYiEkTSCbmeJtW275tOl08wzuQ0Z+7O/SYmmHCi/OZsH5j/4SGhU3YRwU PVoG8R7gJXLH7OmvY+30YNYTIJMBZ45walwRWejAWmTv5EFKmsip0d8VXAx60Q0MH2 4GP9v901JgiUfxjoe67y8DmlunslwQPMMrLwa4aI= 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 B9B4D84486 for ; Wed, 24 Apr 2024 11:00:11 +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=C8SJbexb; 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=ReRJRMt3XVIViBvzyexVdkNX1C9fqVN33P1yopieFjE=; b=C8SJbexbSwfGufeYmmka68uuh0rDRuEL97kEr+sibjrjU/7JT967AgEcn4hlXySnvnJ9 I+S1yERI7fFBInXZ4+K07ZQacMtlPsThm3u5HoIX3Z/yfMThr2Sjf6eO1B2IkZeW//N9AX xrtqLXnjwf2qTHed0s0bD63JjsTjF6M3OsDPTqIrTSjR6LeMLYqDiah71c6BpUnYvUK0F7 YjnM5T940ogSvAZhQ7+1DOs8heVYmjBq6hwgWjlwQiSZPPY519W813y0j3L3KowxaUD0Dl B4KaYJV1pZS6GxGI1I8TQpy2TW1veoFcHQQnJttnA1+of5uKbLFmCpj0Wdeq4tBw== Received: by filterdrecv-54566fd897-mbxsc with SMTP id filterdrecv-54566fd897-mbxsc-1-6628E63A-1F 2024-04-24 11:00:10.747477491 +0000 UTC m=+997924.340857318 Received: from herokuapp.com (unknown) by geopod-ismtpd-31 (SG) with ESMTP id CbW9h4geSJ6MtQ_mXy-nSg for ; Wed, 24 Apr 2024 11:00:10.709 +0000 (UTC) Date: Wed, 24 Apr 2024 11:00:10 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 20444 X-Redmine-Issue-Author: esad X-Redmine-Issue-Priority: Normal X-Redmine-Sender: esad 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: 94275 X-SG-EID: =?us-ascii?Q?u001=2ElMtbztYvHZZZvM524qPN0nU7mdj2wbw4OeavLHeQrlG0ZCx2PWmBPGCch?= =?us-ascii?Q?4=2FXCz8t31i+kRsvxV75BGyB0WhcpS3Ai1n9eaWt?= =?us-ascii?Q?fDP=2Fjb=2FX=2FOrLL0T5bdFCXttG5sjU+mDVnhb9eGN?= =?us-ascii?Q?sh6+sCjtZ47qGZwgS=2Fy59pJSI6IKI9pLDLrGKGJ?= =?us-ascii?Q?3MDZj0YKBlpAJoeSXFGhi3P+4G8SAUH1gX2lQgG?= =?us-ascii?Q?ZZjVZv+qoX8+qwkiuKdeQyjji0MPtbvT721r=2FA5?= =?us-ascii?Q?BpDJc+Va4deAplRSegC=2FvM1KQg=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: QSIXUBTC6DZVS4MXKCKTXOEZZLZTCRGX X-Message-ID-Hash: QSIXUBTC6DZVS4MXKCKTXOEZZLZTCRGX 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:117679] [Ruby master Feature#20444] Kernel#loop: returning the "result" value of StopIteration doesn't work when raised directly List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "esad (Esad Hajdarevic) via ruby-core" Cc: "esad (Esad Hajdarevic)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #20444 has been updated by esad (Esad Hajdarevic). ufuk (Ufuk Kayserilioglu) wrote in #note-7: > @esad If you just want to return a result from the `loop`, you can use `break ` to do that: > ``` > $ ruby -e "puts loop { break 3 }" > 3 Calling break from a block passed to a ractor will raise an exception. I think some sample code about my example will be helpful: Let's make a ractor that just calls all blocks passed to it in a loop: ``` r = Ractor.new do block = Ractor.receive loop { block.call() } end ``` Now let's send it a block that raises StopIteration: ``` block = true.instance_eval { proc { raise StopIteration, 3 } } # instance_eval in true gives us a "shareable" proc r.send Ractor.make_shareable(block) r.take # => nil ``` Let's try with a subclass (this works) ``` class MyStop < ::StopIteration attr_reader :result def initialize(result) @result = result end end block = true.instance_eval { proc { raise MyStop, 3 } } r.send Ractor.make_shareable(block) r.take # => 3 ``` ---------------------------------------- Feature #20444: Kernel#loop: returning the "result" value of StopIteration doesn't work when raised directly https://bugs.ruby-lang.org/issues/20444#change-108089 * Author: esad (Esad Hajdarevic) * Status: Feedback ---------------------------------------- There was a https://bugs.ruby-lang.org/issues/11498 a while ago which was merged in, but I was surprised to find out that raising `StopIteration` in a loop like `loop { raise StopIteration.new(3) }` returns nil and not 3. -- 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/