Restricting the scope for the compiler?

Tim Rowledge tim at sumeru.stanford.edu
Sat Jul 13 16:56:29 UTC 2002


I would like to be able to restrict the scope/environment/whatever
accessible to the compiler for use in an application.
What I have right now is a simple text substitution of sorta-variable
names followed by a simple {Compiler evaluate: '3 + 4'} level of
function. Unfortunately this would allow people to enter nice little
expressions like 'Smalltalk quitPrimitive' which would have an
unfortunate effect upon a seaside server.....

So far as I can see I need to cut off access to just about everything in
Smalltalk-the-system-dictionary. The application is intended to allow
pretty simple expressions that use simple literals (numbers, characters,
strings, collections of the above, stuff like that) to pose questions to
students. For example, a question might specify several variables
(companyName, profit, sales) all of which are randomly chosen values
from lists (like #('enron' 'harken' 'worldcom') for example). The
question might ask:- If {companyName} declares a profit of ${profit}
after sales of ${sales}, what is the percentage rate of return for
{companyName} directors? And the answer is calculated via:-
{profit}/{sales} * 4000000000000000000000000000
(this is an american company y'see).
There's all sorts of neat things one could do, but for now it has to be
near trivial. It's for accounting students after all :-)

Is there anything already in the (3.2) system I can use, or do I have to
try to work it out? I really hate screwing around with compilers. They
always seem to have more unannounced assumed invariants than royal
banquet etiquette.

tim
-- 
Tim Rowledge, tim at sumeru.stanford.edu, http://sumeru.stanford.edu/tim
Nostalgia:  The good old days multiplied by a bad memory...




More information about the Squeak-dev mailing list