New syntax for string mixins
Don
nospam at nospam.com
Sat Dec 18 05:12:27 PST 2010
VladD2 wrote:
> Don Wrote:
>> Suppose the pre-compiled code, when run, asks what CPU it's on. What's
>> the answer? Is it X or Y?
>
> Current: X
> Target: Y
>
> Macro - a plugin to the compiler. It works on the same platform as the compiler, but generates code through the API which abstracts the macro from the target platform. If you need generate platform specific code, you should worry about it in macro logic.
> In any case macro is a meta-programm wich generate or/and transform code.
Yes. But in D there's no distinction between code which is destined for
a macro, versus any other function. You can call a function once at
compile time, and the same function at compile time. My understanding of
Nemerle (which is quite likely to be wrong!) is that at least some
functions are callable only at compile-time.
I'm also scared of the implications of allowing arbitrary code execution
during compilation. Make a typo in your program, and then compilation
may wipe files from your hard disk, or corrupt an external database,
etc... On some platforms you may be able to sandbox it, but since it's
running as part of the compilation process, rather than with the
permissions it will eventually have, it just seems like a security
nightmare.
All these problems would be reduced somewhat if it were only permissible
to call pure functions at compile time. Although even that has issues,
since not all compiler platforms may allow calling of shared libraries.
If we build that into the language, we'd be cutting ourselves off from
those platforms.
I'm not certain that there are any unsurmountable problems, but these
issues make me really cautious.
More information about the Digitalmars-d
mailing list