Scripting again.

%u e at ee.com
Thu Dec 9 15:27:14 PST 2010


== Quote from so (so at so.do)'s article
> > Doesn't this work??
> >
> > import std.file;
> > import std.script;
> >
> > Script s = new Script(cast(ubyte[]) read("script1.d"));
> > s.compile();
> > s.execute();
> What is this supposed to mean?

This should be a bit more clear (untested code).

--scrip1.d
import std.stdio;
writefln(i);
----

--main.d
import std.file;
import std.script;

void main(){
  Script s = new Script(cast(ubyte[]) read("script1.d"));
  assert(!s.validate);
  int i = 1;
  assert(s.validate);
  s.compile();
  s.execute(); // output 1
}
----


More information about the Digitalmars-d mailing list