On Wed, Aug 21, 2019 at 2:43 PM George Neuner <gneun...@comcast.net> wrote:
>
>
> On 8/21/2019 1:13 PM, Gustavo Massaccesi wrote:
> > The expander in racket adds something equivalent to
> >     [else (void)]
> > if there is no else clause. (Try an example with the Macro Stepper.)
> > So an explicit else clause would not change the speed of the programs.
> >
> > In some cases the compiler can prove that the else part is not
> > necessary and drop it, Also, I think that the compiler in RacketCS can
> > notice that it has no side effects and also drop it if the result is
> > ignored (but I'm not 100% sure).
>
> Yes.  But in most cases, it is impossible to prove that the 'else' is
> unnecessary.

Yes, but this is why `else` doesn't slow anything down. Unless the
compiler can prove that it's unnecessary, an `else` clause going to be
there whether you write it explicitly or not, which is exactly what
Gustavo wrote above.


> And as I mentioned in my reply to Hendrick, 'cond' is
> pretty simple, but an 'else' - implicit or explicit - can screw up
> optimizing tests in a 'case'.
>

Racket's `case` is an implementation of this approach:
http://scheme2006.cs.uchicago.edu/07-clinger.pdf

It is not significantly complicated by `else`. And that approach was
created in the context of Scheme, which leaves the return value
unspecified when none of the tests are successful. That seems like it
should offer more opportunities for optimization, but I don't think
this approach is any less efficient when the unsuccessful result is
specified as #<void> (as it is in Racket) than when it is not.

- Jon

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAKfDxxxCMFHoC1%2B14VosKdeqOeg-dKc%2B3_nH-hjMf2JWjfxXOA%40mail.gmail.com.

Reply via email to