Scripting again.
so
so at so.do
Thu Dec 9 16:15:03 PST 2010
> I guess something like that is possible.
>
> I'd prefer something like
> s.call("main", i);
> and also
> s.call("foo", 42, x);
> though - so you can define multiple functions in a script and call them.
>
> Or maybe, with more magic and support within the D compiler
> s.main(i);
> s.foo(42,x);
> But that means that the compiler needs to know the Script type, create a
> class for each script that contains the functions called on the script
> ("main", "foo"), create stubs for them that either do something like
> call("foo",i) or, if no function foo with an appropriate argument is
> found in the script, throws an exception..
> Probably possible, but certainly not easy.
> The first suggestion however (s.call("foo", i)) should be possible
> without support in the D compiler, all the work would be done in the
> Script class. Still not trivial, of course, especially with arguments
> for called functions and their type etc.
The actual use case in my scenario is manipulating your program. not
necessarily the other way around.
class ScriptBinary {
void run() {..}
}
// [modules] is the list of modules you give access to script
// if [modules] contains "std", script can access "std" and it is child
modules.
ScriptBinary compile(string filename, string[] modules, ...) {
...
}
--
Using Opera's revolutionary email client: http://www.opera.com/mail/
More information about the Digitalmars-d
mailing list