Partial classes
Walter Bright
newshound2 at digitalmars.com
Tue Jun 26 12:54:00 PDT 2012
On 6/26/2012 12:52 PM, Timon Gehr wrote:
> 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)
If the compiler doesn't give an error on that, it's a compiler bug, not a
language problem.
More information about the Digitalmars-d
mailing list