<div><div>On Wed, Jun 12, 2024 at 16:32 Mark Volkmann <<a href="mailto:r.mark.volkmann@gmail.com" target="_blank">r.mark.volkmann@gmail.com</a>> wrote:<br></div></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jun 12, 2024 at 6:04 PM Vanessa Freudenberg via Cuis-dev <<a href="mailto:cuis-dev@lists.cuis.st" target="_blank">cuis-dev@lists.cuis.st</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div><div><div>On Wed, Jun 12, 2024 at 15:32 Jaromir Matas <<a href="mailto:mail@jaromir.net" target="_blank">mail@jaromir.net</a>> wrote:<br></div></div><div><div><div class="gmail_quote"></div></div></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div><div><br></div>
<div style="clear:both">So if I understand correctly the #ifTrue:ifFalse message gets inlined only when used with block arguments, and it gets really sent when used without blocks; which means not only there's one more send but also that **both** 'Yes' and 'No' expressions get evaluated before sending <span style="border-color:rgb(255,255,255)">#ifTrue:ifFalse (hence twice as slow?).</span></div></div></blockquote><div dir="auto"><br></div></div></div><div><div><div dir="auto">In this case evaluating both arguments is pretty cheap because they’re simple string constants. </div><div dir="auto"><br></div><div dir="auto">The slowdown comes mainly from actually having to do the sends of “ifTrue:ifFalse:” and “value”. </div></div></div></blockquote><div><br></div><div>Doesn't it seem like the compiler could also be optimized to recognize when the values passed are literal values and then perform the same optimization it does for blocks? I understand it doesn't do that currently and so it is more efficient to pass blocks.</div></div></div></blockquote><div dir="auto"><br></div></div><div><div dir="auto">How would the compiler know if those “literal” objects understand #value? And how could it be sure that #value returns the same object, unchanged?</div><div dir="auto"><br></div><div dir="auto">It can’t. And even if it checked at compile time, the behavior could change between now and later, when the method is actually executed.</div><div dir="auto"><br></div><div dir="auto">While you can use any object that understands #value in those constructs, it doesn’t mean you should. It is neat philosophically, but has little practical value unless you get into meta programming. </div><div dir="auto"><br></div><div dir="auto">BTW, the addition of Object>>value is relatively recent. As in, I remember a time when it did not exist. I’m sure Andres does too, and he has good reasons for cautioning against abusing it.</div><div dir="auto"><br></div><div dir="auto">– Nessa </div><div dir="auto"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div dir="ltr"><div class="gmail_quote"><div dir="auto"></div></div></div></blockquote>
</div>