3 ms·
But I don't know where you'd get that source code from at runtime though? I'm sure there are languages that contain enough runtime information, but, as an perti
by wtetzner 9y ago
But I don't know where you'd get that source code from at runtime though? I'm sure there are languages that contain enough runtime information, but, as an pertinent example, there isn't a way to tell that you have an object with certain fields in OCaml at runtime. It's just a block at runtime. All of the names are gone, as they were only used at compile time.
- yorwba 9y agoI was assuming the TypeScript/JavaScript scenario, where TypeScript objects are implemented as JavaScript objects and their structure is available at runtime. Of course it does not work if you do not have that reflection capability.
- lilactown 9y agoYou can provide your own type guards: https://www.typescriptlang.org/docs/handbook/advanced-types.html https://www.typescriptlang.org/docs/handbook/advanced-types.... Doing this in the general case, I assume, is probably not practical.