<div dir="ltr"><div dir="ltr">On Wed, Jun 12, 2024 at 4:28 PM Vanessa Freudenberg <<a href="mailto:vanessa@codefrau.net">vanessa@codefrau.net</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Wed, Jun 12, 2024 at 6:56 AM Mark Volkmann via Cuis-dev <<a href="mailto:cuis-dev@lists.cuis.st" target="_blank">cuis-dev@lists.cuis.st</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">I saw this example in a YouTube video about Smalltalk this morning:<div><br></div><div><font face="monospace">(2 > 3) ifTrue: ['Yes'] ifFalse: ['No']</font></div><div><br></div><div>It seems to me that none of the parentheses or square brackets are needed here.</div><div>The following works the same for me.</div><div><br></div><div><font face="monospace">2 > 3 ifTrue: 'Yes' ifFalse: 'No'</font></div><div><br></div><div>Is it true that keyword messages that take no-arg blocks can always take a literal value instead?</div><div>It seems this works because the `Object` class defines the `value` method to just return `self`.</div></div></blockquote><div><br></div><div>Yes it only works because of Object>>value.</div></div></div></blockquote><div><br></div><div>I assumed that was intentional to support using objects that are not blocks in cases like this.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div>It's also twice as slow to leave out the block brackets because it prevents compiler optimizations and forces actual sends to be made. You can verify that by benchmarking, and understand it by looking at the bytecodes generated and running a message tally.</div></div></div></blockquote><div><br></div><div>I believe you, but I'm curious why it's faster to send the `value:` message to a block than to some other kind of object. Are you saying that the optimizations make it so the `value:` message is not actually sent to a block in this case and code in the block gets inlined? </div></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><font face="arial, helvetica, sans-serif">R. Mark Volkmann</font></div><div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif">Object Computing, Inc.</font></span></div></div></div></div></div></div></div></div></div>