Behavior>>#compiler directly refers EsCompiler

55 views
Skip to first unread message

Gabriel Cotelli

unread,
Jul 15, 2011, 9:06:26 PM7/15/11
to va-sma...@googlegroups.com
Hi,
anybody knows why:

Behavior>>compiler
"Answer the compiler class to use for the receiver's methods. Override
this method if your class accepts code which does not use the standard
syntax."
^self environment classAt: #EsCompiler

is implemented that way instead of using #Compiler ?

I think is better to use the global (Compiler) instead of the class (EsCompiler) to allow changing easily the default compiler implementation for another one. I'm doing some experimentation and would be good to have this facility.

Regards,
Gabriel

Thomas Koschate

unread,
Jul 18, 2011, 10:06:16 AM7/18/11
to va-sma...@googlegroups.com
Gabriel, by allowing subclasses to override #compiler, it becomes possible to easily provide a customized compiler for a class or hierarchy of classes without affecting system behavior globally.  If you look at senders of #compiler, you can see where that can get interesting.  For your experimentation, I'd suggest that this is actually a better way to go about it, since you can try things for your test classes without breaking the whole environment.  Once you're happy with your new compiler, you can set the global Compiler in whatever way you want.  See EsCompiler class>>#initializeAfterLoad.

Tom

Gabriel Cotelli

unread,
Jul 20, 2011, 4:44:09 PM7/20/11
to va-sma...@googlegroups.com
Hi Tom,
that's exactly what I'm doing. I'm now ready to change globally the compiler but changing the global doesn't work as expected because some tools sends compiler to the class and the implementation in Behavior always returns EsCompiler and not the global.

Gabriel
Reply all
Reply to author
Forward
0 new messages