Maybe D is right about GC after all !
codephantom
me at noyb.com
Thu Dec 28 02:07:26 UTC 2017
On Wednesday, 27 December 2017 at 20:24:04 UTC, Walter Bright
wrote:
>
> This illustrates my point if it was unclear:
>
> C++:
> int foo(int* p) { return p[1]; }
> int bar(int i) { return foo(&i); }
>
> clang++ -c test.cpp -Wall
>
>
> D:
> @safe:
> int foo(int* p) { return p[1]; }
> int bar(int i) {return foo(&i); }
>
> dmd -c test.d
> test.d(3): Error: safe function 'test.foo' cannot index
> pointer 'p'
> test.d(4): Error: cannot take address of parameter i in
> @safe function bar
Well,I can press the accelerator on my car to the floor, and
crash the car.
But is that a problem with the car, or the way I used it
(referring to the C++ portion of your example)? Would be better,
and fairer, to write that portion in modern C++, and then make
the comparison with D.
And sure, we can (and do) make cars that modify the acceleraton
potential, but then you can't do burnouts ;-(
So safety certainly does have real value..but it always wants to
take something away. (and unfortunately, we're becoming a very
risk averse society, with more and more freedoms being taken away
in the name of 'safety' - but I divert..)
Of course, the nice thing about D, is that we can (for the most
part) switch it from one to the other...so I like that a lot.
But when I really want to put the pedal to the metal, I still
look to C.
(although, one day the government will try to make C illegal too
I guess).
More information about the Digitalmars-d
mailing list