Python eval() equivalent in Dlang working in Runtime?

tsbockman thomas.bockman at gmail.com
Fri May 1 18:37:41 UTC 2020


On Friday, 1 May 2020 at 18:07:54 UTC, H. S. Teoh wrote:
> On Fri, May 01, 2020 at 05:44:27PM +0000, tsbockman via 
> Digitalmars-d-learn wrote:
>> On Friday, 1 May 2020 at 15:42:54 UTC, Baby Beaker wrote:
>> > There is a Python eval() equivalent in Dlang working in 
>> > Runtime?
>> 
>> No, and there almost certainly never will be due to 
>> fundamental differences between the languages. Depending on 
>> your goal, the closest alternatives are using the string mixin 
>> language feature, writing a parser (std.conv or certain DUB 
>> packages can help), or embedding a scripting engine such as 
>> AngelScript or Squirrel into your program.
> [...]
>
> Actually, if you're willing to ship a working copy of dmd with 
> your program, you *could* compile D code on-the-fly and 
> dynamically load it as a dll/shared library.

Good to know, but that's quite different from the eval() of 
interpreted languages with respect to both semantics and 
performance, so it's really another item for the "D alternatives 
to eval()" list.


More information about the Digitalmars-d-learn mailing list