On Friday, 10 June 2016 at 15:30:19 UTC, Wyatt wrote:
globals.write = &(writeln!string);
Woah, I never thought of using it like that!
Yeah, since writeln is a template, you need to instantiate it
with some arguments. This isn't the ideal way to do it in the
script btw, it'd be like:
globals.write = (var this_, var[] args) { writeln(args); };
or something like that - this signature gives a variadic function
to the scripting language, whereas writeln!string just has a
single argument.
But, of course, the script language cannot instantiate D
templates itself, so you gotta do that before assigning it to the
runtime var. But from there, the jsvar.d reflection code will
handle the rest of var<->string conversions.
I use it in my toml parser and it's very pleasant. I figured
it probably isn't very fast, but it works and that's important.
kewl! Did you use the script component for interpreting or just
the jsvar part for the data?