Partial classes
Timon Gehr
timon.gehr at gmx.ch
Tue Jun 26 12:52:54 PDT 2012
On 06/26/2012 09:29 PM, Artur Skawina wrote:
> On 06/26/12 20:21, Walter Bright wrote:
>> On 6/26/2012 3:53 AM, Jacob Carlborg wrote:
>>> replace arbitrary methods and classes, even in the standard library. In D you
>>> can overwrite an arbitrary piece of memory.
>>
>> Not when using safe code, you can't.
>
> void poke(T)(size_t addr, T val) @safe pure {
> T* ptr;
> ptr[addr/T.sizeof] = val;
> }
>
> int i = 42;
>
> void main() @safe {
> writeln(i);
> auto whatever = cast(size_t)&i;
> poke(whatever, 666);
> writeln(i);
> poke(0, 0);
> }
>
> void writeln(A...)(A a) @trusted { import std.stdio; writeln(a); }
>
> artur
This is not legal D code. (pointer indexing is unsafe)
More information about the Digitalmars-d
mailing list