aabtop / reify

Reify lets you embed a customized TypeScript runtime within a C++ application.
MIT License
6 stars 0 forks source link

Reduce verbosity of script files by putting reify.* declarations in to the default namespace. #8

Closed aabtop closed 4 years ago

aabtop commented 4 years ago

Currently we have code like this which includes frequent references to "reify.":

let jeep_wheel = reify.Cylinder(0.35, 0.15);

let my_jeep = reify.Mesh3UnionAsMesh3(reify.Mesh3Union({
  meshes: [
    reify.TranslatedMesh3(jeep_wheel, [1.0, 0.0, -0.5]),
    reify.TranslatedMesh3(jeep_wheel, [1.0, 0.0, -0.5]),
    reify.TranslatedMesh3(jeep_wheel, [1.0, 0.0, 0.5]),
    reify.TranslatedMesh3(jeep_wheel, [-1.0, 0.0, 0.5]),
    reify.TranslatedMesh3(jeep_wheel, [-1.0, 0.0, -0.5]),
  ]
}));

It would read nicer (and be easier to explain the system to a beginner) if we didn't have to prefix all Reify functions with "reify.".

Pros:

Cons:

In order to implement this, we would want to run the TypeScript compiler on the Reify interface ".ts" files during the build phase. We would have it produce a ".d.ts" file as well as a ".js" file. We would pass the ".d.ts" file into the embedded/wrapped TypeScript Compiler by appending it to the default library source. We would pass the ".js" file to be pre-loaded by the Reify-runtime before loading any modules, which also gives us the opportunity to create a snapshot of the implementation as well.

aabtop commented 4 years ago

Things were pretty bad before, but it's much better now, and while we still have "h." in front of a lot of things, it's not too bad and kind of makes sense, so it'll probably stay, and this can be closed out.