Le 20/09/2014 16:56, Andreas Wacknitz a écrit :

Am 20.09.2014 um 16:44 schrieb Ben Coman <[email protected]>:

In consideration of Issue 11880, I wanted to better understand the concept of 
pragmas and how they are used in Pharo.
"Pragmas" seem to be used in other languages to provide "compile time" 
directives, but Pharo seems search for pragmas at runtime, for example to do things like build 
menus.  Mostly I'd consider menus fairly static (with any
Pharo’s pragmas are more like annotations (e.g. in Java).

dynamism statically defined).   In Issue 11880 adding a few caches brings menu 
generation from 80ms down to 5ms - but then there is the complexity of 
resetting them when the code that defines them changes.
So I wonder... can/do pragmas cause actions at compile time, like setting a 
class variable to nil when a method is compiled?  That seems a good way to 
reset a cache whose builder uses that method, but maybe there are problems I
I bet you can do that. All you need is to change the compiler accordingly :D

You don't have to change the compiler: just listen for MethodCreation / MethodChange / MethodRemoval system events, and do something if the method has the right pragma.

I believe the global menu stuff works that way. At least there is some code doing that; it shows up when you profile a Monticello package load.

Thierry

Reply via email to