So what are the semantics to BlockClosure's? When are the values of temps bound to the block?<div><br><br><div class="gmail_quote">On Wed, Aug 4, 2010 at 11:02 AM, Randal L. Schwartz <span dir="ltr"><<a href="mailto:merlyn@stonehenge.com">merlyn@stonehenge.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">>>>>> "Randal" == Randal L Schwartz <<a href="mailto:merlyn@stonehenge.com">merlyn@stonehenge.com</a>> writes:<br>
<br>
>>>>> "John" == John Chludzinski <<a href="mailto:john.chludzinski@gmail.com">john.chludzinski@gmail.com</a>> writes:<br>
John> How about:<br>
John> test1<br>
<br>
John> | block w z |<br>
John> w := 3. z := 12.<br>
John> block := { [ :a :b | Transcript show: a asString , ' ' , b asString; cr ]<br>
John> . w . z }.<br>
John> w := 0. z := 1.<br>
John> (block at: 1) value: (block at: 2) value: (block at: 3)<br>
<br>
</div>Randal> Yeah, now that closures work, you could effectively curry the values:<br>
<br>
Randal> | block w z |<br>
Randal> w := 3.<br>
Randal> z := 12.<br>
Randal> block :=<br>
Randal> [:captureW :captureZ |<br>
Randal> [Transcript show: captureW asString , ' ' , captureZ asString; cr]]<br>
Randal> value: w value: z.<br>
<br>
Randal> w := 0.<br>
Randal> z := 1.<br>
<br>
Randal> block value. "should still show 3, 12"<br>
<br>
Randal> There might even be a method for that... or it might have just been<br>
Randal> Seaside specific.<br>
<br>
Ahh yes, #cull:cull:<br>
<div class="im"><br>
| block w z |<br>
w := 3.<br>
z := 12.<br>
</div> block := [:newW :newZ | ... ] cull: w cull: z.<br>
<div class="im"> w := 0.<br>
z := 1.<br>
block value.<br>
<br>
</div>Should do it.<br>
<div><div></div><div class="h5"><br>
--<br>
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095<br>
<<a href="mailto:merlyn@stonehenge.com">merlyn@stonehenge.com</a>> <URL:<a href="http://www.stonehenge.com/merlyn/" target="_blank">http://www.stonehenge.com/merlyn/</a>><br>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.<br>
See <a href="http://methodsandmessages.vox.com/" target="_blank">http://methodsandmessages.vox.com/</a> for Smalltalk and Seaside discussion<br>
</div></div></blockquote></div><br></div>