3 ms·
I think this might waste resources for some transient results. Sometimes that computation time required for evaluation is negligible, and the result might requi
by jstimpfle 9y ago
I think this might waste resources for some transient results. Sometimes that computation time required for evaluation is negligible, and the result might require more memory than "the function call".
- WalterBright 9y agoIt's been in D for a decade, and has been extremely successful, to the extent of becoming a critical feature. An early example was someone wrote a ray tracer in D that ran and generated output completely at compile time. A more useful example is D's regex package can build the engine at compile time, thereby emitting a custom engine for the regex, instead of at runtime.
- barsonme 9y agoWhile I think it's awesome D can do that (and am a bit jealous the languages I use regularly don't have any real sort of constexpr) what does that _really_ provide? It would seem the startup cost of building a regexp engine would really only matter for, say, command-line programs (i.e., short-lived, run-once programs). For a web application the overhead would be negligible. Again, don't get me wrong, but it just seems to be more of a "neat!" thing than a "we _need_ this for reasons X, Y, and Z."
- WalterBright 9y agoMost regex engines build interpreter bytecode at runtime, and then execute the bytecode with an interpreter. Being able to generate the engine at compile time means the runtime engine is running custom compiled code. So, what it _really_ provides is runtime performance.