Export statement?

Nick Sabalausky SeeWebsiteToContactMe at semitwist.com
Tue Oct 16 14:51:14 PDT 2012


On Tue, 16 Oct 2012 23:43:52 +0200
Piotr Szturmaj <bncrbme at jadamspam.pl> wrote:

> We have:
> 
> ImportExpression:
>      import ( AssignExpression )
> 
> Why not also add this:
> 
> ExportStatement:
>      export ( AssignExpression, AssignExpression )
> 
> Both of the AssignExpressions must evaluate at compile time to a 
> constant string. The text contents of the first string are
> interpreted as a file name. The text contents of the second string
> are written to the file specified in the first argument, overwriting
> previous content if the file exists.
> 
> Implementations may restrict the file name in order to avoid security 
> vulnerabilities. A possible restriction might be to allow only paths 
> specified in the compiler option.
> 
> (the above was shamelessly copied from D docs and then modified)
> 
> Export keyword already exist, it's used only as protection attribute,
> so this proposal would not cause ambiguity.
> 
> About some use cases, off the top of my head:
> - generating build scripts or their parts from the code.
> - generating code to instantiate C++ templates when linking with C++
> code.
> - debugging complex ctfe function output, f.i. string to be mixed in 
> (pragma(msg, ...) is a half solution).
> 
> What do you think?

Yea, CTFE definitely could use better IO ability.



More information about the Digitalmars-d mailing list