Converting blocks to methods

Randal L. Schwartz merlyn at
Sat Jan 19 17:11:23 UTC 2008

>>>>> "Martin" == Martin Beck <martin.beck at> writes:

Martin> has anyone tried to accomplish something like

Martin> MyNewClass addMethod:#doSomethingWith: with: [ :arg |
Martin> 	Transcript show: arg].

Martin> MyNewClass new doSomethingWith: 'Hello World'.

Martin> in Squeak? This would mean, to convert a block into a method, thus
Martin> changing the hole semantics. Outer temporaries or other variables are
Martin> of course forbidden. Literals have to be fetched out of the defining
Martin> method and brought into a new compiled method and so on. Or perhaps
Martin> there are other possibilities? Any ideas?

You could invoke the compiler on a decompiled version of the block.  Not the
fastest solution, but probably the easiest. :)

Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at> <URL:>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See for onsite and open-enrollment Perl training!

More information about the Squeak-dev mailing list