On 13 Jun 2015, at 14:39, Clément Bera <bera.clement@gmail.com> wrote:
Dear Clement,
This is an interesting problem. There is currently no simple way of executing a message at compile-time instead of at runtime in Pharo, which is useful to have settings but no runtime overhead.
I did a simple extension for opal compiler for this purpose, adding the message Cvalue, which is compiled by Opal either to its receiver's block value or the result of its value depending on the result of #allowPrecompilation sent to its class using AST manipulation before the semantic analysis.
are you aware of the compile time constants in GNU Smalltalk. The syntax that was picked is ##(EXPR). E.g. the below is an example for usage in GNU Smalltalk. someMethod ^##(Character value: 8) the compiler will create a CompiledMethod that holds a literal ($<8>) and will return it. In general I find that syntax quite nice. cheers holger