Ahh ok, thank you that makes sense. 
I didn't know about PLT_LINKLET_SHOW_CP0 before that is a nice look behind 
the scene.

[email protected] schrieb am Sonntag, 21. März 2021 um 19:47:03 UTC+1:

> That’s not the job of the macro expander. And the Racket optimizer does 
> reduce (if '#t (#%app not '#f) '#f) — in fact to #t.
>
> If you use Racket CS, try running:
>
> PLT_LINKLET_SHOW_CP0=1 racket file.rkt
>
> where file.rkt is 
>
> #lang racket
> (displayln (if #t (not #f) #f))
>
> Here’s the optimized program:
>
> ;; cp0 ---------------------
> (lambda (instance-variable-reference .get-syntax-literal!1
>          .set-transformer!2 displayln3 print-values4)
>   (call-with-module-prompt
>     (lambda ()
>       (#%call-with-values
>         (lambda () (displayln3 #t))
>         print-values4)))
>   (#2%void))
>
>
> On Mon, Mar 22, 2021 at 1:28 AM [email protected] <[email protected]> 
> wrote:
>
>> The [WordCount] thread caused me to play around with the solutions to see 
>> whether I could see anything else that can be tweaked, I tried a few things 
>> but they didn't improve performance, but it was fun anyway.
>>
>> Then I though I could try the macro stepper and look at the expansion of 
>> [crowdsourced].
>> I disabled macro hiding and stepped to the end.
>> There I saw if statements with a condition that is `(quote #t)` with a 
>> little lock symbol before it.
>>
>> I would like to understand why those terms aren't reduced further.
>> Are they placeholders and are replaced and resolved at a later time?
>>
>> terms copied (without the lock symbol) from the macro stepper
>> (if (if '#t (#%app not '#f) '#f)
>>   (#%app for-loop (#%app unsafe-fx+ '1 pos))
>>   (#%app values))
>>
>> From a naive standpoint I would expect it to be simplified:
>> (if '#t (#%app not '#f) '#f) -> (#%app not '#f)
>>
>> (if (#%app not '#f)
>>   (#%app for-loop (#%app unsafe-fx+ '1 pos))
>>   (#%app values))
>>
>> So expressed another way: why isn't the if with boolean literal as 
>> condition reduced to the corresponding branch? Or does this happen, just 
>> isn't shown in the macro stepper? 
>> What am I misunderstanding here?
>>
>> If there aren't simplifications like that, what is preventing them or 
>> making them not worthwhile?
>>
>>
>> [WordCount] 
>> https://groups.google.com/g/racket-users/c/lGA60P6jboY/m/2ZLDAunBBgAJ
>> [crowdsourced] 
>> https://gist.github.com/Bogdanp/b9256e1a91de9083830cb616b3659ff8
>>
>> -- 
>> 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 [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/fce863fe-85d7-44a6-a2ba-5778df40e6bfn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/racket-users/fce863fe-85d7-44a6-a2ba-5778df40e6bfn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/cd4f9860-e57d-4ce2-bef8-6598a28ddfafn%40googlegroups.com.

Reply via email to