A Curious Method

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

A Curious Method

Casey Ransberger-2
I was showing Squeak off to a friend today, and while clicking around in a browser to show off the system's organization, I ran across this method:

BlockStartLocator>>
pushClosureCopyNumCopiedValues: numCopied numArgs: numArgs blockSize: blockSize
"Answer the size of the block"
^blockSize

There's no method tag / pragma here... so why does this method need three parameters? I see six implementers of the message, though... are the extra params there to deal with polymorphism without blowing up? If so, that's kind of interesting, because I hadn't recognized that pattern before.

I was scratching my head and thought I'd share:)

--
Casey Ransberger


Reply | Threaded
Open this post in threaded view
|

Re: A Curious Method

Michael Haupt-3
Hi Casey,

On Mon, Jul 12, 2010 at 9:04 AM, Casey Ransberger
<[hidden email]> wrote:
> There's no method tag / pragma here... so why does this method need three
> parameters? I see six implementers of the message, though... are the extra
> params there to deal with polymorphism without blowing up?

that message is part of the bytecode simulation protocol in
InstructionClient, which BlockStartLocator subclasses. In
InstructionClient, it's even empty. :-)

A "real" implementation is in ContextPart, where it actually does
something. In BlockStartLocator, the responsibility of bytecode
simulation methods is only to, well, locate block start PCs. (See
CompiledMethod >> #blockExtentsInto:from:to:scanner:numberer: for a
usage example.)

> If so, that's kind of interesting, because I hadn't recognized that pattern before.

The interface provided by InstructionClient should surely be provided
by subclasses. It *does* have an ever so faint smell, though. :-)

HTH,

Michael