Embedding a limited interpreter in a SISC Scheme application.

"Igor Hjelmstrom Vinhas Ribeiro" <[email protected]> Tue, 13 Mar 2007 09:48:53 -0300
Newsgroups gmane.comp.java.sisc.user
Message-ID <[email protected]>
Hello everyone!

  Disclaimer: I was told that if I understood what a meta-circular
interpreter is
I wouldn't make the questions below. I am reading
http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-26.html#%_sec_4.1
and it seems it is really possible to solve my problems using one. However,
I am under the impression that there *must* be an way and better (in the
performance dimension) way - if this impression is wrong please tell
let me know.

   First of all: SISC is really great! - and the user manual
incredibly good. For
someone immersed in the Java world for so long like me it is being really
easier to learn Scheme using SISC. When things get ugly and I feel
lost, or when I am feeling lazy, I can always go back to my old habit and do
things like:

(define-generic-java-method java-trim |trim|)

(define string-trim
  (lambda (s)
    (->string (java-trim (->jstring s)))))

And then (string-trim "   abc    ")  ===> "abc" ...

 Hehe :-)

Now.... I have a question for you:

   I am creating one application in Scheme/SISC  and I would like that the
user of the application could extend it using Scheme. However I would need the
user to have access to a limited subset of what SISC can do.

   A few closures will be available for the user. For instance:

(buy-stock-when <stock-code> <amount>
<threshold-after-which-start-buy> <stop-loss-minimum-value>)

(current-stock-price <stock-code>)

   I don't want the user to be able to instantiate and use arbitrary
Java classes
and I also don't want him to be able to read and open files. open-input-file and
similar functions shouldn't even be even defined.

   I also would like to limit the amount of memory and processing power a
single limited interpreter could use.

   The reason for this is there could be multiple users of the
application (hence
the memory and CPU limits) and that it doesn't make sense for them to deal
with files on the application server machine.

   I just want users to have the full power of Scheme/SISC as one algorithm
designing language while not allowing them to wreak havoc in the system they are
using.

   Do you have any tips or pointers/links on how to implement this? I could deal
with the memory and processing power constraints in the Java side if there is no
easier way to do it using SISC... the other limitations are my biggest
concern right
now...

Regards,
 Igor.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV