|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | +<meta charset="utf-8"> |
| 5 | +<title>Issue 4208: Wording needs to ensure that in connect(sndr, rcvr) that rcvr expression is only evaluated once</title> |
| 6 | +<meta property="og:title" content="Issue 4208: Wording needs to ensure that in connect(sndr, rcvr) that rcvr expression is only evaluated once"> |
| 7 | +<meta property="og:description" content="C++ library issue. Status: New"> |
| 8 | +<meta property="og:url" content="https://cplusplus.github.io/LWG/issue4208.html"> |
| 9 | +<meta property="og:type" content="website"> |
| 10 | +<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png"> |
| 11 | +<meta property="og:image:alt" content="C++ logo"> |
| 12 | +<style> |
| 13 | + p {text-align:justify} |
| 14 | + li {text-align:justify} |
| 15 | + pre code.backtick::before { content: "`" } |
| 16 | + pre code.backtick::after { content: "`" } |
| 17 | + blockquote.note |
| 18 | + { |
| 19 | + background-color:#E0E0E0; |
| 20 | + padding-left: 15px; |
| 21 | + padding-right: 15px; |
| 22 | + padding-top: 1px; |
| 23 | + padding-bottom: 1px; |
| 24 | + } |
| 25 | + ins {background-color:#A0FFA0} |
| 26 | + del {background-color:#FFA0A0} |
| 27 | + table.issues-index { border: 1px solid; border-collapse: collapse; } |
| 28 | + table.issues-index th { text-align: center; padding: 4px; border: 1px solid; } |
| 29 | + table.issues-index td { padding: 4px; border: 1px solid; } |
| 30 | + table.issues-index td:nth-child(1) { text-align: right; } |
| 31 | + table.issues-index td:nth-child(2) { text-align: left; } |
| 32 | + table.issues-index td:nth-child(3) { text-align: left; } |
| 33 | + table.issues-index td:nth-child(4) { text-align: left; } |
| 34 | + table.issues-index td:nth-child(5) { text-align: center; } |
| 35 | + table.issues-index td:nth-child(6) { text-align: center; } |
| 36 | + table.issues-index td:nth-child(7) { text-align: left; } |
| 37 | + table.issues-index td:nth-child(5) span.no-pr { color: red; } |
| 38 | + @media (prefers-color-scheme: dark) { |
| 39 | + html { |
| 40 | + color: #ddd; |
| 41 | + background-color: black; |
| 42 | + } |
| 43 | + ins { |
| 44 | + background-color: #225522 |
| 45 | + } |
| 46 | + del { |
| 47 | + background-color: #662222 |
| 48 | + } |
| 49 | + a { |
| 50 | + color: #6af |
| 51 | + } |
| 52 | + a:visited { |
| 53 | + color: #6af |
| 54 | + } |
| 55 | + blockquote.note |
| 56 | + { |
| 57 | + background-color: rgba(255, 255, 255, .10) |
| 58 | + } |
| 59 | + } |
| 60 | +</style> |
| 61 | +</head> |
| 62 | +<body> |
| 63 | +<hr> |
| 64 | +<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#New">New</a> status.</em></p> |
| 65 | +<h3 id="4208"><a href="lwg-active.html#4208">4208</a>. Wording needs to ensure that in <code class='backtick'>connect(sndr, rcvr)</code> that <code class='backtick'>rcvr</code> expression is only evaluated once</h3> |
| 66 | +<p><b>Section:</b> 33.9.10 <a href="https://wg21.link/exec.connect">[exec.connect]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a> |
| 67 | + <b>Submitter:</b> Eric Niebler <b>Opened:</b> 2025-02-07 <b>Last modified:</b> 2025-02-09</p> |
| 68 | +<p><b>Priority: </b>Not Prioritized |
| 69 | +</p> |
| 70 | +<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p> |
| 71 | +<p><b>Discussion:</b></p> |
| 72 | +<p> |
| 73 | +Imported from <a href="https://github.com/cplusplus/sender-receiver/issues/325">cplusplus/sender-receiver #325</a>. |
| 74 | +</p> |
| 75 | +<p> |
| 76 | +The current wording of <code class='backtick'>connect(sndr, rcvr)</code> defines the <code class='backtick'>new_sndr</code> expression as |
| 77 | +<code>transform_sender(decltype(<i>get-domain-late</i>(sndr, get_env(rcvr))){}, sndr, get_env(rcvr))</code>. |
| 78 | +<p/> |
| 79 | +It then defines <code class='backtick'>connect(sndr, rcvr)</code> as expression equivalent to <code class='backtick'>new_sndr.connect(rcvr)</code>. |
| 80 | +<p/> |
| 81 | +As currently worded, this requires evaluating the <code class='backtick'>rcvr</code> expression twice. Note that the first |
| 82 | +usage in the <code class='backtick'>new_sndr</code> expression is unevaluated, but the second usage in <code class='backtick'>get_env(rcvr)</code> is evaluated. |
| 83 | +<p/> |
| 84 | +I think we need to add an extra sentence at the end of this section saying "Where the expression |
| 85 | +<code class='backtick'>rcvr</code> is only evaluated once." or similar. |
| 86 | +</p> |
| 87 | + |
| 88 | + |
| 89 | +<p id="res-4208"><b>Proposed resolution:</b></p> |
| 90 | +<p> |
| 91 | +This wording is relative to <a href="https://wg21.link/N5001">N5001</a>. |
| 92 | +</p> |
| 93 | + |
| 94 | +<ol> |
| 95 | +<li> |
| 96 | +<p>Modify 33.9.10 <a href="https://wg21.link/exec.connect">[exec.connect]</a> as indicated:</p> |
| 97 | + |
| 98 | +<blockquote> |
| 99 | +<p> |
| 100 | +-6- The expression <code class='backtick'>connect(sndr, rcvr)</code> is expression-equivalent to: |
| 101 | +</p> |
| 102 | +<ol style="list-style-type: none"> |
| 103 | +<li><p>(6.1) — <code class='backtick'>new_sndr.connect(rcvr)</code> if that expression is well-formed. |
| 104 | +<p/> |
| 105 | +<i>Mandates</i>: The type of the expression above satisfies <code class='backtick'>operation_state</code>. |
| 106 | +</p> |
| 107 | +</li> |
| 108 | +<li><p>(6.2) — Otherwise, <code><i>connect-awaitable</i>(new_sndr, rcvr)</code>.</p></li> |
| 109 | +</ol> |
| 110 | +<p> |
| 111 | +<ins>except that <code class='backtick'>rcvr</code> is evaluated only once.</ins> |
| 112 | +<p/> |
| 113 | +<i>Mandates</i>: <code>sender<Sndr> && receiver<Rcvr></code> is <code>true</code>. |
| 114 | +<p/> |
| 115 | +</p> |
| 116 | +</blockquote> |
| 117 | +</li> |
| 118 | +</ol> |
| 119 | + |
| 120 | + |
| 121 | + |
| 122 | + |
| 123 | + |
| 124 | + |
| 125 | +</body> |
| 126 | +</html> |
0 commit comments