jk
jk copied to clipboard
Expose std in the inline jk execution
Extracted from #188.
We currently import specific symbols from std in the inline template (log
, write
, read
) we could, instead, do:
import * as std from '@jkcfg/std/std';
so we don't miss symbols (such as Format
) and are future (eg. I'd like to add a logerr
that outputs to stderr).
Just to set out some trade-offs:
-
Given that the standard library is built into the runtime, its contents will be static for a particular release. So the sense in the which this is future-proof is that it doesn't need to be adjusted in the jk source code when a named export is added to std -- and not (as might initially seem the case) that the runtime will automatically pick up new capabilities when things are added to the standard library.
-
It makes inline scripts a little more wordy, because they'll have to include
std.
when referring to things from std (this can be regarded as a positive too) -
scripts that try to use things not in
std
can fail in less obvious ways. For example, if I try to usestd.format
instead ofstd.Format
as a value, the script will run and I'll (probably) get an unexpected output; whereas, if I try to useformat
instead ofFormat
, the script will fail to compile.