FFIPragma experiment

Lukas Renggli renggli at gmail.com
Sat Aug 19 09:04:12 UTC 2006


On 8/19/06, Andreas Raab <andreas.raab at gmx.de> wrote:
> Heh. Here is yet another interesting data point in this discussion. I
> just went ahead and implemented an FFIPragma just like I mentioned
> before (I'm attaching the changes because they are so hillariously
> simple). It does everything I promised (printing, decompile, browsing
> etc) BUT there is this interesting issue that because of the way the
> compiler got changed, an FFI method now prints like here:
>
> apiDeleteDC: aHDC
>         <apicall: bool 'DeleteDC' (Win32HDC) module: 'gdi32.dll'>
>         <primitive: 120>
>         ^ self externalCallFailed
>
> How come? Because the parser currently only picks up primitives if they
> are registered as pragmas (see pragmaPrimitives). And so, although an
> FFI call *implies* a primitive this primitive should really never be
> exposed via pragmas. This is equivalent to "quick" primitives which
> don't (and shouldn't) show up either.

I was suggesting to fix that and allow other packages to register
their own primitives in the compiler. As explained in my initial mail
this would work perfectly with the Squeak primitives, but not with FFI
as they have a rather strange syntax.

> Which illustrates once more that a primitive isn't a pragma and cannot
> be treated as one.

Nice counter example. Thank you very much for providing it.

If I could do the suggested change to the compiler your example would
work nicely. You change-set still patches the compiler and therefor
introduces this kind of problems. The solution I proposed we would
have only one Pragma in the FFI method, namely #apicall:module:.
Therefor it would also build, decompile, syntax-highlight correctly.

Cheers,
Lukas

-- 
Lukas Renggli
http://www.lukas-renggli.ch



More information about the Squeak-dev mailing list