> On 23 May 2018, at 13:47, Marcus Denker <[email protected]> wrote:
>
>
>
>> On 23 May 2018, at 13:30, Thierry Goubier <[email protected]> wrote:
>>
>> 2018-05-23 13:20 GMT+02:00 Sean P. DeNigris <[email protected]>:
>>> Marcus Denker-4 wrote
>>>> method := Smalltalk compiler
>>>> environment: environment;
>>>> compile: 'tt ^MyClass’.
>>>
>>> Awesome! Is it possible to override a global from /within/ a method (e.g. in
>>> a test)?
>>
>> I think at the class level by manipulating that class compiler
>
> Yes. You can override the class side method:
>
> in Behaviour, it is defined as
>
> compiler
> "Answer a compiler appropriate for source methods of this class."
>
> ^self compilerClass new
> environment: self environment;
> class: self
>
> so you can just
>
> compiler
> “Change the compiler environment "
>
> ^super compiler
> environment: self myEnvironment
>
>
> and it should work.
Here we can see, too, that we need to do more work. In Behaviour:
environment
"Return the environment in which the receiver is visible"
^Smalltalk globals
For classes to automatically compile with the environment they are in, we
somehow need to return here
that environment…
Marcus