>>> It is interesting to note that of course, after this was added to 3.9, 
>>> there was
>>> someone *very hard* arguing that adding Pragmas was a very dumb idea...
>>>
>>> Who that person was is left as an exercise to the reader of course ;-)
>>
>> Hint: FFI has its own proprietary hardcoded pragma format. It
>> unnecessary complicates the compiler even when not loaded. Not to
>> mention that it breaks all tools that have their own parser, such as
>> RB for example.
>>
>
> I'd like to discuss, what changes to compiler we may introduce to allow FFI
> to handle pragmas in non-intrusive manner.
> I suppose something, like registration mechanism for compiler, where
> any external package can
> register and provide own handler(s) for pragmas.
> Then, of course, an Encoder should have a public API, which would
> allow such handlers to add/change literals
> and method header.
>
> We already having at least another use of pragmas - preferences. It's
> also could use same mechanism which can
> be used to notify a preferences system about appearance of new or
> removal existing preferences as a result of method compilation.

In fact we had that in Squeak 3.9 and early Pharo versions. I even
wrote code that adapted this mechanism for FFI, but the FFI maintainer
insisted on sticking with his compiler hacks.

The idea was that you could add methods with a specific pragma to one
of the compiler classes (I don't remember which one). There was also
one such method for each of the Smalltalk primitives currently
supported (#primitive:, 3primitive:module:, ...). When encountering a
pragma in the source code the compiler would check if this was a
compiler-pragma with the same name defined and perform that method. In
the case of the primitive the compiler would change the compile method
to use the configured primitive. A very strait forward use of pragmas.

However the functionality that made compiler pragmas and primitives
extensible is gone today even in Pharo. For reasons unknown to me
Eliot removed all the code when he added the closure support. Back to
hacking and patching the compiler.

Lukas

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

_______________________________________________
Pharo-project mailing list
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to