Launch and obtain thread output during compile time
    via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Sun Aug 13 01:09:28 PDT 2017
    
    
  
On Sunday, 13 August 2017 at 07:37:15 UTC, data pulverizer wrote:
> Hi all,
>
> Is it possible to launch/spawn a thread/fibre or some other 
> appropriate item and obtain an immutable/enum or some 
> appropriate output at compile-time? For instance return an 
> immutable(string) from the external thread to be used as the 
> input to a template parameter or a CTFE function. To be clear 
> the thread carries out run-time processing e.g. reading a file.
>
> Thanks in advance.
No, CTFE is single-threaded and additionally it is required that 
functions executed at compile-time are "pure", i.e. they don't 
affect the global state of the system and don't use any 
non-portable facilities. Essentially, only pure computation is 
allowed.
Though, specifically reading files is allowed at compile-time via 
the `string s = import("file.txt");` syntax, provided that the 
file `file.txt` is located in a directory, specified to the 
compiler by the `-J` flag. For more information see:
http://dlang.org/spec/expression.html#import_expressions
    
    
More information about the Digitalmars-d-learn
mailing list