<div dir="ltr">Hey people, I'm passing lots of D function pointers to C, and naturally, the C api expects the fp signatures are all nothrow.<div><br></div><div>Which means, my D functions all look like this:</div><div><br></div><div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>void callback() nothrow</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>{</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">              </span>try</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">            </span>{</div><div><span style="white-space:pre">             </span><span style="white-space:pre">     ...lots of code...</span><br></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">           </span>}<br></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">            </span>catch (Exception e)</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">            </span>{</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                      </span>...log error or abort...</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">               </span>}</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">      </span>}<br></div></div><div><br></div><div><br></div><div>I'm generally annoyed by all the extra indentation.</div><div>Since nothrow is a central thing in D, I wondered if it would be reasonable to allow a nice little bit of sugar to assist working with nothrow that would look like this:</div><div><br></div><div><div><span class="gmail-Apple-tab-span" style="white-space:pre">    </span>void catchingCallback() nothrow</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>{</div><div><span style="white-space:pre">     </span><span style="white-space:pre">     </span><span style="white-space:pre">...lots of code...</span></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">  </span>}<br></div><div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>catch (Exception e)<br></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">  </span>{</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">              </span>...log error or abort...</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">       </span>}</div></div></div><div><br></div><div>Syntactically similar to the existing in/out sections, although I think it would be nicer at the bottom...</div><div>It's simply a lowering which wraps the entire function body scope in a try.</div><div><br></div><div>It's not a really big deal, but it would feel a whole lot tidier in my existing code.<br></div><div>I don't imagine how it would really affect anything else.</div><div><br></div><div>Terrible idea?</div></div>