<div dir="ltr"><div>That would be a pretty awesome feature!</div><div><br></div><div>-- vyzo<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 27, 2019 at 4:42 PM Marc Feeley <<a href="mailto:feeley@iro.umontreal.ca">feeley@iro.umontreal.ca</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">I was going to suggest using the cond-expand approach.<br>
<br>
Also, it might be interesting for the compiler to make the current declarations testable as cond-expand features.  Giving something like:<br>
<br>
  (cond-expand ((declare (not safe))<br>
                …)<br>
               ((declare (debug))<br>
                …)<br>
               ((declare (optimize-dead-definitions))<br>
                …)<br>
               (else<br>
                …))<br>
<br>
The implementation of this is complicated by the fact that the interpreter and compiler don’t manage declarations the same way.<br>
<br>
Marc<br>
<br>
<br>
<br>
> On Nov 27, 2019, at 9:10 AM, Dimitris Vyzovitis <<a href="mailto:vyzo@hackzen.org" target="_blank">vyzo@hackzen.org</a>> wrote:<br>
> <br>
> Just a follow up: <br>
> <br>
> It is possible to do it with a cond-expand, as the gerbil compiler can detect when it is compiling with (not safe).<br>
> The contract check in the generated code would be at the function entry point and look like:<br>
> (cond-expand<br>
>  (gerbil-runtime-checks<br>
>   ...) ;; do checks and raise exception if the contract is violated<br>
>  (else))<br>
> <br>
> When the compiler detects that it is in a safe context (absence of a local or prelude (not safe) declaration), then it<br>
> can emit a (define-cond-expand-feature|gerbil-runtime-checks|) for gsc, and compile in the contract checks.<br>
> <br>
> This is a reasonably good solution, so there is no pressing need to add a construct to gambit that conditionally compiles based on declarations.<br>
> <br>
> -- vyzo<br>
> <br>
> <br>
> On Tue, Nov 26, 2019 at 8:39 PM Dimitris Vyzovitis <<a href="mailto:vyzo@hackzen.org" target="_blank">vyzo@hackzen.org</a>> wrote:<br>
> Is there a mechanism by which we can declare code to be eliminated when compiling with (declare (not safe))?<br>
> I haven't been able to find anything, and it would be very nice to have something like (when-declare (safe) stuff ...),<br>
> which would be eliminated in unsafe compilation.<br>
> The context is that I want to add a contract system to Gerbil, but I don't want the runtime checks to persist when<br>
> compiling with (not safe).<br>
> <br>
> -- vyzo<br>
<br>
<br>
</blockquote></div>