Hi all,
With Opal, if you want to customize how methods are compiled into a class you can override #compilerClass on class-side: MyClass class>>#compilerClass ^ MySpecialCompiler However this custom compiler is not taken into account when compiling methods on the class-side: MyClass class compilerClass ---> OpalCompiler I was expecting to have the same compiler class for the metaclass. The consequence is that right now there is no way to specialize how methods are compiled in *one* metaclass. Is it on purpose or is it a bug? Also is there cases where one wants instance-side methods and class-side methods to be compiled with different compiler classes? My rough guess is that in most cases you want the same compiler class, but I don't fell confortable forcing that. So I propose to add a method #classSideCompilerClass: Class>>#classSideCompilerClass ^ self compilerClass Then compilerClass can be implemented for metaclasses: Metaclass>>#compilerClass ^ self instanceSide classSideCompilerClass Likewise, if I override compilerClass, it is taken into account for both instance-side and class-side methods but I can still say that I want a different compiler for class-side methods by overriding classSideCompilerClass. Tell me what you think about it and if you're ok, I open a bug entry with the slice. Cheers, Camille |
On 27 Aug 2014, at 17:53, Camille Teruel <[hidden email]> wrote:
This is a bug, clearly.
I hope not… but the, could be interesting (e.g. when experimenting). If the overhead is not large, this would be nice.
Yes, this looks good! Marcus
|
Ok then, here the bug entry https://pharo.fogbugz.com/f/cases/13938/Opal-custom-compilers-and-class-side-methods
Slice in inbox On 28 août 2014, at 10:24, Marcus Denker <[hidden email]> wrote:
|
In reply to this post by camille teruel
On 27 Aug 2014, at 17:53, Camille Teruel <[hidden email]> wrote:
I’ve missed this feature. This is super cool!
|
On 28 Aug 2014, at 15:54, Yuriy Tymchuk <[hidden email]> wrote:
There is now in addition #compiler, an instance, not the class. This is useful as you can set compiler options this way. e.g. InstructionStream does not need to use a subclass but can do compiler "The JIT compiler needs to trap all reads to instance variables of contexts. As this check is costly, it is only done in the long form of the bytecodes, which are not used often. In this hierarchy we force the compiler to always generate long bytecodes" ^super compiler options: #(+ optionLongIvarAccessBytecodes) |
On 28 août 2014, at 15:58, Marcus Denker <[hidden email]> wrote:
|
In reply to this post by Marcus Denker-4
On 28 August 2014 15:58, Marcus Denker <[hidden email]> wrote:
Right. Factory method(s) like this are significantly more flexible, since implementor may want to provide a special way of initializing the compiler, you can't foresee via class standard '#new' protocol before hanging it over to user. Giving just a class, make things quite hard and limiting.. especially in situation when developer wants to make a subclass which carries additional state , which needs to be initialized properly. That's why, I prefer to use factory methods instead of 'SomethingClass' everywhere i need.
-- Best regards, Igor Stasenko. |
In reply to this post by camille teruel
On 28 Aug 2014, at 16:03, Camille Teruel <[hidden email]> wrote:
yes… but when #compiler is set, it should be valid for both instance and class side...
|
On 28 Aug 2014, at 16:32, Marcus Denker <[hidden email]> wrote:
or not: as it seems to never have applied to the class side, it should be fine to keep them separate. that is, #compiler applies to instance side, and a classSideCompiler applies to the class side by default people only override the instance side one, but when needed, they can override the classSide one, too. (e.g. when you do a DSL, you want to still have the #initialize on the class side be untouched smalltalk in most cases). Marcus
|
In reply to this post by Marcus Denker-4
+1 Objects are always better than classes :) Doru On Thu, Aug 28, 2014 at 2:58 PM, Marcus Denker <[hidden email]> wrote:
"Every thing has its own flow"
|
Free forum by Nabble | Edit this page |