<div dir="ltr"><div dir="ltr"><div>Just a follow up: <br></div><div><br></div><div>It is possible to do it with a cond-expand, as the gerbil compiler can detect when it is compiling with (not safe).</div><div>The contract check in the generated code would be at the function entry point and look like:</div><div>(cond-expand</div><div> (gerbil-runtime-checks</div><div>  ...) ;; do checks and raise exception if the contract is violated</div><div> (else))</div><div><br></div><div>When the compiler detects that it is in a safe context (absence of a local or prelude (not safe) declaration), then it</div><div>can emit a (define-cond-expand-feature|gerbil-runtime-checks|) for gsc, and compile in the contract checks.</div><div><br></div><div>This is a reasonably good solution, so there is no pressing need to add a construct to gambit that conditionally compiles based on declarations.</div><div><br></div><div>-- vyzo<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 26, 2019 at 8:39 PM Dimitris Vyzovitis <<a href="mailto:vyzo@hackzen.org">vyzo@hackzen.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Is there a mechanism by which we can declare code to be eliminated when compiling with (declare (not safe))?</div><div>I haven't been able to find anything, and it would be very nice to have something like (when-declare (safe) stuff ...),</div><div>which would be eliminated in unsafe compilation.</div><div>The context is that I want to add a contract system to Gerbil, but I don't want the runtime checks to persist when</div><div>compiling with (not safe).</div><div><br></div><div>-- vyzo<br></div></div>
</blockquote></div></div>