<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span lang="CS">Hi Eliot, Christoph,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CS">> But should the selector be simply sender: or setSender: ? 
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CS">I'd like it simply `#sender:`. I find #setSender inconsistent (and thus slightly irritating and confusing). And I like the idea to stop considering sender accessor private :)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CS">> And what about swapSender: ? I like sending isContext in several places to validate the argument. 
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS">><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CS">> I like the idea of cleaning up this code. There’s lots of old code and some duplication.  Let’s keep polishing.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CS">I guess at least these four could use `self sender:` instead of `sender :=` to force the type check:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CS">        #swapSender: <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS">        #insertSender:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS">        #setSender:receiver:arguments:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS">        #setSender:receiver:closure:startpc:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CS">(Enclosing a simple suggestion; prevents Christoph's crash example)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CS">Then there's #terminateTo: but "unfortunately" it's a primitive so it can't be fixed the same way... The following will crash the VM:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CS">```<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS">thisContext terminateTo: 1<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS">```<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CS">> I also find the sends to access sender in e.g. insertSender: unnecessary and complicating.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CS">+1 indeed<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CS">When at cleaning up: would it make sense to add this to complement the same you did for basicNew:, new: and new?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CS">Context class>>basicNew<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS">        self instanceCreationError<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CS"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CS">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS">best,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS">Jaromir</span><span style="color:#2E75B6"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#8FAADC"><o:p> </o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="border:none;padding:0in"><b>From: </b><a href="mailto:eliot.miranda@gmail.com">Eliot Miranda</a><br>
<b>Sent: </b>Monday, September 19, 2022 17:44<br>
<b>To: </b><a href="mailto:squeak-dev@lists.squeakfoundation.org">The general-purpose Squeak developers list</a><br>
<b>Subject: </b>Re: [squeak-dev] The Inbox: Kernel-eem.1489.mcz</p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Hi Jaromir,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-bottom:12.0pt">On Sep 19, 2022, at 7:13 AM, Jaromir Matas <mail@jaromir.net> wrote:<o:p></o:p></p>
</blockquote>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><span lang="CS">Hi Eliot, Christoph,</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="CS"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="CS">I have a question re: [Vm-dev] [OpenSmalltalk/opensmalltalk-vm] pushRcvr fails for context instances whose sender has been set to an Integer instance (Issue #654):</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="CS"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="CS">Why would one want to be able to send `privSender: 1` ? Is it useful for something? Otherwise I'm thinking why not block such an assignment inside #privSender e.g. like this:</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="CS"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="CS">Context>>privSender: aContextOrNil</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="CS"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="CS">        sender := aContextOrNil ifNotNil: [aContextOrNil asContext]</span><o:p></o:p></p>
</div>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">Well, I find the convention weak, but the implication of the priv prefix in privSender: et al is that these are private selectors, and hence only used within Context (clearly violated in a few places) and hence only correctly.<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">However, your idea is a good one; I’ll add it.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><span lang="CS">As a side-effect this would allow e.g. blocks to be used as reasonable arguments too...</span><o:p></o:p></p>
</div>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">Which might simplify some debugger code.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">But should the selector be simply sender: or setSender: ?  And what about swapSender: ?  I like sending isContext in several places to validate the argument.  I also find the sends to access sender in e.g. insertSender: unnecessary and
 complicating.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I like the idea of cleaning up this code. There’s lots of old code and some duplication.  Let’s keep polishing.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><span lang="CS"> </span>Thanks,<o:p></o:p></p>
<p class="MsoNormal"><span lang="CS">Jaromir</span><o:p></o:p></p>
</div>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">Eliot<o:p></o:p></p>
<div>
<p class="MsoNormal">_,,,^..^,,,_ (phone)<o:p></o:p></p>
</div>
<div id="AppleMailSignature">
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From: </b><a href="mailto:commits@source.squeak.org">commits@source.squeak.org</a><br>
<b>Sent: </b>Monday, September 19, 2022 1:29<br>
<b>To: </b><a href="mailto:squeak-dev@lists.squeakfoundation.org">squeak-dev@lists.squeakfoundation.org</a><br>
<b>Subject: </b>[squeak-dev] The Inbox: Kernel-eem.1489.mcz<o:p></o:p></p>
</div>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">A new version of Kernel was added to project The Inbox:<br>
<a href="http://source.squeak.org/inbox/Kernel-eem.1489.mcz">http://source.squeak.org/inbox/Kernel-eem.1489.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Kernel-eem.1489<br>
Author: eem<br>
Time: 18 September 2022, 4:29:27.672168 pm<br>
UUID: 825872cd-7b3f-48cb-b765-0fa7bb4b4f21<br>
Ancestors: Kernel-eem.1488<br>
<br>
Ensure that a Context can only be instantiated via newForMethod:, and that the resulting Context has its method inst var initiialized.<br>
<br>
=============== Diff against Kernel-eem.1488 ===============<br>
<br>
Item was changed:<br>
  ----- Method: BlockClosure>>asContextWithSender: (in category 'private') -----<br>
  asContextWithSender: aContext<br>
         "Inner private support method for evaluation.  Do not use unless you know what you're doing."<br>
  <br>
         ^(Context newForMethod: outerContext method)<br>
                 setSender: aContext<br>
                 receiver: outerContext receiver<br>
-                method: outerContext method<br>
                 closure: self<br>
                 startpc: startpcOrMethod;<br>
                 privRefresh!<br>
<br>
Item was changed:<br>
  ----- Method: BlockClosure>>simulateValueWithArguments:caller: (in category 'system simulation') -----<br>
  simulateValueWithArguments: anArray caller: aContext<br>
         "Simulate the valueWithArguments: primitive. Fail if anArray is not an array of the right arity."<br>
         | newContext sz |<br>
         newContext := (Context newForMethod: outerContext method)<br>
                                                 setSender: aContext<br>
                                                 receiver: outerContext receiver<br>
-                                                method: outerContext method<br>
                                                 closure: self<br>
                                                 startpc: startpcOrMethod.<br>
         ((newContext objectClass: anArray) ~~ Array<br>
          or: [numArgs ~= anArray size]) ifTrue:<br>
                 [^Context primitiveFailTokenFor: nil].<br>
         sz := self basicSize.<br>
         newContext stackp: sz + numArgs.<br>
         1 to: numArgs do:<br>
                 [:i| newContext at: i put: (anArray at: i)].<br>
         1 to: sz do:<br>
                 [:i| newContext at: i + numArgs put: (self at: i)].<br>
         ^newContext!<br>
<br>
Item was changed:<br>
  ----- Method: Context class>>basicNew: (in category 'instance creation') -----<br>
  basicNew: size <br>
+        self instanceCreationError!<br>
-        ^ (size = CompiledMethod smallFrameSize or: [ size = CompiledMethod fullFrameSize ])<br>
-                ifTrue: [ super basicNew: size ]<br>
-                ifFalse: [ self error: 'Contexts must be ' , CompiledMethod smallFrameSize , ' or ' , CompiledMethod fullFrameSize , ' bytes.' ]!<br>
<br>
Item was added:<br>
+ ----- Method: Context class>>instanceCreationError (in category 'private') -----<br>
+ instanceCreationError<br>
+        self error: 'Contexts must only be created with newForMethod:'!<br>
<br>
Item was changed:<br>
  ----- Method: Context class>>new (in category 'instance creation') -----<br>
  new<br>
+        self instanceCreationError!<br>
- <br>
-        self error: 'Contexts must only be created with newForMethod:'!<br>
<br>
Item was changed:<br>
  ----- Method: Context class>>new: (in category 'instance creation') -----<br>
  new: size<br>
+        self instanceCreationError!<br>
- <br>
-        self error: 'Contexts must only be created with newForMethod:'!<br>
<br>
Item was changed:<br>
  ----- Method: Context class>>newForMethod: (in category 'instance creation') -----<br>
+ newForMethod: aCompiledCode<br>
- newForMethod: aMethod<br>
         "This is the only method for creating new contexts, other than primitive cloning.<br>
         Any other attempts, such as inherited methods like shallowCopy, should be<br>
         avoided or must at least be rewritten to determine the proper size from the<br>
         method being activated.  This is because asking a context its size (even basicSize!!)<br>
         will not return the real object size but only the number of fields currently<br>
         accessible, as determined by stackp."<br>
  <br>
+        ^(super basicNew: aCompiledCode frameSize)<br>
+                privMethod: aCompiledCode!<br>
-        ^ super basicNew: aMethod frameSize!<br>
<br>
Item was changed:<br>
  ----- Method: Context class>>sender:receiver:method:arguments: (in category 'instance creation') -----<br>
  sender: s receiver: r method: m arguments: args <br>
         "Answer an instance of me with attributes set to the arguments."<br>
  <br>
+        ^(self newForMethod: m) setSender: s receiver: r arguments: args!<br>
-        ^(self newForMethod: m) setSender: s receiver: r method: m arguments: args!<br>
<br>
Item was added:<br>
+ ----- Method: Context>>privMethod: (in category 'private') -----<br>
+ privMethod: aCompiledCode<br>
+ <br>
+        method := aCompiledCode!<br>
<br>
Item was added:<br>
+ ----- Method: Context>>setSender:receiver:arguments: (in category 'private') -----<br>
+ setSender: s receiver: r arguments: args <br>
+        "Initialize the receiver's initial state."<br>
+ <br>
+        pc := method initialPC.<br>
+        self stackp: method numTemps.<br>
+        sender := s.<br>
+        receiver := r.<br>
+        closureOrNil := nil.<br>
+        1 to: args size do: [:i | self at: i put: (args at: i)]!<br>
<br>
Item was added:<br>
+ ----- Method: Context>>setSender:receiver:closure:startpc: (in category 'private') -----<br>
+ setSender: s receiver: r closure: c startpc: startpc<br>
+        "Create the receiver's initial state."<br>
+ <br>
+        sender := s.<br>
+        receiver := r.<br>
+        closureOrNil := c.<br>
+        pc := startpc.<br>
+        stackp := 0!<br>
<br>
Item was removed:<br>
- ----- Method: Context>>setSender:receiver:method:arguments: (in category 'private') -----<br>
- setSender: s receiver: r method: m arguments: args <br>
-        "Create the receiver's initial state."<br>
- <br>
-        sender := s.<br>
-        receiver := r.<br>
-        method := m.<br>
-        closureOrNil := nil.<br>
-        pc := method initialPC.<br>
-        self stackp: method numTemps.<br>
-        1 to: args size do: [:i | self at: i put: (args at: i)]!<br>
<br>
Item was removed:<br>
- ----- Method: Context>>setSender:receiver:method:closure:startpc: (in category 'private') -----<br>
- setSender: s receiver: r method: m closure: c startpc: startpc<br>
-        "Create the receiver's initial state."<br>
- <br>
-        sender := s.<br>
-        receiver := r.<br>
-        method := m.<br>
-        closureOrNil := c.<br>
-        pc := startpc.<br>
-        stackp := 0!<br>
<br>
Item was changed:<br>
  ----- Method: FullBlockClosure>>asContextWithSender: (in category 'private') -----<br>
  asContextWithSender: aContext<br>
         "Inner private support method for evaluation.  Do not use unless you know what you're doing."<br>
  <br>
         ^(Context newForMethod: startpcOrMethod)<br>
                 setSender: aContext<br>
                 receiver: self receiver<br>
-                method: startpcOrMethod<br>
                 closure: self<br>
                 startpc: startpcOrMethod initialPC;<br>
                 privRefresh!<br>
<br>
Item was changed:<br>
  ----- Method: FullBlockClosure>>simulateValueWithArguments:caller: (in category 'simulation') -----<br>
  simulateValueWithArguments: anArray caller: aContext<br>
         "Simulate the valueWithArguments: primitive. Fail if anArray is not an array of the right arity."<br>
         | newContext |<br>
         newContext := (Context newForMethod: startpcOrMethod)<br>
                                                 setSender: aContext<br>
                                                 receiver: receiver<br>
-                                                method: startpcOrMethod<br>
                                                 closure: self<br>
                                                 startpc: startpcOrMethod initialPC.<br>
         ((newContext objectClass: anArray) ~~ Array<br>
          or: [numArgs ~= anArray size]) ifTrue:<br>
                 [^Context primitiveFailTokenFor: nil].<br>
         newContext stackp: startpcOrMethod numTemps.<br>
         1 to: numArgs do:<br>
                 [:i| newContext at: i put: (anArray at: i)].<br>
         1 to: self basicSize do:<br>
                 [:i| newContext at: i + numArgs put: (self at: i)].<br>
         ^newContext!<br>
<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</blockquote>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:0in;margin-right:.5in;margin-bottom:5.0pt;margin-left:.5in">
<o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>