Can we do compile time reading part of a file using import?

Jack jckj33 at
Sun Oct 25 16:52:43 UTC 2020

On Friday, 23 October 2020 at 16:42:00 UTC, data pulverizer wrote:
> Hi all,
> the `import` function allows a file to be read at compile time, 
> which opens up great opportunities for (mostly binary) file IO, 
> where data types can be coded into files - the user doesn't 
> need to know data types ahead of time. As specified in my old 
> blog article: 
> Binary files can be very large and reading the whole file at 
> compile time is often unnecessary.
> This isn't exactly the intended use for the function, but there 
> it is. Since compile time read capability already exists and is 
> useful, adding capability to be able to read only a portion of 
> the file at compile time in a given location is advantageous 
> and has utility.
> For me it's not make-or-break, it just something very useful 
> and I think has clear use case. Please let me know if there are 
> aspects or alternatives I am missing.
> Thanks

That's a really good approach, I always wanted to do things like 
this in C# but that wasn't possible due to C#'s lack of CTFE. 
Could be good if we find a out a way to read part of the file and 
lazy-reading.Sure an external tool could do the first job, I mean 
if we could find a way in pure D.

More information about the Digitalmars-d-learn mailing list