Mixins and compile-time coding
janderson
askme at me.com
Tue Feb 6 20:52:19 PST 2007
janderson wrote:
> Walter Bright wrote:
>> janderson wrote:
>>> Here's a suggestion that I actually sent a couple of of years ago
>>> that actually make sense now with the new mixin stuff. What if you
>>> could plugin dlls into DMD that would be run at compile time. The
>>> requirement of use would be that the input parameters would be constant.
>>
>> The main problem with this is the malware author who puts some source
>> code up, and when you try to compile it, it would install a rootkit.
>
> Good point. What about the static version. ie
>
> //This would be compiled on the fly. It could be put into its own object
> file so it doesn't need to be re-built everytime.
> mixin char[] stateMachine(char[] input)
> {
> ...
> }
>
> void main()
> {
> stateMachine("ect...");
> }
>
> or
>
> plugin char[] stateMachine(char[] input)
> {
> ...
> }
>
> void main()
> {
> mixin(stateMachine("ect..."));
> }
>
> or
>
> char[] stateMachine(char[] input)
> {
> ...
> }
>
> void main()
> {
> mixin(plugin stateMachine("ect..."));
> }
>
>
> Something like that.
>
>
> I guess malware may still be possible, but you can do that with unit
> tests now. Essentially these are not much more then unit tests.
>
> -Joel
Actually you could go one step better with this. No calls to functions
outside of D. That way you'd have access to all of D's
string/int/float/array operations but you wouldn't be able to make
systems calls at all. You could also disabled asm calls if you wanted
to get really restrictive although I don't see that as necessary.
The only way you'd be able to hack the system is to do some sort of
funky memory accessing.
-JOel
More information about the Digitalmars-d
mailing list