thisCompiler special variable

Florin X Mateoc mateoc_florin at jpmorgan.com
Thu May 18 16:46:28 UTC 2000


the #compilerClass approach would not work when you extend existing classes.

I was thinking recently about a related idea - to have a special thisMethod
construct (the compiled method would keep a reference to itsef). I know that you
could also get there through thisContext, but it is time expensive and perhaps
you don't need the whole thing.
Although such constructs add complexity, it is not something that you have to
deal with immediately while learning Smalltalk, and obviously they add
flexibility. From my perspective, this plays on Smalltalk's strength.


Florin





rwuyts at vub.ac.be on 05/18/2000 05:32:04 AM

Please respond to squeak at cs.uiuc.edu

To:   squeak at cs.uiuc.edu
cc:   (bcc: Florin X Mateoc)
Subject:  Re: thisCompiler special variable




Instead of using these kind of global checks in the code, it is probably
better in this case to just override the #compilerClass method on the class
side. By default this is set to Compiler, but you could override it to
return DebugCompiler (or whatever) instead. Maybe you could override this to
check in that specific place to see whether debugging is enabled or not
(which would eliminate the checks throughout the code).

BTW: The Colored Syntax should have been done that way too, I think ...

> I've always wanted a way of specifying compile time directives in method
> source.  I just had a thought that it might be nice to expose a new special
> variable called "thisCompiler" (or maybe thisParser?).
>
> Then we could write code like:
>
> someMethod
>
>  thisCompiler ifDebug: [
>   self printDebugInfoInTranscript.
>  ].
>  self doSomething.
>
> - or -
>
> someMethod
>
>  ^thisCompiler valueNow: [
>   IdentityDictionary new
>    at: 'US' put: 'United States';
>    at: 'UK' put: 'United Kingdom';
>    yourself
>  ].
>
> - or even -
>
> someMethod
>
>  thisCompiler primitive: 'primname' module: 'modulename'.
>  self primitiveFailed.
>
> ---
>
> In the #ifDebug: case you could set or reset a compiler flag for debugging,
> then re-compile all senders of #ifDebug: to yield compiled methods with
> either the debug code embedded, or ignored.  The second case is an
> alternative to special syntax that other dialects introduce (dolphin allows
> ##() to denote evaluation at compile time).  Also, (but less importantly) it
> could be used to eliminate the special syntax for primitive declarations.
>
> I haven't really thought through the idea, but at first glance it seems like
> it would be very useful.  I might take a stab at it if people think it's a
> good idea.  Thoughts?
>
> - Stephen
>


--
Roel Wuyts                    Programming Technology Lab
rwuyts at vub.ac.be              Vrije Universiteit Brussel
http://prog.vub.ac.be/~rwuyts
Webmaster of European Smalltalk User Group: www.esug.org








This communication is for informational purposes only.  It is not intended as
an offer or solicitation for the purchase or sale of any financial instrument
or as an official confirmation of any transaction. All market prices, data
and other information are not warranted as to completeness or accuracy and
are subject to change without notice. Any comments or statements made herein
do not necessarily reflect those of J.P. Morgan & Co. Incorporated, its
subsidiaries and affiliates.





More information about the Squeak-dev mailing list