Skip to content
David Pearce edited this page May 11, 2017 · 6 revisions

This is a general discussion page about adding meta-programming support to Whiley. For example, C++ provides support for meta-programming via templates, whilst Rust provides support via macros. Whiley has a proposal now for extending the language with templates (see https://github.com/Whiley/WhileyCompiler/issues/540). Some pointers:

Use Cases

What uses cases do we want to support for meta-programming?

From Issue #740

In real world programming scenarios one often ends up writing scripts that turn data-files into code. Often one also have to update multiple locations with the same data, manually.

It would be very useful to have a feature where the programmer could specify a "lazy" transform from XML/JSON/tab-separated-file to Whiley.

The goal is to make the data available in Whiley-code through some query mechanism, a transform into constants or some other "injection" method.

In Rust you can do this using Macros:

http://stackoverflow.com/questions/32956050/how-to-create-a-static-string-at-compile-time

I have found some situations where this is useful. For example, in creating a Z80 emulator it's useful to include the boot ROM as a compile-time constant from a file.

Clone this wiki locally