Reading IDX Files in D, an introduction to compile time programming

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Aug 21 20:33:51 UTC 2020


On Fri, Aug 21, 2020 at 01:18:30PM -0700, Ali Çehreli via Digitalmars-d-announce wrote:
[...]
> 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).

The actual limitation is that string imports do not allow reading
directory contents (the C function can be replaced if such were
allowed).  Generally, I don't expect directory traversal to ever be
allowed at compile-time, since it opens the door to a huge can o'
security worms. :-P


> 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.

Yeah, that's probably the simplest solution.


[...]
> 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.)
[...]

fakePureCalloc is a red herring; even if it weren't a problem, you'd
eventually run into the problem that you cannot do directory traversal
at compile-time.


T

-- 
Time flies like an arrow. Fruit flies like a banana.


More information about the Digitalmars-d-announce mailing list