Hi Sean,
On Apr 30, 2020, at 7:36 PM, Sean P. DeNigris <sean@clipperadams.com> wrote:
What am I not understanding about FullBlockClosure?
I have a clean block that I'd like to turn into a FullBlockClosure so that I can serialize it without dragging (unneeded methods) into my object graph. However, documentation and in-image example usages seem severely limited. Here was one experiment that ended with a primitive failure. It seems like a receiver is needed and it can't be a dummy value (see commented "receiver: 1"). But what would the receiver be in the absence of an outer context?!
aBlockClosure := [ :a :b | 1 + a + b ]. fbc := (FullBlockClosure outerContext: nil startpc: aBlockClosure startpc numArgs: aBlockClosure argumentCount copiedValues: Array new) "receiver: 1; yourself".
FullBlockClosure doesnât have a startpc. Because it has its own method its startpc is implicit, just like a normal method. Iâm on my phone now, so I donât know what the creation method is off hand. But if you look at how Context implements the FullBlockClosure value primitives in doPrimitive:... you should find it.
fbc value: 2 value: 3. "PrimitiveFailed: primitive #value:value: in FullBlockClosure failed"
----- Cheers, Sean -- Sent from: http://forum.world.st/Pharo-Smalltalk-Developers-f1294837.html