Let's not make invariants const
Marco Leise
Marco.Leise at gmx.de
Fri Aug 3 19:20:41 PDT 2012
Am Fri, 03 Aug 2012 22:40:02 +0200
schrieb "bearophile" <bearophileHUGS at lycos.com>:
> Another solution (that doesn't replace the need for the
> prestate!) is ghost fields, that are class instance/struct fields
> usable only inside contracts and that vanish in release mode:
> http://d.puremagic.com/issues/show_bug.cgi?id=5027
>
> Bye,
> bearophile
While reading this thread I had the same idea. But the user must be 100% aware, that structs change size in release mode. This can be a real problem for data exchange with libraries using the same struct, in memory mapped files or in files.
Just imagine you stored some structured data in a file using the pointer and size of such a struct in release mode. Then you debug the program and you don't realize why the file cannot be loaded any more.
If it weren't for the systems programming language part (.sizeof, &...), it could be a nice proposal.
--
Marco
More information about the Digitalmars-d
mailing list