O'Reilly logo

D Cookbook by Adam D. Ruppe

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Communicating with a dynamic scripting language

D's features also lead to easy integration with dynamic languages. It can host a dynamic type as well as dynamic objects.

Getting ready

To begin, download bindings to a scripting language. Here, we'll use the one I wrote whose syntax is inspired by both D and JavaScript. It was written with the goal to blur the line between the D code and the script code—the scripting language's dynamic type can also be used in D itself. Download jsvar.d and script.d from the following website:

Build your program with all three files on the command line, as follows:

dmd yourfile.d jsvar.d script.d

How to do it…

Let's execute the following steps to communicate with JavaScript:

  1. Create ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required