I just published a package by said post title to the Open Repository. Here's its package comment.
A terrible package name, I know. But it caught your attention, huh?
It is an anagram for "bad argument kind", which is an error that you may have seen if you've done much DLLCC programming under VW. Two examples:
1) You have a function
<C: void function(float number)>
If you pass a SmallInteger, or a Double, or a Float to this, the VM's DLLCC marshalling magic below primitive 395 will do the right thing. And it will do it faster and with less garbage than if you littered your code with asFloats. But if you pass it a Fraction or a ScaledDecimal, then it will blow up. We like Smalltalk transcendental numbers. We'd like to not have to worry about this. It may be slower, but it should work.
2) You have a function
<C: void function(char* string)>
Pass it a string, and all is good. But what if one of those UserMessages makes its way there? Should you have to put asString in front of every thing. Same problem as above, just another common example.
What this package does is put in place a special handler in the externalAccessFailedWith: code, which notes when the error is of this type, backs the stack back up to the method where things started, sends a recastAsCType: to the offending object, passing along the type, and then lets it try again. If multiple arguments are are encountered, it will repeat for each one.
There's probably a chance for infinite spin, I intend to fix that when I concoct a good test case. It works great for OpenGL and Cairo though.
Basically I wrote this to come up with a more general/encapsulated solution to problems I ran into with CairoGraphics and saw being repeated in the OpenGL packages.
Michael Lucas-Smith deserves some credit for inspiring me to take the time to write this. Thank you. Bob Westergaard deserves some credit for letting me bounce a couple of the ideas off of him. Alan Knight too.