On 28 August 2014 15:58, Marcus Denker <[email protected]> wrote:

>
> On 28 Aug 2014, at 15:54, Yuriy Tymchuk <[email protected]> wrote:
>
>
> On 27 Aug 2014, at 17:53, Camille Teruel <[email protected]> wrote:
>
> 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
>
>
> I’ve missed this feature. This is super cool!
>
>
> There is now in addition #compiler, an instance, not the class.
>
>
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.



> 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)
>
>


-- 
Best regards,
Igor Stasenko.

Reply via email to