Scripting again.

%u e at ee.com
Thu Dec 9 15:39:29 PST 2010


== Quote from Daniel Gibson (metalcaedes at gmail.com)'s article
> %u schrieb:
> > == 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
> > }
> > ----
> That wouldn't be just a script but a runtime-string-mixin (or something like that).
Yes, I forgot to change the s.execute to s.mixin :)

> I don't think something like that is feasible in a compiled language.
how about something like this:

s.execute(i);
Where in the script i will be the first arg in main?
That way the compiler knows which variables to export.


More information about the Digitalmars-d mailing list