On Wed, 4 Apr 2007, Andreas Rossberg wrote:

> I'm afraid it is - Compiler.evalWith is as close as you can get. The 
> reason is not so much lack of dynamism, but the non-priviledged status 
> and functional purity of compiler and toplevel in the Alice system.

> The interactive toplevel is even less magic. It is an ordinary 
> application, written all in plain ML, on top of the Compiler structure. 
> Roughly, all it does is running an interactive loop invoking 
> Compiler.evalWith and threading the environment (plus a few other 
> things, e.g. installing its own component manager to enable the reset 
> functionality). Thus the "current" environment can only be updated after 
> complete processing of an input, not in-between. IOW, all input has to 
> be sequentialised - that is what the "use" queue accomplishes.

This sounds like we should get along with Compile.evalWith, while updating 
a global env ref stored in our own toplevel environment.  (Isabelle 
provides a separate read-eval-print loop, but needs to be able to eval 
arbitrary ML code occasionally, without leaving that loop.)

A remaining hindrance appears to be the slightly strict handling of a 
sequence of toplevel ML declarations in Alice.  This problem can already 
be reproduced with the 'use' provided by the Alice toplevel.  For example:

  Alice> val a = 1; val b = a + 1;      (* works *)

  File a.ML:  val a = 1
  Alice> use "a.ML"; val b = a + 1;     (* fails, unknown `a' *)

  Alice> use "a.ML"; \n val b = a + 1;  (* works *)

The second version fails, because the whole line is compiled before the 
content of a.ML is evaluated.  The third version works again, because the 
read-eval-print loop happens to treat separate lines of input as units for 
sequential evaluation (cf. tools/toplevel/TextToplevel.aml).

As far as I understand other ML toplevels (notably Poly/ML), the outermost 
loop takes care not to read chunks of declarations too eagerly.  Thus the 
natural sequential division of toplevel declarations is maintained.  E.g. 
decl1; decl2 is processed as

  compile(decl1); exec(decl1); compile(decl2); exec(decl2)

instead of

  compile(decl1); compile(decl2); exec(decl1); exec(decl2)

performed in Alice, as it seems.  The same problem is encountered, when 
'use' occurs recursively within the used file.

Is there a chance to get the former kind of seqential Compile.evalWith in 
Alice?  Or maybe just a parser function to split a string consisting of 
several ML declarations into a list of strings?


        Makarius

_______________________________________________
alice-users mailing list
[email protected]
http://www.ps.uni-sb.de/mailman/listinfo/alice-users

Reply via email to