CTFE and DI: The Crossroads of D

H. S. Teoh hsteoh at quickfur.ath.cx
Wed May 9 17:35:29 PDT 2012


On Wed, May 09, 2012 at 08:06:24PM -0400, Nick Sabalausky wrote:
> "H. S. Teoh" <hsteoh at quickfur.ath.cx> wrote in message 
> news:mailman.489.1336603453.24740.digitalmars-d at puremagic.com...
[...]
> > This is why I kept proposing that .di's should have zero
> > implementation.  ZERO. No function bodies, no template bodies,
> > NOTHING except API information. All of the implementation stuff
> > should be compiled into some intermediate form and stuck into
> > special sections in the object file that the compiler understands.
> > For example, it can be a serialized AST of the corresponding source.
> > When you import the module, the compiler automatically looks up the
> > corresponding section in the precompiled library and gets whatever
> > info it needs (template bodies, CTFE function bodies, whatever).
[...]
> There's no need for all that.
> 
> The whole point here is "Compile to some obfuscated form" right? So
> just make/use a good code obfuscator. Done. Problem solved.
> 
> Inventing an AST storage format just to obfuscate some code is
> unnecesary overkill (although maybe it might have some other use).
> This "just use an obfuscator" approach even makes the whole DI system
> become totally redundant (except for binding to C code, of course).
[...]

This is an interesting idea. Probably more feasible than mine.

You don't necessarily have to throw away the DI system; some people may
sleep better at night if their proprietary algorithms are in binary
executable form only (though personally I think that's just self
delusion, but who am I to judge?). So you just take the existing .di
files, complete with all their warts and function bodies and whatever,
and run an obfuscator on them. Ship the .di and your shared library as
usual.  Problem solved.

Plus, all of this is already possible with the current system, except
for the only missing piece of a D obfuscator.

(Wait, I hear you cry. But what about the library API? How would users
know how to use the library if the .di is incomprehensible?  As somebody
pointed out in another thread: just ship the ddocs generated from the
unobfuscated source with the library. Users don't need to read the .di.
Problem solved.)


T

-- 
IBM = I'll Buy Microsoft!


More information about the Digitalmars-d mailing list