On 8/21/20 8:04 AM, data pulverizer wrote:
I have written an article targeted at people new to D on compile-time programming: https://www.active-analytics.com/blog/reading-idx-files-in-d/ and tweeted it here: https://twitter.com/chibisi/status/1296824381088440320?s=20

Comments welcome.

Thanks in advance.

Great article. (There are other typos in there; I would be happy to review your next articles. :) )

I use "import expressions" for parsing files at compile time as well but your article gave me some ideas where I may be able to parse types of fields very similar to your example.

In my case I found a limitation: I cannot "iterate a directory" and import all file contents in there (the limitation is related to a C library function not having source code so it cannot be evaluated). So, I use a build step to generate the file that contains all files in my directory. So, I first import the file list then 'static foreach' that list to import and parse contents of other files.

For the record, here is an example of code that does not work at compile time:

import std.file;

void main() {
  static foreach (entry; dirEntries(".", SpanMode.shallow)) {
  }
}

Error: `fakePureCalloc` cannot be interpreted at compile time, because it has no available source code

(I think the error message is different in dmd 2.084 where my project currently uses.)

Ali

Reply via email to